diff options
author | Richard van der Hoff <richard@matrix.org> | 2019-01-22 17:35:09 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2019-01-22 20:35:12 +0000 |
commit | 53a327b4d5bdcab36651aa86ddf1815ff86e5db2 (patch) | |
tree | e10bb401e66216757ed73fe3c318547fea24bc26 /synapse/http | |
parent | changelog (diff) | |
download | synapse-53a327b4d5bdcab36651aa86ddf1815ff86e5db2.tar.xz |
Require that service_name be a byte string
it is only ever a bytes now, so let's enforce that.
Diffstat (limited to 'synapse/http')
-rw-r--r-- | synapse/http/federation/srv_resolver.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/synapse/http/federation/srv_resolver.py b/synapse/http/federation/srv_resolver.py index a6e92fdf40..e05f934d0b 100644 --- a/synapse/http/federation/srv_resolver.py +++ b/synapse/http/federation/srv_resolver.py @@ -92,7 +92,7 @@ def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE, clock=t but the cache never gets populated), so we add our own caching layer here. Args: - service_name (unicode|bytes): record to look up + service_name (bytes): record to look up dns_client (twisted.internet.interfaces.IResolver): twisted resolver impl cache (dict): cache object clock (object): clock implementation. must provide a time() method. @@ -100,9 +100,9 @@ def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE, clock=t Returns: Deferred[list[Server]]: a list of the SRV records, or an empty list if none found """ - # TODO: the dns client handles both unicode names (encoding via idna) and pre-encoded - # byteses; however they will obviously end up as separate entries in the cache. We - # should pick one form and stick with it. + if not isinstance(service_name, bytes): + raise TypeError("%r is not a byte string" % (service_name,)) + cache_entry = cache.get(service_name, None) if cache_entry: if all(s.expires > int(clock.time()) for s in cache_entry): |