Config validation

This commit is contained in:
Neil Alexander 2022-11-14 16:26:18 +00:00
parent ed915eed19
commit 7ff7c7eaba
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -115,6 +115,10 @@ func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
checkNotEmpty(configErrs, "global.server_name", string(c.ServerName)) checkNotEmpty(configErrs, "global.server_name", string(c.ServerName))
checkNotEmpty(configErrs, "global.private_key", string(c.PrivateKeyPath)) checkNotEmpty(configErrs, "global.private_key", string(c.PrivateKeyPath))
for _, v := range c.VirtualHosts {
v.Verify(configErrs)
}
c.JetStream.Verify(configErrs, isMonolith) c.JetStream.Verify(configErrs, isMonolith)
c.Metrics.Verify(configErrs, isMonolith) c.Metrics.Verify(configErrs, isMonolith)
c.Sentry.Verify(configErrs, isMonolith) c.Sentry.Verify(configErrs, isMonolith)
@ -183,6 +187,10 @@ type VirtualHost struct {
KeyValidityPeriod time.Duration `yaml:"key_validity_period"` KeyValidityPeriod time.Duration `yaml:"key_validity_period"`
} }
func (v *VirtualHost) Verify(configErrs *ConfigErrors) {
checkNotEmpty(configErrs, "virtual_host.*.server_name", string(v.ServerName))
}
func (v *VirtualHost) SigningIdentity() *gomatrixserverlib.SigningIdentity { func (v *VirtualHost) SigningIdentity() *gomatrixserverlib.SigningIdentity {
return &gomatrixserverlib.SigningIdentity{ return &gomatrixserverlib.SigningIdentity{
ServerName: v.ServerName, ServerName: v.ServerName,