~emersion/soju

e2e232fa9c106e5cbd77bbb9e31b5e21e85c9da5 — Simon Ser 8 days ago 80ed0d2
config: add `message-store memory`

The old way to do this was `message-store fs ""`, which is
misleading.
3 files changed, 24 insertions(+), 9 deletions(-)

M cmd/soju/main.go
M config/config.go
M doc/soju.1.scd
M cmd/soju/main.go => cmd/soju/main.go +1 -1
@@ 86,7 86,7 @@ func loadConfig() (*config.Server, *soju.Config, error) {
	cfg := &soju.Config{
		Hostname:        raw.Hostname,
		Title:           raw.Title,
		LogPath:         raw.LogPath,
		LogPath:         raw.MsgStoreSource,
		HTTPOrigins:     raw.HTTPOrigins,
		AcceptProxyIPs:  raw.AcceptProxyIPs,
		MaxUserNetworks: raw.MaxUserNetworks,

M config/config.go => config/config.go +14 -5
@@ 45,7 45,9 @@ type Server struct {

	SQLDriver string
	SQLSource string
	LogPath   string

	MsgStoreDriver string
	MsgStoreSource string

	HTTPOrigins    []string
	AcceptProxyIPs IPSet


@@ 64,6 66,7 @@ func Defaults() *Server {
		Hostname:        hostname,
		SQLDriver:       "sqlite3",
		SQLSource:       "soju.db",
		MsgStoreDriver:  "memory",
		MaxUserNetworks: -1,
		MultiUpstream:   true,
	}


@@ 110,12 113,18 @@ func parse(cfg scfg.Block) (*Server, error) {
				return nil, err
			}
		case "message-store", "log":
			var driver string
			if err := d.ParseParams(&driver, &srv.LogPath); err != nil {
			if err := d.ParseParams(&srv.MsgStoreDriver); err != nil {
				return nil, err
			}
			if driver != "fs" {
				return nil, fmt.Errorf("directive %q: unknown driver %q", d.Name, driver)
			switch srv.MsgStoreDriver {
			case "memory":
				srv.MsgStoreSource = ""
			case "fs":
				if err := d.ParseParams(nil, &srv.MsgStoreSource); err != nil {
					return nil, err
				}
			default:
				return nil, fmt.Errorf("directive %q: unknown driver %q", d.Name, srv.MsgStoreDriver)
			}
		case "http-origin":
			srv.HTTPOrigins = d.Params

M doc/soju.1.scd => doc/soju.1.scd +9 -3
@@ 133,9 133,15 @@ The following directives are supported:
	  strings, see:
	  <https://pkg.go.dev/github.com/lib/pq#hdr-Connection_String_Parameters>.

*message-store* fs <path>
	Path to the bouncer logs root directory, or empty to disable logging. By
	default, logging is disabled.
*message-store* <driver> [source]
	Set the database location for IRC messages. By default, an in-memory message
	database is used.

	Supported drivers:

	- _memory_ stores messages in memory.
	- _fs_ stores messages on disk, in the same format as ZNC. _source_ is
	  required and is the root directory path for the database.

	(_log_ is a deprecated alias for this directive.)