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

Commit

Permalink
Handle SERVFAILs when doing AAAA lookups for federation (#2477)
Browse files Browse the repository at this point in the history
... to cope with people with broken dnssec setups, mostly
  • Loading branch information
richvdh authored Sep 28, 2017
1 parent 768f00d commit 75e67b9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions synapse/http/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,28 @@ def cb(res):

return res[0]

def eb(res):
res.trap(DNSNameError)
return []
def eb(res, record_type):
if res.check(DNSNameError):
return []
logger.warn("Error looking up %s for %s: %s",
record_type, host, res, res.value)
return res

# no logcontexts here, so we can safely fire these off and gatherResults
d1 = dns_client.lookupAddress(host).addCallbacks(cb, eb)
d2 = dns_client.lookupIPV6Address(host).addCallbacks(cb, eb)
results = yield defer.gatherResults([d1, d2], consumeErrors=True)
results = yield defer.DeferredList(
[d1, d2], consumeErrors=True)

# if all of the lookups failed, raise an exception rather than blowing out
# the cache with an empty result.
if results and all(s == defer.FAILURE for (s, _) in results):
defer.returnValue(results[0][1])

for (success, result) in results:
if success == defer.FAILURE:
continue

for result in results:
for answer in result:
if not answer.payload:
continue
Expand Down

0 comments on commit 75e67b9

Please sign in to comment.