config: add message-store memory

The old way to do this was `message-store fs ""`, which is
misleading.
This commit is contained in:
Simon Ser 2022-05-09 16:59:27 +02:00
parent 80ed0d2a6c
commit e2e232fa9c
3 changed files with 24 additions and 9 deletions

View File

@ -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,

View File

@ -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

View File

@ -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.)