New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement MSC1708 (.well-known lookups for server routing) #4489

Merged
merged 14 commits into from Jan 29, 2019

Conversation

3 participants
@richvdh
Copy link
Member

richvdh commented Jan 28, 2019

Based on #4488.

richvdh added some commits Jan 25, 2019

Fix idna and ipv6 literal handling in MatrixFederationAgent
Turns out that the library does a better job of parsing URIs than our
reinvented wheel. Who knew.

There are two things going on here. The first is that, unlike
parse_server_name, URI.fromBytes will strip off square brackets from IPv6
literals, which means that it is valid input to ClientTLSOptionsFactory and
HostnameEndpoint.

The second is that we stay in `bytes` throughout (except for the argument to
ClientTLSOptionsFactory), which avoids the weirdness of (sometimes) ending up
with idna-encoded values being held in `unicode` variables. TBH it probably
would have been ok but it made the tests fragile.
Handle IP literals explicitly
We don't want to be doing .well-known lookups on these guys.
MatrixFederationAgent: factor out routing logic
This is going to get too big and unmanageable.

@richvdh richvdh requested a review from matrix-org/synapse-core Jan 28, 2019

@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Jan 28, 2019

Codecov Report

Merging #4489 into develop will decrease coverage by <.01%.
The diff coverage is 67.39%.

@@             Coverage Diff             @@
##           develop    #4489      +/-   ##
===========================================
- Coverage    74.76%   74.75%   -0.01%     
===========================================
  Files          336      336              
  Lines        34180    34224      +44     
  Branches      5559     5567       +8     
===========================================
+ Hits         25553    25583      +30     
- Misses        7051     7061      +10     
- Partials      1576     1580       +4

@richvdh richvdh added this to To Do in Homeserver Task Board via automation Jan 28, 2019

@richvdh richvdh moved this from To Do to In progress in Homeserver Task Board Jan 28, 2019

@erikjohnston
Copy link
Member

erikjohnston left a comment

Looks sane, would be nice to have some more comments/docstrings about what's going on thought 👍

Show resolved Hide resolved synapse/http/federation/matrix_federation_agent.py
Show resolved Hide resolved synapse/http/federation/matrix_federation_agent.py

body = yield make_deferred_yieldable(readBody(response))

logger.info("Response from .well-known: %s", body)

This comment has been minimized.

@erikjohnston

erikjohnston Jan 28, 2019

Member

This should probably be debug

This comment has been minimized.

@richvdh

richvdh Jan 28, 2019

Author Member

I'm minded to leave it as info for now as otherwise it's quite hard to see what's going on. I've moved it down a bit to print out the parsed response though.

Show resolved Hide resolved synapse/http/federation/matrix_federation_agent.py

@richvdh richvdh force-pushed the rav/fed_routing/well-known branch 2 times, most recently from 82b31b9 to f3b50e0 Jan 28, 2019

@richvdh richvdh requested a review from erikjohnston Jan 28, 2019

richvdh added some commits Jan 28, 2019

Use SimpleResolverComplexifier in tests
two reasons for this. One, it saves a bunch of boilerplate. Two, it squashes
unicode to IDNA-in-a-`str` (even on python 3) in a way that it turns out we
rely on to give consistent behaviour between python 2 and 3.
@richvdh

This comment has been minimized.

Copy link
Member Author

richvdh commented Jan 28, 2019

(have merged in #4497 in an attempt to get the tests to work)

@richvdh richvdh merged commit 99e36d5 into develop Jan 29, 2019

5 checks passed

ci/circleci: sytestpy2merged Your tests passed on CircleCI!
Details
ci/circleci: sytestpy2postgresmerged Your tests passed on CircleCI!
Details
ci/circleci: sytestpy3merged Your tests passed on CircleCI!
Details
ci/circleci: sytestpy3postgresmerged Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@richvdh richvdh deleted the rav/fed_routing/well-known branch Jan 29, 2019

@richvdh richvdh moved this from In progress to Done in Homeserver Task Board Jan 29, 2019

turt2live added a commit to matrix-org/matrix-doc that referenced this pull request Jan 31, 2019

Specify .well-known s2s discovery and X.509 validation
Original proposals:
* #1708 (note: the JSON requirements were softened by #1824)
* #1711

Implementation proofs:
* matrix-org/synapse#4489
* No explicit PRs for MSC1711 could be found, however Synapse is known to implement it.

There are no intentional changes which differ from the proposals in this commit, however the author has relied upon various historical conversations outside of the proposals to gain the required context. Inaccuracies introduced by the author are purely accidental.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment