summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-04-25 14:59:21 +0100
committerMark Haines <mark.haines@matrix.org>2016-04-25 14:59:21 +0100
commitf22f46f4f902e071fe322854a228f8fe53677cdc (patch)
treeca73108418f0394ac11cc2a5ecab0b54b8062215 /synapse
parentSplit out setting up the manhole to a separate file (diff)
downloadsynapse-f22f46f4f902e071fe322854a228f8fe53677cdc.tar.xz
Move the listenTCP call outside the manhole function
Diffstat (limited to 'synapse')
-rwxr-xr-xsynapse/app/homeserver.py16
-rw-r--r--synapse/util/manhole.py14
2 files changed, 14 insertions, 16 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index b033073ef7..df675c0ed4 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -57,7 +57,7 @@ from synapse.federation.transport.server import TransportLayerServer
 from synapse.util.rlimit import change_resource_limit
 from synapse.util.versionstring import get_version_string
 from synapse.util.httpresourcetree import create_resource_tree
-from synapse.util.manhole import listen_manhole
+from synapse.util.manhole import manhole
 
 from synapse.http.site import SynapseSite
 
@@ -203,12 +203,14 @@ class SynapseHomeServer(HomeServer):
             if listener["type"] == "http":
                 self._listener_http(config, listener)
             elif listener["type"] == "manhole":
-                listen_manhole(
-                    bind_address=listener.get("bind_address", '127.0.0.1'),
-                    bind_port=listener["port"],
-                    username="matrix",
-                    password="rabbithole",
-                    globals={"hs": self},
+                reactor.listenTCP(
+                    listener["port"],
+                    manhole(
+                        username="matrix",
+                        password="rabbithole",
+                        globals={"hs": self},
+                    ),
+                    interface=listener.get("bind_address", '127.0.0.1')
                 )
             else:
                 logger.warn("Unrecognized listener type: %s", listener["type"])
diff --git a/synapse/util/manhole.py b/synapse/util/manhole.py
index e12583209f..9b106cdf47 100644
--- a/synapse/util/manhole.py
+++ b/synapse/util/manhole.py
@@ -18,21 +18,19 @@ from twisted.conch import manhole_ssh
 from twisted.cred import checkers, portal
 
 
-from twisted.internet import reactor
-
-
-def listen_manhole(bind_address, bind_port, username, password, globals):
+def manhole(username, password, globals):
     """Starts a ssh listener with password authentication using
     the given username and password. Clients connecting to the ssh
     listener will find themselves in a colored python shell with
     the supplied globals.
 
     Args:
-        bind_address(str): IP address to listen on.
-        bind_port(int): TCP port to listen on.
         username(str): The username ssh clients should auth with.
         password(str): The password ssh clients should auth with.
         globals(dict): The variables to expose in the shell.
+
+    Returns:
+        twisted.internet.protocol.Factory: A factory to pass to ``listenTCP``
     """
 
     checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(
@@ -45,6 +43,4 @@ def listen_manhole(bind_address, bind_port, username, password, globals):
         dict(globals, __name__="__console__")
     )
 
-    factory = manhole_ssh.ConchFactory(portal.Portal(rlm, [checker]))
-
-    reactor.listenTCP(bind_port, factory, interface=bind_address)
+    return manhole_ssh.ConchFactory(portal.Portal(rlm, [checker]))