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