-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
This is an (untested) general sketch of how to use wrapClientTLS to implement TLS over IPv6, as well as faster connections over IPv4.
Similar to matrix-org#1689, but for endpoint.py
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? |
One problem though is that the default |
@matrixbot test this please |
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Seems I missed to add the fixed imports originally, so the tests would need to be re-run. |
uh, is this a known issue? |
@matrixbot ok to test |
@kyrias no idea why that build stalled, but I restarted it and now it errors with:
|
Apparently I just removed the spaces instead... Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
? |
It may be worth noting that the empty string may cause Twisted to listen on IPv6 addresses as well, depending on your platform; |
For the record: I had a brief IRL discussion with @erikjohnston and @NegativeMjark and others this morning about what we do about ipv6-only HSes. Obviously we risk a major split-brain problem if some servers can't talk to others 'cos they're either ipv6 or ipv4 only. For now, the suggestion is to mandate that servers expose ipv4 publicly (but if any given pair of servers happen to do ipv6 then they'll use it). I guess this is the same semantics as email. If anyone has any smarter solutions then we're all ears. |
It would also be a good idea to be able to specify multiple bind_addresses, and I have this implemented uncommitted locally already. |
return None | ||
return SpiderEndpoint( | ||
reactor, uri.host, uri.port, self.blacklist, self.whitelist, | ||
endpoint=endpoint_factory, endpoint_kw_args=dict(timeout=15), |
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.
what's the rationale for using dict()
rather than {}
here? i think the existing code style is to use {}
...
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 just didn't change that part, but it seems dict()
is used in a bunch of places as well
λ git grep ' dict\(' | wc -l
61
I can certainly change it to {}
instead though.
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.
looking through the results of that grep, none of those uses seem to be for constants like this, which is only why it jumped out as looking weird. it's trivial, but probably worth fixing. (disclaimer: i'm hardly a python expert, but trying to help fill in whilst @erikjohnston is out)
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.
The rationale is as follows:
- This dictionary is going to be used as
**kw
, meaning it needs to be nativestr
mapped to some object. - To facilitate python 3 portability, all modules should slowly be getting as many
__future__
imports as possible, to make the py2 environment and the py3 environment consistent. One such import isfrom __future__ import unicode_literals
. - If you rely on
""
to produce a nativestr
, this assumption will be broken withunicode_literals
imported. - However,
dict(**kw)
will producekw
unaltered; meaning, it will be a nativestr
even if a quoted string would produce aunicode
.
So this is generally a habit I believe one should get into for py3 hygiene.
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.
okay, i'm happy to defer (and yield, for that matter) to python wisdom here ;)
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.
One such import is
from __future__ import unicode_literals
FWIW, Guido says you shouldn't use unicode_literals
and they're going to add a warning about this to the official docs. (See recent thread on python-dev.)
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.
Hrm. I'm not sure I fully agree with that thread, but definitely unicode_literals
is not without its pitfalls. Nevertheless, dict(**kw)
is a clearer expression of the intent of "I intend to use this for keywords".
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.
the multiple bind_addresses PR has ended up at #1709 - thanks @kyrias! Doing a quick review here, the only thing that screams out as being missing is to kick the dependency for https://github.com/matrix-org/synapse/blob/master/synapse/python_dependencies.py? Otherwise I think I'm happy to merge this as an experimental feature (modulo random stylistic niggle) |
At least 16.0.0 is needed for wrapClientTLS support. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Really glad to help. (Thanks to Rackspace for sponsoring my time to work on open source infrastructure like this in the Twisted ecosystem... :)) |
I've been testing it out in a clean private testing environment with 2 IPv4 and one IPv6 homeservers running, and it seems to be working pretty well so far.
(Supersedes #1689 and #1690)