Make db and log config options more future-proof

Rename the "sql" directive to "db". Rename the "log" directive to
"log fs".

In the future, we'll maybe support more databases and more message
stores. Make it so it's easy to integrate these new festures to the
config file format.
This commit is contained in:
Simon Ser 2021-04-21 18:15:04 +02:00
parent fd365f9480
commit 706b6e33fb
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 11 additions and 9 deletions

View file

@ -1,2 +1,2 @@
sql sqlite3 /var/lib/soju/main.db db sqlite3 /var/lib/soju/main.db
log /var/lib/soju/logs/ log fs /var/lib/soju/logs/

View file

@ -86,14 +86,18 @@ func parse(cfg scfg.Block) (*Server, error) {
return nil, err return nil, err
} }
srv.TLS = tls srv.TLS = tls
case "sql": case "db":
if err := d.ParseParams(&srv.SQLDriver, &srv.SQLSource); err != nil { if err := d.ParseParams(&srv.SQLDriver, &srv.SQLSource); err != nil {
return nil, err return nil, err
} }
case "log": case "log":
if err := d.ParseParams(&srv.LogPath); err != nil { var driver string
if err := d.ParseParams(&driver, &srv.LogPath); err != nil {
return nil, err return nil, err
} }
if driver != "fs" {
return nil, fmt.Errorf("directive %q: unknown driver %q", d.Name, driver)
}
case "http-origin": case "http-origin":
srv.HTTPOrigins = d.Params srv.HTTPOrigins = d.Params
case "accept-proxy-ip": case "accept-proxy-ip":

View file

@ -101,12 +101,10 @@ The following directives are supported:
*tls* <cert> <key> *tls* <cert> <key>
Enable TLS support. The certificate and the key files must be PEM-encoded. Enable TLS support. The certificate and the key files must be PEM-encoded.
*sql* <driver> <source> *db* sqlite3 <path>
Set the SQL driver settings. The only supported driver is "sqlite3". The Set the SQLite database path (default: "soju.db" in the current directory).
source is the path to the SQLite database file. By default, the path to the
database file is "soju.db".
*log* <path> *log* fs <path>
Path to the bouncer logs root directory, or empty to disable logging. By Path to the bouncer logs root directory, or empty to disable logging. By
default, logging is disabled. default, logging is disabled.