Move the listenTCP call outside the manhole function

This commit is contained in:
Mark Haines 2016-04-25 14:59:21 +01:00
parent 5905f36f05
commit f22f46f4f9
2 changed files with 14 additions and 16 deletions

View File

@ -57,7 +57,7 @@ from synapse.federation.transport.server import TransportLayerServer
from synapse.util.rlimit import change_resource_limit from synapse.util.rlimit import change_resource_limit
from synapse.util.versionstring import get_version_string from synapse.util.versionstring import get_version_string
from synapse.util.httpresourcetree import create_resource_tree 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 from synapse.http.site import SynapseSite
@ -203,12 +203,14 @@ class SynapseHomeServer(HomeServer):
if listener["type"] == "http": if listener["type"] == "http":
self._listener_http(config, listener) self._listener_http(config, listener)
elif listener["type"] == "manhole": elif listener["type"] == "manhole":
listen_manhole( reactor.listenTCP(
bind_address=listener.get("bind_address", '127.0.0.1'), listener["port"],
bind_port=listener["port"], manhole(
username="matrix", username="matrix",
password="rabbithole", password="rabbithole",
globals={"hs": self}, globals={"hs": self},
),
interface=listener.get("bind_address", '127.0.0.1')
) )
else: else:
logger.warn("Unrecognized listener type: %s", listener["type"]) logger.warn("Unrecognized listener type: %s", listener["type"])

View File

@ -18,21 +18,19 @@ from twisted.conch import manhole_ssh
from twisted.cred import checkers, portal from twisted.cred import checkers, portal
from twisted.internet import reactor def manhole(username, password, globals):
def listen_manhole(bind_address, bind_port, username, password, globals):
"""Starts a ssh listener with password authentication using """Starts a ssh listener with password authentication using
the given username and password. Clients connecting to the ssh the given username and password. Clients connecting to the ssh
listener will find themselves in a colored python shell with listener will find themselves in a colored python shell with
the supplied globals. the supplied globals.
Args: 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. username(str): The username ssh clients should auth with.
password(str): The password ssh clients should auth with. password(str): The password ssh clients should auth with.
globals(dict): The variables to expose in the shell. globals(dict): The variables to expose in the shell.
Returns:
twisted.internet.protocol.Factory: A factory to pass to ``listenTCP``
""" """
checker = checkers.InMemoryUsernamePasswordDatabaseDontUse( checker = checkers.InMemoryUsernamePasswordDatabaseDontUse(
@ -45,6 +43,4 @@ def listen_manhole(bind_address, bind_port, username, password, globals):
dict(globals, __name__="__console__") dict(globals, __name__="__console__")
) )
factory = manhole_ssh.ConchFactory(portal.Portal(rlm, [checker])) return manhole_ssh.ConchFactory(portal.Portal(rlm, [checker]))
reactor.listenTCP(bind_port, factory, interface=bind_address)