1
0

Compare commits

...

1 Commits

Author SHA1 Message Date
Andrew Morgan ff195965ce Unsecure -> insecure 2020-04-13 14:02:34 +01:00
2 changed files with 20 additions and 20 deletions
+18 -18
View File
@@ -459,11 +459,11 @@ class ServerConfig(Config):
} }
) )
unsecure_port = config.get("unsecure_port", bind_port - 400) insecure_port = config.get("insecure_port", bind_port - 400)
if unsecure_port: if insecure_port:
self.listeners.append( self.listeners.append(
{ {
"port": unsecure_port, "port": insecure_port,
"bind_addresses": [bind_host], "bind_addresses": [bind_host],
"tls": False, "tls": False,
"type": "http", "type": "http",
@@ -515,10 +515,10 @@ class ServerConfig(Config):
): ):
_, bind_port = parse_and_validate_server_name(server_name) _, bind_port = parse_and_validate_server_name(server_name)
if bind_port is not None: if bind_port is not None:
unsecure_port = bind_port - 400 insecure_port = bind_port - 400
else: else:
bind_port = 8448 bind_port = 8448
unsecure_port = 8008 insecure_port = 8008
pid_file = os.path.join(data_dir_path, "homeserver.pid") pid_file = os.path.join(data_dir_path, "homeserver.pid")
@@ -526,7 +526,7 @@ class ServerConfig(Config):
# default config string # default config string
default_room_version = DEFAULT_ROOM_VERSION default_room_version = DEFAULT_ROOM_VERSION
secure_listeners = [] secure_listeners = []
unsecure_listeners = [] insecure_listeners = []
private_addresses = ["::1", "127.0.0.1"] private_addresses = ["::1", "127.0.0.1"]
if listeners: if listeners:
for listener in listeners: for listener in listeners:
@@ -541,19 +541,19 @@ class ServerConfig(Config):
if not open_private_ports: if not open_private_ports:
listener.setdefault("bind_addresses", private_addresses) listener.setdefault("bind_addresses", private_addresses)
unsecure_listeners.append(listener) insecure_listeners.append(listener)
secure_http_bindings = indent( secure_http_bindings = indent(
yaml.dump(secure_listeners), " " * 10 yaml.dump(secure_listeners), " " * 10
).lstrip() ).lstrip()
unsecure_http_bindings = indent( insecure_http_bindings = indent(
yaml.dump(unsecure_listeners), " " * 10 yaml.dump(insecure_listeners), " " * 10
).lstrip() ).lstrip()
if not unsecure_listeners: if not insecure_listeners:
unsecure_http_bindings = ( insecure_http_bindings = (
"""- port: %(unsecure_port)s """- port: %(insecure_port)s
tls: false tls: false
type: http type: http
x_forwarded: true""" x_forwarded: true"""
@@ -561,11 +561,11 @@ class ServerConfig(Config):
) )
if not open_private_ports: if not open_private_ports:
unsecure_http_bindings += ( insecure_http_bindings += (
"\n bind_addresses: ['::1', '127.0.0.1']" "\n bind_addresses: ['::1', '127.0.0.1']"
) )
unsecure_http_bindings += """ insecure_http_bindings += """
resources: resources:
- names: [client, federation] - names: [client, federation]
@@ -573,10 +573,10 @@ class ServerConfig(Config):
if listeners: if listeners:
# comment out this block # comment out this block
unsecure_http_bindings = "#" + re.sub( insecure_http_bindings = "#" + re.sub(
"\n {10}", "\n {10}",
lambda match: match.group(0) + "#", lambda match: match.group(0) + "#",
unsecure_http_bindings, insecure_http_bindings,
) )
if not secure_listeners: if not secure_listeners:
@@ -790,13 +790,13 @@ class ServerConfig(Config):
# #
%(secure_http_bindings)s %(secure_http_bindings)s
# Unsecure HTTP listener: for when matrix traffic passes through a reverse proxy # Insecure HTTP listener: for when matrix traffic passes through a reverse proxy
# that unwraps TLS. # that unwraps TLS.
# #
# If you plan to use a reverse proxy, please see # If you plan to use a reverse proxy, please see
# https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md. # https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md.
# #
%(unsecure_http_bindings)s %(insecure_http_bindings)s
# example additional_resources: # example additional_resources:
# #
+2 -2
View File
@@ -32,7 +32,7 @@ class ServerConfigTestCase(unittest.TestCase):
self.assertFalse(is_threepid_reserved(config, user3)) self.assertFalse(is_threepid_reserved(config, user3))
self.assertFalse(is_threepid_reserved(config, user1_msisdn)) self.assertFalse(is_threepid_reserved(config, user1_msisdn))
def test_unsecure_listener_no_listeners_open_private_ports_false(self): def test_insecure_listener_no_listeners_open_private_ports_false(self):
conf = yaml.safe_load( conf = yaml.safe_load(
ServerConfig().generate_config_section( ServerConfig().generate_config_section(
"che.org", "/data_dir_path", False, None "che.org", "/data_dir_path", False, None
@@ -52,7 +52,7 @@ class ServerConfigTestCase(unittest.TestCase):
self.assertEqual(conf["listeners"], expected_listeners) self.assertEqual(conf["listeners"], expected_listeners)
def test_unsecure_listener_no_listeners_open_private_ports_true(self): def test_insecure_listener_no_listeners_open_private_ports_true(self):
conf = yaml.safe_load( conf = yaml.safe_load(
ServerConfig().generate_config_section( ServerConfig().generate_config_section(
"che.org", "/data_dir_path", True, None "che.org", "/data_dir_path", True, None