mirror of
https://github.com/1f349/dendrite.git
synced 2024-12-22 16:24:10 +00:00
Shuffle config Verify/Defaults a bit around (#2459)
This commit is contained in:
parent
fc670f03a2
commit
870f9b0c3f
@ -50,11 +50,14 @@ func (c *AppServiceAPI) Defaults(generate bool) {
|
||||
}
|
||||
|
||||
func (c *AppServiceAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "app_service_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "app_service_api.internal_api.bind", string(c.InternalAPI.Connect))
|
||||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "app_service_api.database.connection_string", string(c.Database.ConnectionString))
|
||||
}
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "app_service_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "app_service_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
}
|
||||
|
||||
// ApplicationServiceNamespace is the namespace that a specific application
|
||||
|
@ -67,19 +67,13 @@ func (c *ClientAPI) Defaults(generate bool) {
|
||||
}
|
||||
|
||||
func (c *ClientAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "client_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "client_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
if !isMonolith {
|
||||
checkURL(configErrs, "client_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
}
|
||||
if c.RecaptchaEnabled {
|
||||
checkNotEmpty(configErrs, "client_api.recaptcha_public_key", string(c.RecaptchaPublicKey))
|
||||
checkNotEmpty(configErrs, "client_api.recaptcha_private_key", string(c.RecaptchaPrivateKey))
|
||||
checkNotEmpty(configErrs, "client_api.recaptcha_siteverify_api", string(c.RecaptchaSiteVerifyAPI))
|
||||
}
|
||||
c.TURN.Verify(configErrs)
|
||||
c.RateLimiting.Verify(configErrs)
|
||||
|
||||
if c.RecaptchaEnabled {
|
||||
checkNotEmpty(configErrs, "client_api.recaptcha_public_key", c.RecaptchaPublicKey)
|
||||
checkNotEmpty(configErrs, "client_api.recaptcha_private_key", c.RecaptchaPrivateKey)
|
||||
checkNotEmpty(configErrs, "client_api.recaptcha_siteverify_api", c.RecaptchaSiteVerifyAPI)
|
||||
}
|
||||
// Ensure there is any spam counter measure when enabling registration
|
||||
if !c.RegistrationDisabled && !c.OpenRegistrationWithoutVerificationEnabled {
|
||||
if !c.RecaptchaEnabled {
|
||||
@ -93,6 +87,12 @@ func (c *ClientAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
)
|
||||
}
|
||||
}
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "client_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "client_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
checkURL(configErrs, "client_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
}
|
||||
|
||||
type TURN struct {
|
||||
|
@ -34,24 +34,24 @@ func (c *FederationAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7772"
|
||||
c.InternalAPI.Connect = "http://localhost:7772"
|
||||
c.ExternalAPI.Listen = "http://[::]:8072"
|
||||
c.FederationMaxRetries = 16
|
||||
c.DisableTLSValidation = false
|
||||
c.Database.Defaults(10)
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:federationapi.db"
|
||||
}
|
||||
|
||||
c.FederationMaxRetries = 16
|
||||
c.DisableTLSValidation = false
|
||||
}
|
||||
|
||||
func (c *FederationAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "federation_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "federation_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
if !isMonolith {
|
||||
checkURL(configErrs, "federation_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
}
|
||||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "federation_api.database.connection_string", string(c.Database.ConnectionString))
|
||||
}
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "federation_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
checkURL(configErrs, "federation_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "federation_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
}
|
||||
|
||||
// The config for setting a proxy to use for server->server requests
|
||||
|
@ -36,9 +36,10 @@ func (c *JetStream) Defaults(generate bool) {
|
||||
}
|
||||
|
||||
func (c *JetStream) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
// If we are running in a polylith deployment then we need at least
|
||||
// one NATS JetStream server to talk to.
|
||||
if !isMonolith {
|
||||
checkNotZero(configErrs, "global.jetstream.addresses", int64(len(c.Addresses)))
|
||||
}
|
||||
checkNotZero(configErrs, "global.jetstream.addresses", int64(len(c.Addresses)))
|
||||
}
|
||||
|
@ -18,9 +18,12 @@ func (c *KeyServer) Defaults(generate bool) {
|
||||
}
|
||||
|
||||
func (c *KeyServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "key_server.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "key_server.internal_api.bind", string(c.InternalAPI.Connect))
|
||||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "key_server.database.connection_string", string(c.Database.ConnectionString))
|
||||
}
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "key_server.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "key_server.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
}
|
||||
|
@ -42,26 +42,19 @@ func (c *MediaAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7774"
|
||||
c.InternalAPI.Connect = "http://localhost:7774"
|
||||
c.ExternalAPI.Listen = "http://[::]:8074"
|
||||
c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
|
||||
c.MaxThumbnailGenerators = 10
|
||||
c.Database.Defaults(5)
|
||||
if generate {
|
||||
c.Database.ConnectionString = "file:mediaapi.db"
|
||||
c.BasePath = "./media_store"
|
||||
}
|
||||
|
||||
c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
|
||||
c.MaxThumbnailGenerators = 10
|
||||
}
|
||||
|
||||
func (c *MediaAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "media_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "media_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
if !isMonolith {
|
||||
checkURL(configErrs, "media_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
}
|
||||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "media_api.database.connection_string", string(c.Database.ConnectionString))
|
||||
}
|
||||
|
||||
checkNotEmpty(configErrs, "media_api.base_path", string(c.BasePath))
|
||||
checkPositive(configErrs, "media_api.max_file_size_bytes", int64(c.MaxFileSizeBytes))
|
||||
checkPositive(configErrs, "media_api.max_thumbnail_generators", int64(c.MaxThumbnailGenerators))
|
||||
@ -70,4 +63,10 @@ func (c *MediaAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkPositive(configErrs, fmt.Sprintf("media_api.thumbnail_sizes[%d].width", i), int64(size.Width))
|
||||
checkPositive(configErrs, fmt.Sprintf("media_api.thumbnail_sizes[%d].height", i), int64(size.Height))
|
||||
}
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "media_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "media_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
checkURL(configErrs, "media_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
}
|
||||
|
@ -18,9 +18,12 @@ func (c *RoomServer) Defaults(generate bool) {
|
||||
}
|
||||
|
||||
func (c *RoomServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "room_server.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "room_server.internal_ap.bind", string(c.InternalAPI.Connect))
|
||||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "room_server.database.connection_string", string(c.Database.ConnectionString))
|
||||
}
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "room_server.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "room_server.internal_ap.connect", string(c.InternalAPI.Connect))
|
||||
}
|
||||
|
@ -22,12 +22,13 @@ func (c *SyncAPI) Defaults(generate bool) {
|
||||
}
|
||||
|
||||
func (c *SyncAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "sync_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "sync_api.internal_api.bind", string(c.InternalAPI.Connect))
|
||||
if !isMonolith {
|
||||
checkURL(configErrs, "sync_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
}
|
||||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "sync_api.database", string(c.Database.ConnectionString))
|
||||
}
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "sync_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "sync_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
checkURL(configErrs, "sync_api.external_api.listen", string(c.ExternalAPI.Listen))
|
||||
}
|
||||
|
@ -26,19 +26,22 @@ const DefaultOpenIDTokenLifetimeMS = 3600000 // 60 minutes
|
||||
func (c *UserAPI) Defaults(generate bool) {
|
||||
c.InternalAPI.Listen = "http://localhost:7781"
|
||||
c.InternalAPI.Connect = "http://localhost:7781"
|
||||
c.BCryptCost = bcrypt.DefaultCost
|
||||
c.OpenIDTokenLifetimeMS = DefaultOpenIDTokenLifetimeMS
|
||||
c.AccountDatabase.Defaults(10)
|
||||
if generate {
|
||||
c.AccountDatabase.ConnectionString = "file:userapi_accounts.db"
|
||||
}
|
||||
c.BCryptCost = bcrypt.DefaultCost
|
||||
c.OpenIDTokenLifetimeMS = DefaultOpenIDTokenLifetimeMS
|
||||
}
|
||||
|
||||
func (c *UserAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
checkURL(configErrs, "user_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "user_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
checkPositive(configErrs, "user_api.openid_token_lifetime_ms", c.OpenIDTokenLifetimeMS)
|
||||
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
||||
checkNotEmpty(configErrs, "user_api.account_database.connection_string", string(c.AccountDatabase.ConnectionString))
|
||||
}
|
||||
checkPositive(configErrs, "user_api.openid_token_lifetime_ms", c.OpenIDTokenLifetimeMS)
|
||||
if isMonolith { // polylith required configs below
|
||||
return
|
||||
}
|
||||
checkURL(configErrs, "user_api.internal_api.listen", string(c.InternalAPI.Listen))
|
||||
checkURL(configErrs, "user_api.internal_api.connect", string(c.InternalAPI.Connect))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user