diff --git a/lbry/dht/peer.py b/lbry/dht/peer.py index bc2a60022..b1abaa8fb 100644 --- a/lbry/dht/peer.py +++ b/lbry/dht/peer.py @@ -156,9 +156,9 @@ class KademliaPeer: if not len(self._node_id) == constants.HASH_LENGTH: raise ValueError("invalid node_id: {}".format(hexlify(self._node_id).decode())) if self.udp_port is not None and not 1024 <= self.udp_port <= 65535: - raise ValueError("invalid udp port") + raise ValueError(f"invalid udp port: {self.address}:{self.udp_port}") if self.tcp_port is not None and not 1024 <= self.tcp_port <= 65535: - raise ValueError("invalid tcp port") + raise ValueError(f"invalid tcp port: {self.address}:{self.tcp_port}") if not is_valid_public_ipv4(self.address, self.allow_localhost): raise ValueError(f"invalid ip address: '{self.address}'") diff --git a/lbry/dht/protocol/protocol.py b/lbry/dht/protocol/protocol.py index 7b90b5644..8c24aeb76 100644 --- a/lbry/dht/protocol/protocol.py +++ b/lbry/dht/protocol/protocol.py @@ -452,7 +452,11 @@ class KademliaProtocol(DatagramProtocol): try: peer = self.routing_table.get_peer(request_datagram.node_id) except IndexError: - peer = make_kademlia_peer(request_datagram.node_id, address[0], address[1]) + try: + peer = make_kademlia_peer(request_datagram.node_id, address[0], address[1]) + except ValueError as err: + log.warning("error replying to %s: %s", address[0], str(err)) + return try: self._handle_rpc(peer, request_datagram) # if the contact is not known to be bad (yet) and we haven't yet queried it, send it a ping so that it