Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
juga
sbws
Commits
ed1d61c9
Commit
ed1d61c9
authored
Oct 24, 2018
by
juga
Browse files
Merge branch 'ticket28141'
parents
1defb776
8787741b
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
ed1d61c9
...
...
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
-
Update python minimal version in setup (#28043)
-
Catch unhandled exception when we fail to resolve a domain name (#28141)
### Changed
...
...
sbws/globals.py
View file @
ed1d61c9
...
...
@@ -68,8 +68,16 @@ def touch_file(fname, times=None):
def
resolve
(
hostname
,
ipv4_only
=
False
,
ipv6_only
=
False
):
assert
not
(
ipv4_only
and
ipv6_only
)
results
=
[]
try
:
results
=
socket
.
getaddrinfo
(
hostname
,
0
)
except
socket
.
gaierror
:
log
.
warn
(
'Unable to resolve %s hostname. Returning empty list of addresses'
,
hostname
)
return
[]
ret
=
set
()
for
result
in
socket
.
getaddrinfo
(
hostname
,
0
)
:
for
result
in
results
:
fam
,
_
,
_
,
_
,
addr
=
result
if
fam
==
socket
.
AddressFamily
.
AF_INET6
and
not
ipv4_only
:
ret
.
add
(
addr
[
0
])
...
...
sbws/lib/relaylist.py
View file @
ed1d61c9
...
...
@@ -120,7 +120,10 @@ class Relay:
#
# Also, only use the first ipv4/6 we get even if there is more than
# one.
host
=
resolve
(
host
)[
0
]
results
=
resolve
(
host
)
if
not
len
(
results
):
return
False
host
=
results
[
0
]
assert
is_valid_ipv4_address
(
host
)
or
is_valid_ipv6_address
(
host
)
return
self
.
exit_policy
.
can_exit_to
(
host
,
port
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment