mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 14:03:53 +01:00
Improve logging around listening services
I wanted to bring listen_tcp into line with listen_ssl in terms of returning a list of ports, and wanted to check that was a safe thing to do - hence the logging in `refresh_certificate`. Also, pull the 'Synapse now listening' message up to homeserver.py, because it was being duplicated everywhere else.
This commit is contained in:
parent
e3a0300431
commit
2a5a15aff8
2 changed files with 20 additions and 11 deletions
|
@ -162,21 +162,23 @@ def listen_tcp(bind_addresses, port, factory, reactor=reactor, backlog=50):
|
||||||
Create a TCP socket for a port and several addresses
|
Create a TCP socket for a port and several addresses
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list (empty)
|
list of twisted.internet.tcp.Port listening for TLS connections
|
||||||
"""
|
"""
|
||||||
|
r = []
|
||||||
for address in bind_addresses:
|
for address in bind_addresses:
|
||||||
try:
|
try:
|
||||||
reactor.listenTCP(
|
r.append(
|
||||||
port,
|
reactor.listenTCP(
|
||||||
factory,
|
port,
|
||||||
backlog,
|
factory,
|
||||||
address
|
backlog,
|
||||||
|
address
|
||||||
|
)
|
||||||
)
|
)
|
||||||
except error.CannotListenError as e:
|
except error.CannotListenError as e:
|
||||||
check_bind_error(e, address, bind_addresses)
|
check_bind_error(e, address, bind_addresses)
|
||||||
|
|
||||||
logger.info("Synapse now listening on TCP port %d", port)
|
return r
|
||||||
return []
|
|
||||||
|
|
||||||
|
|
||||||
def listen_ssl(
|
def listen_ssl(
|
||||||
|
@ -203,7 +205,6 @@ def listen_ssl(
|
||||||
except error.CannotListenError as e:
|
except error.CannotListenError as e:
|
||||||
check_bind_error(e, address, bind_addresses)
|
check_bind_error(e, address, bind_addresses)
|
||||||
|
|
||||||
logger.info("Synapse now listening on port %d (TLS)", port)
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,6 +230,10 @@ def refresh_certificate(hs):
|
||||||
# requests. This factory attribute is public but missing from
|
# requests. This factory attribute is public but missing from
|
||||||
# Twisted's documentation.
|
# Twisted's documentation.
|
||||||
if isinstance(i.factory, TLSMemoryBIOFactory):
|
if isinstance(i.factory, TLSMemoryBIOFactory):
|
||||||
|
addr = i.getHost()
|
||||||
|
logger.info(
|
||||||
|
"Replacing TLS context factory on [%s]:%i", addr.host, addr.port,
|
||||||
|
)
|
||||||
# We want to replace TLS factories with a new one, with the new
|
# We want to replace TLS factories with a new one, with the new
|
||||||
# TLS configuration. We do this by reaching in and pulling out
|
# TLS configuration. We do this by reaching in and pulling out
|
||||||
# the wrappedFactory, and then re-wrapping it.
|
# the wrappedFactory, and then re-wrapping it.
|
||||||
|
|
|
@ -121,7 +121,7 @@ class SynapseHomeServer(HomeServer):
|
||||||
root_resource = create_resource_tree(resources, root_resource)
|
root_resource = create_resource_tree(resources, root_resource)
|
||||||
|
|
||||||
if tls:
|
if tls:
|
||||||
return listen_ssl(
|
ports = listen_ssl(
|
||||||
bind_addresses,
|
bind_addresses,
|
||||||
port,
|
port,
|
||||||
SynapseSite(
|
SynapseSite(
|
||||||
|
@ -134,9 +134,10 @@ class SynapseHomeServer(HomeServer):
|
||||||
self.tls_server_context_factory,
|
self.tls_server_context_factory,
|
||||||
reactor=self.get_reactor(),
|
reactor=self.get_reactor(),
|
||||||
)
|
)
|
||||||
|
logger.info("Synapse now listening on TCP port %d (TLS)", port)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return listen_tcp(
|
ports = listen_tcp(
|
||||||
bind_addresses,
|
bind_addresses,
|
||||||
port,
|
port,
|
||||||
SynapseSite(
|
SynapseSite(
|
||||||
|
@ -148,6 +149,9 @@ class SynapseHomeServer(HomeServer):
|
||||||
),
|
),
|
||||||
reactor=self.get_reactor(),
|
reactor=self.get_reactor(),
|
||||||
)
|
)
|
||||||
|
logger.info("Synapse now listening on TCP port %d", port)
|
||||||
|
|
||||||
|
return ports
|
||||||
|
|
||||||
def _configure_named_resource(self, name, compress=False):
|
def _configure_named_resource(self, name, compress=False):
|
||||||
"""Build a resource map for a named resource
|
"""Build a resource map for a named resource
|
||||||
|
|
Loading…
Reference in a new issue