-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Adapt the default config to bind on both IPv4 and IPv6 on all platforms #2435
Conversation
Can one of the admins verify this patch? |
2 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
synapse/app/homeserver.py
Outdated
@@ -259,6 +273,13 @@ def quit_with_error(error_string): | |||
sys.exit(1) | |||
|
|||
|
|||
def check_bind_error(e, address, bind_addresses): | |||
if address == '0.0.0.0' and '::' in bind_addresses: | |||
logger.warn('Failed to listen on 0.0.0.0, continuing because listening on [::]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a comment about why this is a sensible thing to do (ie, explaining some of the problems discussed in #2232 ) ?
matrixbot: ok to test |
synapse/app/homeserver.py
Outdated
interface=address | ||
) | ||
except error.CannotListenError as e: | ||
check_bind_error(e, address, bind_addresses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it makes sense to apply the same logic to the rabbithole or replication listeners, not least because if you're binding them to the wildcard addresses, you're probably doing it wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we're going to do this we should probably be consistent, so this needs updating in all the other synapse/app/*.py
workers.
generally this looks like a good idea to me. @erikjohnston do you have any thoughts? |
I have committed an attempt to abstract this in |
synapse/app/homeserver.py
Outdated
@@ -258,7 +263,6 @@ def quit_with_error(error_string): | |||
sys.stderr.write("*" * line_length + '\n') | |||
sys.exit(1) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a PEP8 failure
synapse/app/homeserver.py
Outdated
"before", "shutdown", server_listener.stopListening, | ||
) | ||
except error.CannotListenError as e: | ||
_base.check_bind_error(logger, e, address, bind_addresses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to do this for the replication listener
synapse/app/_base.py
Outdated
@@ -97,3 +97,58 @@ def run(): | |||
daemon.start() | |||
else: | |||
run() | |||
|
|||
|
|||
def listen_tcp(logger, bind_addresses, port, factory, backlog=50): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd probably be better to create a new logger
in this file than to pass around the logger from another file.
Most deployments are on Linux (or Mac OS), so this would actually bind on both IPv4 and IPv6. Resolves matrix-org#1886. Signed-off-by: Willem Mulder <willemmaster@hotmail.com>
Binding on 0.0.0.0 when :: is specified in the bind_addresses is now allowed. This causes a warning explaining the behaviour. Configuration changed to match. See matrix-org#2232 Signed-off-by: Silke Hofstra <silke@slxh.eu>
Add listen_tcp and listen_ssl which implement Twisted's reactor.listenTCP and reactor.listenSSL for multiple addresses. Signed-off-by: Silke Hofstra <silke@slxh.eu>
7ce6531
to
8ad120b
Compare
The requested changes have been applied and I have rebased on develop. Edit: they have been updated. |
8ad120b
to
70b20f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good otherwise
synapse/app/_base.py
Outdated
from twisted.internet import reactor | ||
from twisted.internet import error, reactor | ||
|
||
logger = logging.getLogger("synapse.app.client_reader") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used outside the client reader. logging.getLogger(__name__)
, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Fixed.
Signed-off-by: Silke <silke@slxh.eu>
Signed-off-by: Silke <silke@slxh.eu>
3311c6b
to
df0f602
Compare
thanks! |
This pull requests extends #2232 with the suggestions from @ara4n:
Listen on both
::
and0.0.0.0
, but ignore bind errors for0.0.0.0
when::
was specified.This ensures that the default configuration supports all platforms.