From f22b5da170e699c25c64474eb8c8bd66d569a132 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 6 Feb 2019 12:11:22 -0500 Subject: [PATCH] fix raised error for a peer address mismatch --- lbrynet/dht/protocol/protocol.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lbrynet/dht/protocol/protocol.py b/lbrynet/dht/protocol/protocol.py index 0b31bc1b5..ec3cd8dd0 100644 --- a/lbrynet/dht/protocol/protocol.py +++ b/lbrynet/dht/protocol/protocol.py @@ -474,7 +474,12 @@ class KademliaProtocol(DatagramProtocol): remote_exception = RemoteException(f"{error_datagram.exception_type}({error_datagram.response})") if error_datagram.rpc_id in self.sent_messages: peer, df, request = self.sent_messages.pop(error_datagram.rpc_id) - + if (peer.address, peer.udp_port) != address: + df.set_exception(RemoteException( + f"response from {address[0]}:{address[1]}, " + f"expected {peer.address}:{peer.udp_port}") + ) + return error_msg = f"" \ f"Error sending '{request.method}' to {peer.address}:{peer.udp_port}\n" \ f"Args: {request.args}\n" \ @@ -484,11 +489,6 @@ class KademliaProtocol(DatagramProtocol): else: log.warning("known dht protocol backwards compatibility error with %s:%i (lbrynet v%s)", peer.address, peer.udp_port, old_protocol_errors[error_datagram.response]) - - # reject replies coming from a different address than what we sent our request to - if (peer.address, peer.udp_port) != address: - log.error("node id mismatch in reply") - remote_exception = TimeoutError(peer.node_id) df.set_exception(remote_exception) return else: