Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Adapt the default config to bind on both IPv4 and IPv6 on all platforms #2435

Merged
merged 5 commits into from
Dec 18, 2017

Conversation

silkeh
Copy link
Contributor

@silkeh silkeh commented Sep 2, 2017

This pull requests extends #2232 with the suggestions from @ara4n:

Listen on both :: and 0.0.0.0, but ignore bind errors for 0.0.0.0 when :: was specified.
This ensures that the default configuration supports all platforms.

@matrixbot
Copy link
Member

Can one of the admins verify this patch?

2 similar comments
@matrixbot
Copy link
Member

Can one of the admins verify this patch?

@matrixbot
Copy link
Member

Can one of the admins verify this patch?

@@ -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 [::]')
Copy link
Member

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 ) ?

@richvdh
Copy link
Member

richvdh commented Sep 5, 2017

matrixbot: ok to test

interface=address
)
except error.CannotListenError as e:
check_bind_error(e, address, bind_addresses)
Copy link
Member

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.

Copy link
Member

@richvdh richvdh left a 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.

@richvdh
Copy link
Member

richvdh commented Sep 5, 2017

generally this looks like a good idea to me. @erikjohnston do you have any thoughts?

@silkeh
Copy link
Contributor Author

silkeh commented Sep 6, 2017

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.

I have committed an attempt to abstract this in _base. Depending on feedback I will do the same for all other synapse/app/*.py workers.

@@ -258,7 +263,6 @@ def quit_with_error(error_string):
sys.stderr.write("*" * line_length + '\n')
sys.exit(1)


Copy link
Member

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

"before", "shutdown", server_listener.stopListening,
)
except error.CannotListenError as e:
_base.check_bind_error(logger, e, address, bind_addresses)
Copy link
Member

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

@@ -97,3 +97,58 @@ def run():
daemon.start()
else:
run()


def listen_tcp(logger, bind_addresses, port, factory, backlog=50):
Copy link
Member

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.

14mRh4X0r and others added 3 commits December 17, 2017 13:07
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>
@silkeh silkeh force-pushed the listen-ipv6-default branch 2 times, most recently from 7ce6531 to 8ad120b Compare December 17, 2017 12:27
@silkeh
Copy link
Contributor Author

silkeh commented Dec 17, 2017

The requested changes have been applied and I have rebased on develop.
I still need to update the other synapse/app/*.py workers.

Edit: they have been updated.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good otherwise

from twisted.internet import reactor
from twisted.internet import error, reactor

logger = logging.getLogger("synapse.app.client_reader")
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Fixed.

@richvdh richvdh merged commit 48fa4e1 into matrix-org:develop Dec 18, 2017
@richvdh
Copy link
Member

richvdh commented Dec 18, 2017

thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants