summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2018-07-05 10:04:20 +0100
committerGitHub <noreply@github.com>2018-07-05 10:04:20 +0100
commit1a886406770f4a51dd03c31c15fbd1e2d33ff202 (patch)
tree3a668e42377a871519e97fbeb8997758a5edbb91 /synapse/config
parentMerge pull request #3481 from matrix-org/rav/fix_cachedescriptor_test (diff)
parentMore server_name validation (diff)
downloadsynapse-1a886406770f4a51dd03c31c15fbd1e2d33ff202.tar.xz
Merge pull request #3483 from matrix-org/rav/more_server_name_validation
More server_name validation
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/server.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/synapse/config/server.py b/synapse/config/server.py
index 968ecd9ea0..71fd51e4bc 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -16,6 +16,7 @@
 
 import logging
 
+from synapse.http.endpoint import parse_and_validate_server_name
 from ._base import Config, ConfigError
 
 logger = logging.Logger(__name__)
@@ -25,6 +26,12 @@ class ServerConfig(Config):
 
     def read_config(self, config):
         self.server_name = config["server_name"]
+
+        try:
+            parse_and_validate_server_name(self.server_name)
+        except ValueError as e:
+            raise ConfigError(str(e))
+
         self.pid_file = self.abspath(config.get("pid_file"))
         self.web_client = config["web_client"]
         self.web_client_location = config.get("web_client_location", None)
@@ -162,8 +169,8 @@ class ServerConfig(Config):
             })
 
     def default_config(self, server_name, **kwargs):
-        if ":" in server_name:
-            bind_port = int(server_name.split(":")[1])
+        _, bind_port = parse_and_validate_server_name(server_name)
+        if bind_port is not None:
             unsecure_port = bind_port - 400
         else:
             bind_port = 8448