Fold the slightly-odd bind_port/secure_port/etc.. logic into SynapseHomeServer.start_listening()

This commit is contained in:
Paul "LeoNerd" Evans 2015-03-12 15:51:33 +00:00
parent e0214a263b
commit a2cdd11d4a
1 changed files with 11 additions and 12 deletions

View File

@ -219,17 +219,20 @@ class SynapseHomeServer(HomeServer):
""" """
return "%s-%s" % (resource, path_seg) return "%s-%s" % (resource, path_seg)
def start_listening(self, secure_port, unsecure_port): def start_listening(self):
if secure_port is not None: config = self.get_config()
if not config.no_tls and config.bind_port is not None:
reactor.listenSSL( reactor.listenSSL(
secure_port, Site(self.root_resource), self.tls_context_factory config.bind_port, Site(self.root_resource), self.tls_context_factory
) )
logger.info("Synapse now listening on port %d", secure_port) logger.info("Synapse now listening on port %d", config.bind_port)
if unsecure_port is not None:
if config.unsecure_port is not None:
reactor.listenTCP( reactor.listenTCP(
unsecure_port, Site(self.root_resource) config.unsecure_port, Site(self.root_resource)
) )
logger.info("Synapse now listening on port %d", unsecure_port) logger.info("Synapse now listening on port %d", config.unsecure_port)
def get_version_string(): def get_version_string():
@ -381,11 +384,7 @@ def setup(config_options):
f.namespace['hs'] = hs f.namespace['hs'] = hs
reactor.listenTCP(config.manhole, f, interface='127.0.0.1') reactor.listenTCP(config.manhole, f, interface='127.0.0.1')
bind_port = config.bind_port hs.start_listening()
if config.no_tls:
bind_port = None
hs.start_listening(bind_port, config.unsecure_port)
hs.get_pusherpool().start() hs.get_pusherpool().start()
hs.get_state_handler().start_caching() hs.get_state_handler().start_caching()