summary refs log tree commit diff
path: root/synapse/app/client_reader.py
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@arasphere.net>2016-12-19 23:49:34 +0000
committerGitHub <noreply@github.com>2016-12-19 23:49:34 +0000
commitda2c8f3c94139d3d8d1b9b39622146e195b7c74e (patch)
treecf3ab98691d2acd2508b5aecf403a05542b1cf40 /synapse/app/client_reader.py
parentMerge pull request #1696 from kyrias/ipv6 (diff)
parentAdd IPv6 comment to default config (diff)
downloadsynapse-da2c8f3c94139d3d8d1b9b39622146e195b7c74e.tar.xz
Merge pull request #1709 from kyrias/bind_addresses
Add support for specifying multiple bind addresses
Diffstat (limited to 'synapse/app/client_reader.py')
-rw-r--r--synapse/app/client_reader.py54
1 files changed, 34 insertions, 20 deletions
diff --git a/synapse/app/client_reader.py b/synapse/app/client_reader.py
index 0086a2977e..305a82b664 100644
--- a/synapse/app/client_reader.py
+++ b/synapse/app/client_reader.py
@@ -90,7 +90,8 @@ class ClientReaderServer(HomeServer):
 
     def _listen_http(self, listener_config):
         port = listener_config["port"]
-        bind_address = listener_config.get("bind_address", "")
+        bind_address = listener_config.get("bind_address", None)
+        bind_addresses = listener_config.get("bind_addresses", [])
         site_tag = listener_config.get("tag", port)
         resources = {}
         for res in listener_config["resources"]:
@@ -108,16 +109,22 @@ class ClientReaderServer(HomeServer):
                     })
 
         root_resource = create_resource_tree(resources, Resource())
-        reactor.listenTCP(
-            port,
-            SynapseSite(
-                "synapse.access.http.%s" % (site_tag,),
-                site_tag,
-                listener_config,
-                root_resource,
-            ),
-            interface=bind_address
-        )
+
+        if bind_address:
+            bind_addresses.append(bind_address)
+
+        for address in bind_addresses:
+            reactor.listenTCP(
+                port,
+                SynapseSite(
+                    "synapse.access.http.%s" % (site_tag,),
+                    site_tag,
+                    listener_config,
+                    root_resource,
+                ),
+                interface=address
+            )
+
         logger.info("Synapse client reader now listening on port %d", port)
 
     def start_listening(self, listeners):
@@ -125,15 +132,22 @@ class ClientReaderServer(HomeServer):
             if listener["type"] == "http":
                 self._listen_http(listener)
             elif listener["type"] == "manhole":
-                reactor.listenTCP(
-                    listener["port"],
-                    manhole(
-                        username="matrix",
-                        password="rabbithole",
-                        globals={"hs": self},
-                    ),
-                    interface=listener.get("bind_address", '127.0.0.1')
-                )
+                bind_address = listener.get("bind_address", None)
+                bind_addresses = listener.get("bind_addresses", [])
+
+                if bind_address:
+                    bind_addresses.append(bind_address)
+
+                for address in bind_addresses:
+                    reactor.listenTCP(
+                        listener["port"],
+                        manhole(
+                            username="matrix",
+                            password="rabbithole",
+                            globals={"hs": self},
+                        ),
+                        interface=address
+                    )
             else:
                 logger.warn("Unrecognized listener type: %s", listener["type"])