Merge pull request #2521 from lbryio/resolve-ipv4-only

fix resolving fixed peers from an ipv6 connection
This commit is contained in:
Jack Robison 2019-10-08 14:37:49 -04:00 committed by GitHub
commit 292f1953e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -161,7 +161,7 @@ class KademliaPeer:
if self.tcp_port is not None and not 1 <= self.tcp_port <= 65535:
raise ValueError("invalid tcp port")
if not is_valid_ipv4(self.address):
raise ValueError("invalid ip address")
raise ValueError(f"invalid ip address: '{self.address}'")
def update_tcp_port(self, tcp_port: int):
self.tcp_port = tcp_port

View file

@ -192,7 +192,8 @@ async def resolve_host(url: str, port: int, proto: str) -> str:
return (await loop.getaddrinfo(
url, port,
proto=socket.IPPROTO_TCP if proto == 'tcp' else socket.IPPROTO_UDP,
type=socket.SOCK_STREAM if proto == 'tcp' else socket.SOCK_DGRAM
type=socket.SOCK_STREAM if proto == 'tcp' else socket.SOCK_DGRAM,
family=socket.AF_INET
))[0][4][0]