aboutsummaryrefslogtreecommitdiff
path: root/setup
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-10-26 12:59:19 +0100
committerGitHub <noreply@github.com>2022-10-26 12:59:19 +0100
commitf6dea712d2e9c71f6ebe61f90e45a142852432e8 (patch)
tree981b818ec9ece4e67f1b27ed52f82510aecc465d /setup
parent2a4c7f45b37a9bcd1a37d42b0668e0c3dfb29762 (diff)
Initial support for multiple server names (#2829)
This PR is the first step towards virtual hosting by laying the groundwork for multiple server names being configured.
Diffstat (limited to 'setup')
-rw-r--r--setup/config/config_global.go15
-rw-r--r--setup/mscs/msc2836/msc2836.go2
-rw-r--r--setup/mscs/msc2946/msc2946.go2
3 files changed, 17 insertions, 2 deletions
diff --git a/setup/config/config_global.go b/setup/config/config_global.go
index 784893d2..82577282 100644
--- a/setup/config/config_global.go
+++ b/setup/config/config_global.go
@@ -14,6 +14,9 @@ type Global struct {
// The name of the server. This is usually the domain name, e.g 'matrix.org', 'localhost'.
ServerName gomatrixserverlib.ServerName `yaml:"server_name"`
+ // The secondary server names, used for virtual hosting.
+ SecondaryServerNames []gomatrixserverlib.ServerName `yaml:"-"`
+
// Path to the private key which will be used to sign requests and events.
PrivateKeyPath Path `yaml:"private_key"`
@@ -120,6 +123,18 @@ func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
c.Cache.Verify(configErrs, isMonolith)
}
+func (c *Global) IsLocalServerName(serverName gomatrixserverlib.ServerName) bool {
+ if c.ServerName == serverName {
+ return true
+ }
+ for _, secondaryName := range c.SecondaryServerNames {
+ if secondaryName == serverName {
+ return true
+ }
+ }
+ return false
+}
+
type OldVerifyKeys struct {
// Path to the private key.
PrivateKeyPath Path `yaml:"private_key"`
diff --git a/setup/mscs/msc2836/msc2836.go b/setup/mscs/msc2836/msc2836.go
index 452b1458..98502f5c 100644
--- a/setup/mscs/msc2836/msc2836.go
+++ b/setup/mscs/msc2836/msc2836.go
@@ -132,7 +132,7 @@ func Enable(
base.PublicFederationAPIMux.Handle("/unstable/event_relationships", httputil.MakeExternalAPI(
"msc2836_event_relationships", func(req *http.Request) util.JSONResponse {
fedReq, errResp := gomatrixserverlib.VerifyHTTPRequest(
- req, time.Now(), base.Cfg.Global.ServerName, keyRing,
+ req, time.Now(), base.Cfg.Global.ServerName, base.Cfg.Global.IsLocalServerName, keyRing,
)
if fedReq == nil {
return errResp
diff --git a/setup/mscs/msc2946/msc2946.go b/setup/mscs/msc2946/msc2946.go
index a92a16a2..bc9df0f9 100644
--- a/setup/mscs/msc2946/msc2946.go
+++ b/setup/mscs/msc2946/msc2946.go
@@ -64,7 +64,7 @@ func Enable(
fedAPI := httputil.MakeExternalAPI(
"msc2946_fed_spaces", func(req *http.Request) util.JSONResponse {
fedReq, errResp := gomatrixserverlib.VerifyHTTPRequest(
- req, time.Now(), base.Cfg.Global.ServerName, keyRing,
+ req, time.Now(), base.Cfg.Global.ServerName, base.Cfg.Global.IsLocalServerName, keyRing,
)
if fedReq == nil {
return errResp