diff --git a/cmd/generate-config/main.go b/cmd/generate-config/main.go index c7f0f658b..3e3411c50 100644 --- a/cmd/generate-config/main.go +++ b/cmd/generate-config/main.go @@ -27,63 +27,63 @@ func main() { Generate: true, Monolithic: !*polylith, }) + if *serverName != "" { + cfg.Global.ServerName = gomatrixserverlib.ServerName(*serverName) + } + uri := config.DataSource(*dbURI) + if *polylith || uri.IsSQLite() || uri == "" { + for name, db := range map[string]*config.DatabaseOptions{ + "federationapi": &cfg.FederationAPI.Database, + "keyserver": &cfg.KeyServer.Database, + "mscs": &cfg.MSCs.Database, + "mediaapi": &cfg.MediaAPI.Database, + "roomserver": &cfg.RoomServer.Database, + "syncapi": &cfg.SyncAPI.Database, + "userapi": &cfg.UserAPI.AccountDatabase, + } { + if uri == "" { + db.ConnectionString = config.DataSource(fmt.Sprintf("file:dendrite_%s.db", name)) + } else { + db.ConnectionString = uri + } + } + } else { + cfg.Global.DatabaseOptions.ConnectionString = uri + } + cfg.Logging = []config.LogrusHook{ + { + Type: "file", + Level: "info", + Params: map[string]interface{}{ + "path": "/var/log/dendrite", + }, + }, + } + if *defaultsForCI { + cfg.AppServiceAPI.DisableTLSValidation = true + cfg.ClientAPI.RateLimiting.Enabled = false + cfg.FederationAPI.DisableTLSValidation = false + // don't hit matrix.org when running tests!!! + cfg.FederationAPI.KeyPerspectives = config.KeyPerspectives{} + cfg.MSCs.MSCs = []string{"msc2836", "msc2946", "msc2444", "msc2753"} + cfg.Logging[0].Level = "trace" + cfg.Logging[0].Type = "std" + cfg.UserAPI.BCryptCost = bcrypt.MinCost + cfg.Global.JetStream.InMemory = true + cfg.ClientAPI.RegistrationDisabled = false + cfg.ClientAPI.OpenRegistrationWithoutVerificationEnabled = true + cfg.ClientAPI.RegistrationSharedSecret = "complement" + cfg.Global.Presence = config.PresenceOptions{ + EnableInbound: true, + EnableOutbound: true, + } + } } else { var err error if cfg, err = config.Load(*normalise, !*polylith); err != nil { panic(err) } } - if *serverName != "" { - cfg.Global.ServerName = gomatrixserverlib.ServerName(*serverName) - } - uri := config.DataSource(*dbURI) - if *polylith || uri.IsSQLite() || uri == "" { - for name, db := range map[string]*config.DatabaseOptions{ - "federationapi": &cfg.FederationAPI.Database, - "keyserver": &cfg.KeyServer.Database, - "mscs": &cfg.MSCs.Database, - "mediaapi": &cfg.MediaAPI.Database, - "roomserver": &cfg.RoomServer.Database, - "syncapi": &cfg.SyncAPI.Database, - "userapi": &cfg.UserAPI.AccountDatabase, - } { - if uri == "" { - db.ConnectionString = config.DataSource(fmt.Sprintf("file:dendrite_%s.db", name)) - } else { - db.ConnectionString = uri - } - } - } else { - cfg.Global.DatabaseOptions.ConnectionString = uri - } - cfg.Logging = []config.LogrusHook{ - { - Type: "file", - Level: "info", - Params: map[string]interface{}{ - "path": "/var/log/dendrite", - }, - }, - } - if *defaultsForCI { - cfg.AppServiceAPI.DisableTLSValidation = true - cfg.ClientAPI.RateLimiting.Enabled = false - cfg.FederationAPI.DisableTLSValidation = false - // don't hit matrix.org when running tests!!! - cfg.FederationAPI.KeyPerspectives = config.KeyPerspectives{} - cfg.MSCs.MSCs = []string{"msc2836", "msc2946", "msc2444", "msc2753"} - cfg.Logging[0].Level = "trace" - cfg.Logging[0].Type = "std" - cfg.UserAPI.BCryptCost = bcrypt.MinCost - cfg.Global.JetStream.InMemory = true - cfg.ClientAPI.RegistrationDisabled = false - cfg.ClientAPI.OpenRegistrationWithoutVerificationEnabled = true - cfg.ClientAPI.RegistrationSharedSecret = "complement" - cfg.Global.Presence = config.PresenceOptions{ - EnableInbound: true, - EnableOutbound: true, - } - } j, err := yaml.Marshal(cfg) if err != nil {