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

Commit

Permalink
Look up the right SRV record
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Jan 24, 2019
1 parent e1c8440 commit afd69a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/4464.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move SRV logic into the Agent layer
3 changes: 2 additions & 1 deletion synapse/http/federation/matrix_federation_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def request(self, method, uri, headers=None, bodyProducer=None):
if port is not None:
target = (host, port)
else:
server_list = yield self._srv_resolver.resolve_service(server_name_bytes)
service_name = b"_matrix._tcp.%s" % (server_name_bytes, )
server_list = yield self._srv_resolver.resolve_service(service_name)
if not server_list:
target = (host, 8448)
logger.debug("No SRV record for %s, using %s", host, target)
Expand Down
12 changes: 9 additions & 3 deletions tests/http/federation/test_matrix_federation_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def test_get_ip_address(self):
# Nothing happened yet
self.assertNoResult(test_d)

self.mock_resolver.resolve_service.assert_called_once()
self.mock_resolver.resolve_service.assert_called_once_with(
b"_matrix._tcp.1.2.3.4",
)

# Make sure treq is trying to connect
clients = self.reactor.tcpClients
Expand Down Expand Up @@ -212,7 +214,9 @@ def test_get_hostname_no_srv(self):
# Nothing happened yet
self.assertNoResult(test_d)

self.mock_resolver.resolve_service.assert_called_once()
self.mock_resolver.resolve_service.assert_called_once_with(
b"_matrix._tcp.testserv",
)

# Make sure treq is trying to connect
clients = self.reactor.tcpClients
Expand Down Expand Up @@ -251,7 +255,9 @@ def test_get_hostname_srv(self):
# Nothing happened yet
self.assertNoResult(test_d)

self.mock_resolver.resolve_service.assert_called_once()
self.mock_resolver.resolve_service.assert_called_once_with(
b"_matrix._tcp.testserv",
)

# Make sure treq is trying to connect
clients = self.reactor.tcpClients
Expand Down

0 comments on commit afd69a0

Please sign in to comment.