mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-04-15 16:23:39 +00:00
Validate configured server name
This commit is contained in:
parent
b0aa101dcd
commit
16aff3af62
1 changed files with 12 additions and 0 deletions
|
@ -1,11 +1,13 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"golang.org/x/crypto/ed25519"
|
"golang.org/x/crypto/ed25519"
|
||||||
|
"golang.org/x/net/idna"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Global struct {
|
type Global struct {
|
||||||
|
@ -73,6 +75,16 @@ 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))
|
||||||
|
|
||||||
|
validator := idna.New(
|
||||||
|
idna.StrictDomainName(true),
|
||||||
|
idna.ValidateForRegistration(),
|
||||||
|
idna.ValidateLabels(true),
|
||||||
|
idna.VerifyDNSLength(true),
|
||||||
|
)
|
||||||
|
if _, err := validator.ToUnicode(string(c.ServerName)); err != nil {
|
||||||
|
configErrs.Add(fmt.Sprintf("server_name %q is not a valid domain name", c.ServerName))
|
||||||
|
}
|
||||||
|
|
||||||
c.Kafka.Verify(configErrs, isMonolith)
|
c.Kafka.Verify(configErrs, isMonolith)
|
||||||
c.Metrics.Verify(configErrs, isMonolith)
|
c.Metrics.Verify(configErrs, isMonolith)
|
||||||
c.Sentry.Verify(configErrs, isMonolith)
|
c.Sentry.Verify(configErrs, isMonolith)
|
||||||
|
|
Loading…
Reference in a new issue