Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
53a327b4
Commit
53a327b4
authored
6 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Require that service_name be a byte string
it is only ever a bytes now, so let's enforce that.
parent
c66f4bf7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/http/federation/srv_resolver.py
+4
-4
4 additions, 4 deletions
synapse/http/federation/srv_resolver.py
tests/http/federation/test_srv_resolver.py
+4
-4
4 additions, 4 deletions
tests/http/federation/test_srv_resolver.py
with
8 additions
and
8 deletions
synapse/http/federation/srv_resolver.py
+
4
−
4
View file @
53a327b4
...
...
@@ -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 separa
te
en
tri
es in the cache. We
# should pick one form and stick with it.
if
not
isinstance
(
service_name
,
bytes
):
raise
TypeError
(
"
%r is not a by
te
s
tri
ng
"
%
(
service_name
,))
cache_entry
=
cache
.
get
(
service_name
,
None
)
if
cache_entry
:
if
all
(
s
.
expires
>
int
(
clock
.
time
())
for
s
in
cache_entry
):
...
...
This diff is collapsed.
Click to expand it.
tests/http/federation/test_srv_resolver.py
+
4
−
4
View file @
53a327b4
...
...
@@ -83,7 +83,7 @@ class SrvResolverTestCase(unittest.TestCase):
dns_client_mock
=
Mock
()
dns_client_mock
.
lookupService
.
return_value
=
defer
.
fail
(
error
.
DNSServerError
())
service_name
=
"
test_service.example.com
"
service_name
=
b
"
test_service.example.com
"
entry
=
Mock
(
spec_set
=
[
"
expires
"
])
entry
.
expires
=
0
...
...
@@ -106,7 +106,7 @@ class SrvResolverTestCase(unittest.TestCase):
dns_client_mock
=
Mock
(
spec_set
=
[
'
lookupService
'
])
dns_client_mock
.
lookupService
=
Mock
(
spec_set
=
[])
service_name
=
"
test_service.example.com
"
service_name
=
b
"
test_service.example.com
"
entry
=
Mock
(
spec_set
=
[
"
expires
"
])
entry
.
expires
=
999999999
...
...
@@ -128,7 +128,7 @@ class SrvResolverTestCase(unittest.TestCase):
dns_client_mock
.
lookupService
.
return_value
=
defer
.
fail
(
error
.
DNSServerError
())
service_name
=
"
test_service.example.com
"
service_name
=
b
"
test_service.example.com
"
cache
=
{}
...
...
@@ -141,7 +141,7 @@ class SrvResolverTestCase(unittest.TestCase):
dns_client_mock
.
lookupService
.
return_value
=
defer
.
fail
(
error
.
DNSNameError
())
service_name
=
"
test_service.example.com
"
service_name
=
b
"
test_service.example.com
"
cache
=
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment