From 7bfba6f771aa5f71890e509e70950833840d0793 Mon Sep 17 00:00:00 2001 From: contact Date: Wed, 21 Apr 2021 16:15:04 +0000 Subject: [PATCH] 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. git-svn-id: file:///srv/svn/repo/suika/trunk@507 f0ae65fe-ee39-954e-97ec-027ff2717ef4 --- config.in | 4 ++-- config/config.go | 8 ++++++-- doc/soju.1.scd | 8 +++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config.in b/config.in index c24c734..a0b510e 100644 --- a/config.in +++ b/config.in @@ -1,2 +1,2 @@ -sql sqlite3 /var/lib/soju/main.db -log /var/lib/soju/logs/ +db sqlite3 /var/lib/soju/main.db +log fs /var/lib/soju/logs/ diff --git a/config/config.go b/config/config.go index 59b23cf..a9118a8 100644 --- a/config/config.go +++ b/config/config.go @@ -86,14 +86,18 @@ func parse(cfg scfg.Block) (*Server, error) { return nil, err } srv.TLS = tls - case "sql": + case "db": if err := d.ParseParams(&srv.SQLDriver, &srv.SQLSource); err != nil { return nil, err } 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 } + if driver != "fs" { + return nil, fmt.Errorf("directive %q: unknown driver %q", d.Name, driver) + } case "http-origin": srv.HTTPOrigins = d.Params case "accept-proxy-ip": diff --git a/doc/soju.1.scd b/doc/soju.1.scd index 1c09429..7e3f2c4 100644 --- a/doc/soju.1.scd +++ b/doc/soju.1.scd @@ -101,12 +101,10 @@ The following directives are supported: *tls* Enable TLS support. The certificate and the key files must be PEM-encoded. -*sql* - Set the SQL driver settings. The only supported driver is "sqlite3". The - source is the path to the SQLite database file. By default, the path to the - database file is "soju.db". +*db* sqlite3 + Set the SQLite database path (default: "soju.db" in the current directory). -*log* +*log* fs Path to the bouncer logs root directory, or empty to disable logging. By default, logging is disabled.