Add debug logging to DNS SRV requests. (#9305)

pull/9317/head
Marcus 2021-02-03 22:47:30 +01:00 committed by GitHub
parent 3f534d3fdf
commit b0f4119b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

1
changelog.d/9305.misc Normal file
View File

@ -0,0 +1 @@
Add debug logging for SRV lookups. Contributed by @Bubu.

View File

@ -323,12 +323,19 @@ class MatrixHostnameEndpoint:
if port or _is_ip_literal(host):
return [Server(host, port or 8448)]
logger.debug("Looking up SRV record for %s", host.decode(errors="replace"))
server_list = await self._srv_resolver.resolve_service(b"_matrix._tcp." + host)
if server_list:
logger.debug(
"Got %s from SRV lookup for %s",
", ".join(map(str, server_list)),
host.decode(errors="replace"),
)
return server_list
# No SRV records, so we fallback to host and 8448
logger.debug("No SRV records for %s", host.decode(errors="replace"))
return [Server(host, 8448)]