skip non-public IP addresses

the old TorManager would return None for these, but txtorcon's new API throws
ValueError, which we must catch and skip
This commit is contained in:
Brian Warner 2017-05-23 17:41:24 -07:00
parent 269faf190a
commit 6b4ed71c8a

View File

@ -889,9 +889,12 @@ class Common:
def _endpoint_from_hint_obj(self, hint):
if self._tor:
if isinstance(hint, (DirectTCPV1Hint, TorTCPV1Hint)):
# this Tor object will return None for non-public IPv4
# this Tor object will throw ValueError for non-public IPv4
# addresses and any IPv6 address
return self._tor.stream_via(hint.hostname, hint.port)
try:
return self._tor.stream_via(hint.hostname, hint.port)
except ValueError:
return None
return None
if isinstance(hint, DirectTCPV1Hint):
return endpoints.HostnameEndpoint(self._reactor,