From 7ff7c7eaba41b27a8f7a7bda1b332b4770c57ff9 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 14 Nov 2022 16:26:18 +0000 Subject: [PATCH] Config validation --- setup/config/config_global.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup/config/config_global.go b/setup/config/config_global.go index 6548fc5c5..acf610218 100644 --- a/setup/config/config_global.go +++ b/setup/config/config_global.go @@ -115,6 +115,10 @@ func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) { checkNotEmpty(configErrs, "global.server_name", string(c.ServerName)) checkNotEmpty(configErrs, "global.private_key", string(c.PrivateKeyPath)) + for _, v := range c.VirtualHosts { + v.Verify(configErrs) + } + c.JetStream.Verify(configErrs, isMonolith) c.Metrics.Verify(configErrs, isMonolith) c.Sentry.Verify(configErrs, isMonolith) @@ -183,6 +187,10 @@ type VirtualHost struct { 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 { return &gomatrixserverlib.SigningIdentity{ ServerName: v.ServerName,