From b0f4119b8bc8ab2da6a6f5f6480da8a0b749c768 Mon Sep 17 00:00:00 2001
From: Marcus <bubu@bubu1.eu>
Date: Wed, 3 Feb 2021 22:47:30 +0100
Subject: [PATCH] Add debug logging to DNS SRV requests. (#9305)

---
 changelog.d/9305.misc                              | 1 +
 synapse/http/federation/matrix_federation_agent.py | 7 +++++++
 2 files changed, 8 insertions(+)
 create mode 100644 changelog.d/9305.misc

diff --git a/changelog.d/9305.misc b/changelog.d/9305.misc
new file mode 100644
index 0000000000..456bfbfdd7
--- /dev/null
+++ b/changelog.d/9305.misc
@@ -0,0 +1 @@
+Add debug logging for SRV lookups. Contributed by @Bubu.
diff --git a/synapse/http/federation/matrix_federation_agent.py b/synapse/http/federation/matrix_federation_agent.py
index 4c06a117d3..113fd47134 100644
--- a/synapse/http/federation/matrix_federation_agent.py
+++ b/synapse/http/federation/matrix_federation_agent.py
@@ -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)]
 
 
-- 
GitLab