mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Configuration tweaks
This commit is contained in:
parent
09f0ff14c8
commit
bd925a1cd8
|
|
@ -243,7 +243,7 @@ func (m *DendriteMonolith) Start() {
|
|||
|
||||
prefix := hex.EncodeToString(pk)
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk))
|
||||
cfg.Global.PrivateKey = sk
|
||||
cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ func (m *DendriteMonolith) Start() {
|
|||
m.YggdrasilNode = ygg
|
||||
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
cfg.Global.ServerName = gomatrixserverlib.ServerName(ygg.DerivedServerName())
|
||||
cfg.Global.PrivateKey = ygg.PrivateKey()
|
||||
cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID)
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ func TestValidationOfApplicationServices(t *testing.T) {
|
|||
|
||||
// Set up a config
|
||||
fakeConfig := &config.Dendrite{}
|
||||
fakeConfig.Defaults(true)
|
||||
fakeConfig.Defaults(true, true)
|
||||
fakeConfig.Global.ServerName = "localhost"
|
||||
fakeConfig.ClientAPI.Derived.ApplicationServices = []config.ApplicationService{fakeApplicationService}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ func main() {
|
|||
}()
|
||||
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk))
|
||||
cfg.Global.PrivateKey = sk
|
||||
cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID)
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ func main() {
|
|||
if configFlagSet {
|
||||
cfg = setup.ParseFlags(true)
|
||||
} else {
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
cfg.Global.JetStream.StoragePath = config.Path(fmt.Sprintf("%s/", *instanceName))
|
||||
cfg.UserAPI.AccountDatabase.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-account.db", *instanceName))
|
||||
cfg.MediaAPI.Database.ConnectionString = config.DataSource(fmt.Sprintf("file:%s-mediaapi.db", *instanceName))
|
||||
|
|
|
|||
|
|
@ -11,74 +11,42 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
defaultsForCI := flag.Bool("ci", false, "sane defaults for CI testing")
|
||||
defaultsForCI := flag.Bool("ci", false, "Populate the configuration with sane defaults for use in CI")
|
||||
serverName := flag.String("server", "", "The domain name of the server if not 'localhost'")
|
||||
dbURI := flag.String("db", "", "The DB URI to use for all components if not SQLite files")
|
||||
normalise := flag.String("normalise", "", "Normalise a given configuration file")
|
||||
polylith := flag.Bool("polylith", false, "Generate a config that makes sense for polylith deployments")
|
||||
flag.Parse()
|
||||
|
||||
cfg := &config.Dendrite{
|
||||
Version: config.Version,
|
||||
var cfg *config.Dendrite
|
||||
if *normalise == "" {
|
||||
cfg = &config.Dendrite{
|
||||
Version: config.Version,
|
||||
}
|
||||
cfg.Defaults(true, !*polylith)
|
||||
} else {
|
||||
var err error
|
||||
if cfg, err = config.Load(*normalise, !*polylith); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
cfg.Defaults(true)
|
||||
if *serverName != "" {
|
||||
cfg.Global.ServerName = gomatrixserverlib.ServerName(*serverName)
|
||||
}
|
||||
if *dbURI != "" {
|
||||
cfg.AppServiceAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.FederationAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.KeyServer.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.MSCs.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.MediaAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.RoomServer.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.SyncAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.UserAPI.AccountDatabase.ConnectionString = config.DataSource(*dbURI)
|
||||
if *polylith {
|
||||
cfg.AppServiceAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.FederationAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.KeyServer.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.MSCs.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.MediaAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.RoomServer.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.SyncAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
||||
cfg.UserAPI.AccountDatabase.ConnectionString = config.DataSource(*dbURI)
|
||||
} else {
|
||||
cfg.Global.DatabaseOptions.ConnectionString = config.DataSource(*dbURI)
|
||||
}
|
||||
}
|
||||
cfg.Global.TrustedIDServers = []string{
|
||||
"matrix.org",
|
||||
"vector.im",
|
||||
}
|
||||
cfg.Logging = []config.LogrusHook{
|
||||
{
|
||||
Type: "file",
|
||||
Level: "info",
|
||||
Params: map[string]interface{}{
|
||||
"path": "/var/log/dendrite",
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg.FederationAPI.KeyPerspectives = config.KeyPerspectives{
|
||||
{
|
||||
ServerName: "matrix.org",
|
||||
Keys: []config.KeyPerspectiveTrustKey{
|
||||
{
|
||||
KeyID: "ed25519:auto",
|
||||
PublicKey: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw",
|
||||
},
|
||||
{
|
||||
KeyID: "ed25519:a_RXGa",
|
||||
PublicKey: "l8Hft5qXKn1vfHrg3p4+W8gELQVo8N13JkluMfmn2sQ",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
cfg.MediaAPI.ThumbnailSizes = []config.ThumbnailSize{
|
||||
{
|
||||
Width: 32,
|
||||
Height: 32,
|
||||
ResizeMethod: "crop",
|
||||
},
|
||||
{
|
||||
Width: 96,
|
||||
Height: 96,
|
||||
ResizeMethod: "crop",
|
||||
},
|
||||
{
|
||||
Width: 640,
|
||||
Height: 480,
|
||||
ResizeMethod: "scale",
|
||||
},
|
||||
}
|
||||
|
||||
if *defaultsForCI {
|
||||
cfg.AppServiceAPI.DisableTLSValidation = true
|
||||
cfg.ClientAPI.RateLimiting.Enabled = false
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ func TestMain(m *testing.M) {
|
|||
// Draw up just enough Dendrite config for the server key
|
||||
// API to work.
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
cfg.Global.ServerName = gomatrixserverlib.ServerName(s.name)
|
||||
cfg.Global.PrivateKey = testPriv
|
||||
cfg.Global.JetStream.InMemory = true
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ func testFederationAPIJoinThenKeyUpdate(t *testing.T, dbType test.DBType) {
|
|||
func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
|
||||
_, privKey, _ := ed25519.GenerateKey(nil)
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
cfg.Global.KeyID = gomatrixserverlib.KeyID("ed25519:auto")
|
||||
cfg.Global.ServerName = gomatrixserverlib.ServerName("localhost")
|
||||
cfg.Global.PrivateKey = privKey
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ func loadConfig(
|
|||
monolithic bool,
|
||||
) (*Dendrite, error) {
|
||||
var c Dendrite
|
||||
c.Defaults(false)
|
||||
c.Defaults(false, monolithic)
|
||||
c.IsMonolith = monolithic
|
||||
|
||||
var err error
|
||||
|
|
@ -293,19 +293,31 @@ func (config *Dendrite) Derive() error {
|
|||
}
|
||||
|
||||
// SetDefaults sets default config values if they are not explicitly set.
|
||||
func (c *Dendrite) Defaults(generate bool) {
|
||||
func (c *Dendrite) Defaults(generate bool, isMonolith bool) {
|
||||
c.Version = Version
|
||||
|
||||
c.Global.Defaults(generate)
|
||||
c.ClientAPI.Defaults(generate)
|
||||
c.FederationAPI.Defaults(generate)
|
||||
c.KeyServer.Defaults(generate)
|
||||
c.MediaAPI.Defaults(generate)
|
||||
c.RoomServer.Defaults(generate)
|
||||
c.SyncAPI.Defaults(generate)
|
||||
c.UserAPI.Defaults(generate)
|
||||
c.AppServiceAPI.Defaults(generate)
|
||||
c.MSCs.Defaults(generate)
|
||||
if generate {
|
||||
c.Logging = []LogrusHook{
|
||||
{
|
||||
Type: "file",
|
||||
Level: "info",
|
||||
Params: map[string]interface{}{
|
||||
"path": "/var/log/dendrite",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
c.Global.Defaults(generate, isMonolith)
|
||||
c.ClientAPI.Defaults(generate, isMonolith)
|
||||
c.FederationAPI.Defaults(generate, isMonolith)
|
||||
c.KeyServer.Defaults(generate, isMonolith)
|
||||
c.MediaAPI.Defaults(generate, isMonolith)
|
||||
c.RoomServer.Defaults(generate, isMonolith)
|
||||
c.SyncAPI.Defaults(generate, isMonolith)
|
||||
c.UserAPI.Defaults(generate, isMonolith)
|
||||
c.AppServiceAPI.Defaults(generate, isMonolith)
|
||||
c.MSCs.Defaults(generate, isMonolith)
|
||||
|
||||
c.Wiring()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ type AppServiceAPI struct {
|
|||
Matrix *Global `yaml:"-"`
|
||||
Derived *Derived `yaml:"-"` // TODO: Nuke Derived from orbit
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
|
||||
Database DatabaseOptions `yaml:"database"`
|
||||
Database DatabaseOptions `yaml:"database,omitempty"`
|
||||
|
||||
// DisableTLSValidation disables the validation of X.509 TLS certs
|
||||
// on appservice endpoints. This is not recommended in production!
|
||||
|
|
@ -40,12 +40,16 @@ type AppServiceAPI struct {
|
|||
ConfigFiles []string `yaml:"config_files"`
|
||||
}
|
||||
|
||||
func (c *AppServiceAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7777"
|
||||
c.InternalAPI.Connect = "http://localhost:7777"
|
||||
c.Database.Defaults(5)
|
||||
func (c *AppServiceAPI) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7777"
|
||||
c.InternalAPI.Connect = "http://localhost:7777"
|
||||
c.Database.Defaults(5)
|
||||
}
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:appservice.db"
|
||||
if !isMonolith {
|
||||
c.Database.ConnectionString = "file:appservice.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ type ClientAPI struct {
|
|||
Matrix *Global `yaml:"-"`
|
||||
Derived *Derived `yaml:"-"` // TODO: Nuke Derived from orbit
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api,omitempty"`
|
||||
|
||||
// If set disables new users from registering (except via shared
|
||||
// secrets)
|
||||
|
|
@ -48,13 +48,15 @@ type ClientAPI struct {
|
|||
// Rate-limiting options
|
||||
RateLimiting RateLimiting `yaml:"rate_limiting"`
|
||||
|
||||
MSCs *MSCs `yaml:"mscs"`
|
||||
MSCs *MSCs `yaml:"-"`
|
||||
}
|
||||
|
||||
func (c *ClientAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7771"
|
||||
c.InternalAPI.Connect = "http://localhost:7771"
|
||||
c.ExternalAPI.Listen = "http://[::]:8071"
|
||||
func (c *ClientAPI) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7771"
|
||||
c.InternalAPI.Connect = "http://localhost:7771"
|
||||
c.ExternalAPI.Listen = "http://[::]:8071"
|
||||
}
|
||||
c.RegistrationSharedSecret = ""
|
||||
c.RecaptchaPublicKey = ""
|
||||
c.RecaptchaPrivateKey = ""
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import "github.com/matrix-org/gomatrixserverlib"
|
|||
type FederationAPI struct {
|
||||
Matrix *Global `yaml:"-"`
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api,omitempty"`
|
||||
|
||||
// The database stores information used by the federation destination queues to
|
||||
// send transactions to remote servers.
|
||||
Database DatabaseOptions `yaml:"database"`
|
||||
Database DatabaseOptions `yaml:"database,omitempty"`
|
||||
|
||||
// Federation failure threshold. How many consecutive failures that we should
|
||||
// tolerate when sending federation requests to a specific server. The backoff
|
||||
|
|
@ -30,15 +30,34 @@ type FederationAPI struct {
|
|||
PreferDirectFetch bool `yaml:"prefer_direct_fetch"`
|
||||
}
|
||||
|
||||
func (c *FederationAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7772"
|
||||
c.InternalAPI.Connect = "http://localhost:7772"
|
||||
c.ExternalAPI.Listen = "http://[::]:8072"
|
||||
func (c *FederationAPI) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7772"
|
||||
c.InternalAPI.Connect = "http://localhost:7772"
|
||||
c.ExternalAPI.Listen = "http://[::]:8072"
|
||||
c.Database.Defaults(10)
|
||||
}
|
||||
c.FederationMaxRetries = 16
|
||||
c.DisableTLSValidation = false
|
||||
c.Database.Defaults(10)
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:federationapi.db"
|
||||
c.KeyPerspectives = KeyPerspectives{
|
||||
{
|
||||
ServerName: "matrix.org",
|
||||
Keys: []KeyPerspectiveTrustKey{
|
||||
{
|
||||
KeyID: "ed25519:auto",
|
||||
PublicKey: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw",
|
||||
},
|
||||
{
|
||||
KeyID: "ed25519:a_RXGa",
|
||||
PublicKey: "l8Hft5qXKn1vfHrg3p4+W8gELQVo8N13JkluMfmn2sQ",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if !isMonolith {
|
||||
c.Database.ConnectionString = "file:federationapi.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ type Global struct {
|
|||
// connections will be used instead. This way we don't have to manage connection
|
||||
// counts on a per-component basis, but can instead do it for the entire monolith.
|
||||
// In a polylith deployment, this will be ignored.
|
||||
DatabaseOptions DatabaseOptions `yaml:"database"`
|
||||
DatabaseOptions DatabaseOptions `yaml:"database,omitempty"`
|
||||
|
||||
// The server name to delegate server-server communications to, with optional port
|
||||
WellKnownServerName string `yaml:"well_known_server_name"`
|
||||
|
|
@ -80,15 +80,21 @@ type Global struct {
|
|||
Cache Cache `yaml:"cache"`
|
||||
}
|
||||
|
||||
func (c *Global) Defaults(generate bool) {
|
||||
func (c *Global) Defaults(generate bool, isMonolith bool) {
|
||||
if generate {
|
||||
c.ServerName = "localhost"
|
||||
c.PrivateKeyPath = "matrix_key.pem"
|
||||
_, c.PrivateKey, _ = ed25519.GenerateKey(rand.New(rand.NewSource(0)))
|
||||
c.KeyID = "ed25519:auto"
|
||||
c.TrustedIDServers = []string{
|
||||
"matrix.org",
|
||||
"vector.im",
|
||||
}
|
||||
}
|
||||
c.KeyValidityPeriod = time.Hour * 24 * 7
|
||||
|
||||
if isMonolith {
|
||||
c.DatabaseOptions.Defaults(90)
|
||||
}
|
||||
c.JetStream.Defaults(generate)
|
||||
c.Metrics.Defaults(generate)
|
||||
c.DNSCache.Defaults()
|
||||
|
|
|
|||
|
|
@ -3,17 +3,21 @@ package config
|
|||
type KeyServer struct {
|
||||
Matrix *Global `yaml:"-"`
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
|
||||
Database DatabaseOptions `yaml:"database"`
|
||||
Database DatabaseOptions `yaml:"database,omitempty"`
|
||||
}
|
||||
|
||||
func (c *KeyServer) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7779"
|
||||
c.InternalAPI.Connect = "http://localhost:7779"
|
||||
c.Database.Defaults(10)
|
||||
func (c *KeyServer) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7779"
|
||||
c.InternalAPI.Connect = "http://localhost:7779"
|
||||
c.Database.Defaults(10)
|
||||
}
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:keyserver.db"
|
||||
if !isMonolith {
|
||||
c.Database.ConnectionString = "file:keyserver.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import (
|
|||
type MediaAPI struct {
|
||||
Matrix *Global `yaml:"-"`
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api,omitempty"`
|
||||
|
||||
// The MediaAPI database stores information about files uploaded and downloaded
|
||||
// by local users. It is only accessed by the MediaAPI.
|
||||
Database DatabaseOptions `yaml:"database"`
|
||||
Database DatabaseOptions `yaml:"database,omitempty"`
|
||||
|
||||
// The base path to where the media files will be stored. May be relative or absolute.
|
||||
BasePath Path `yaml:"base_path"`
|
||||
|
|
@ -38,15 +38,36 @@ type MediaAPI struct {
|
|||
// DefaultMaxFileSizeBytes defines the default file size allowed in transfers
|
||||
var DefaultMaxFileSizeBytes = FileSizeBytes(10485760)
|
||||
|
||||
func (c *MediaAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7774"
|
||||
c.InternalAPI.Connect = "http://localhost:7774"
|
||||
c.ExternalAPI.Listen = "http://[::]:8074"
|
||||
func (c *MediaAPI) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7774"
|
||||
c.InternalAPI.Connect = "http://localhost:7774"
|
||||
c.ExternalAPI.Listen = "http://[::]:8074"
|
||||
c.Database.Defaults(5)
|
||||
}
|
||||
c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
|
||||
c.MaxThumbnailGenerators = 10
|
||||
c.Database.Defaults(5)
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:mediaapi.db"
|
||||
c.ThumbnailSizes = []ThumbnailSize{
|
||||
{
|
||||
Width: 32,
|
||||
Height: 32,
|
||||
ResizeMethod: "crop",
|
||||
},
|
||||
{
|
||||
Width: 96,
|
||||
Height: 96,
|
||||
ResizeMethod: "crop",
|
||||
},
|
||||
{
|
||||
Width: 640,
|
||||
Height: 480,
|
||||
ResizeMethod: "scale",
|
||||
},
|
||||
}
|
||||
if !isMonolith {
|
||||
c.Database.ConnectionString = "file:mediaapi.db"
|
||||
}
|
||||
c.BasePath = "./media_store"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,17 @@ type MSCs struct {
|
|||
// 'msc2946': Spaces Summary - https://github.com/matrix-org/matrix-doc/pull/2946
|
||||
MSCs []string `yaml:"mscs"`
|
||||
|
||||
Database DatabaseOptions `yaml:"database"`
|
||||
Database DatabaseOptions `yaml:"database,omitempty"`
|
||||
}
|
||||
|
||||
func (c *MSCs) Defaults(generate bool) {
|
||||
c.Database.Defaults(5)
|
||||
func (c *MSCs) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.Database.Defaults(5)
|
||||
}
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:mscs.db"
|
||||
if !isMonolith {
|
||||
c.Database.ConnectionString = "file:mscs.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,17 +3,21 @@ package config
|
|||
type RoomServer struct {
|
||||
Matrix *Global `yaml:"-"`
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
|
||||
Database DatabaseOptions `yaml:"database"`
|
||||
Database DatabaseOptions `yaml:"database,omitempty"`
|
||||
}
|
||||
|
||||
func (c *RoomServer) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7770"
|
||||
c.InternalAPI.Connect = "http://localhost:7770"
|
||||
c.Database.Defaults(10)
|
||||
func (c *RoomServer) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7770"
|
||||
c.InternalAPI.Connect = "http://localhost:7770"
|
||||
c.Database.Defaults(10)
|
||||
}
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:roomserver.db"
|
||||
if !isMonolith {
|
||||
c.Database.ConnectionString = "file:roomserver.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,21 +3,25 @@ package config
|
|||
type SyncAPI struct {
|
||||
Matrix *Global `yaml:"-"`
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
ExternalAPI ExternalAPIOptions `yaml:"external_api,omitempty"`
|
||||
|
||||
Database DatabaseOptions `yaml:"database"`
|
||||
Database DatabaseOptions `yaml:"database,omitempty"`
|
||||
|
||||
RealIPHeader string `yaml:"real_ip_header"`
|
||||
}
|
||||
|
||||
func (c *SyncAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7773"
|
||||
c.InternalAPI.Connect = "http://localhost:7773"
|
||||
c.ExternalAPI.Listen = "http://localhost:8073"
|
||||
c.Database.Defaults(10)
|
||||
func (c *SyncAPI) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7773"
|
||||
c.InternalAPI.Connect = "http://localhost:7773"
|
||||
c.ExternalAPI.Listen = "http://localhost:8073"
|
||||
c.Database.Defaults(10)
|
||||
}
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:syncapi.db"
|
||||
if !isMonolith {
|
||||
c.Database.ConnectionString = "file:syncapi.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import "golang.org/x/crypto/bcrypt"
|
|||
type UserAPI struct {
|
||||
Matrix *Global `yaml:"-"`
|
||||
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
||||
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
||||
|
||||
// The cost when hashing passwords.
|
||||
BCryptCost int `yaml:"bcrypt_cost"`
|
||||
|
|
@ -18,19 +18,23 @@ type UserAPI struct {
|
|||
|
||||
// The Account database stores the login details and account information
|
||||
// for local users. It is accessed by the UserAPI.
|
||||
AccountDatabase DatabaseOptions `yaml:"account_database"`
|
||||
AccountDatabase DatabaseOptions `yaml:"account_database,omitempty"`
|
||||
}
|
||||
|
||||
const DefaultOpenIDTokenLifetimeMS = 3600000 // 60 minutes
|
||||
|
||||
func (c *UserAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7781"
|
||||
c.InternalAPI.Connect = "http://localhost:7781"
|
||||
func (c *UserAPI) Defaults(generate bool, isMonolith bool) {
|
||||
if !isMonolith {
|
||||
c.InternalAPI.Listen = "http://localhost:7781"
|
||||
c.InternalAPI.Connect = "http://localhost:7781"
|
||||
c.AccountDatabase.Defaults(10)
|
||||
}
|
||||
c.BCryptCost = bcrypt.DefaultCost
|
||||
c.OpenIDTokenLifetimeMS = DefaultOpenIDTokenLifetimeMS
|
||||
c.AccountDatabase.Defaults(10)
|
||||
if generate {
|
||||
c.AccountDatabase.ConnectionString = "file:userapi_accounts.db"
|
||||
if !isMonolith {
|
||||
c.AccountDatabase.ConnectionString = "file:userapi_accounts.db"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ func (r *testRoomserverAPI) QueryMembershipForUser(ctx context.Context, req *roo
|
|||
func injectEvents(t *testing.T, userAPI userapi.UserInternalAPI, rsAPI roomserver.RoomserverInternalAPI, events []*gomatrixserverlib.HeaderedEvent) *mux.Router {
|
||||
t.Helper()
|
||||
cfg := &config.Dendrite{}
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
cfg.Global.ServerName = "localhost"
|
||||
cfg.MSCs.Database.ConnectionString = "file:msc2836_test.db"
|
||||
cfg.MSCs.MSCs = []string{"msc2836"}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ import (
|
|||
|
||||
func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, func()) {
|
||||
var cfg config.Dendrite
|
||||
cfg.Defaults(false)
|
||||
cfg.Defaults(false, true)
|
||||
cfg.Global.JetStream.InMemory = true
|
||||
|
||||
switch dbType {
|
||||
case test.DBTypePostgres:
|
||||
cfg.Global.Defaults(true) // autogen a signing key
|
||||
cfg.MediaAPI.Defaults(true) // autogen a media path
|
||||
cfg.Global.Defaults(true, true) // autogen a signing key
|
||||
cfg.MediaAPI.Defaults(true, true) // autogen a media path
|
||||
// use a distinct prefix else concurrent postgres/sqlite runs will clash since NATS will use
|
||||
// the file system event with InMemory=true :(
|
||||
cfg.Global.JetStream.TopicPrefix = fmt.Sprintf("Test_%d_", dbType)
|
||||
|
|
@ -49,7 +49,7 @@ func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, f
|
|||
}
|
||||
return base.NewBaseDendrite(&cfg, "Test", base.DisableMetrics), close
|
||||
case test.DBTypeSQLite:
|
||||
cfg.Defaults(true) // sets a sqlite db per component
|
||||
cfg.Defaults(true, true) // sets a sqlite db per component
|
||||
// use a distinct prefix else concurrent postgres/sqlite runs will clash since NATS will use
|
||||
// the file system event with InMemory=true :(
|
||||
cfg.Global.JetStream.TopicPrefix = fmt.Sprintf("Test_%d_", dbType)
|
||||
|
|
@ -82,7 +82,7 @@ func CreateBaseDendrite(t *testing.T, dbType test.DBType) (*base.BaseDendrite, f
|
|||
func Base(cfg *config.Dendrite) (*base.BaseDendrite, nats.JetStreamContext, *nats.Conn) {
|
||||
if cfg == nil {
|
||||
cfg = &config.Dendrite{}
|
||||
cfg.Defaults(true)
|
||||
cfg.Defaults(true, true)
|
||||
}
|
||||
cfg.Global.JetStream.InMemory = true
|
||||
base := base.NewBaseDendrite(cfg, "Tests")
|
||||
|
|
|
|||
Loading…
Reference in a new issue