From b2d256b024237d41dd65bee386262d778fd11701 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Thu, 10 Oct 2013 16:23:52 -0500 Subject: [PATCH] added peer validation to registration requests we reply to --- ipsc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ipsc.py b/ipsc.py index 1585f6f..49948a6 100644 --- a/ipsc.py +++ b/ipsc.py @@ -541,10 +541,10 @@ class IPSC(DatagramProtocol): # Answer a peer registration request -- simple, no callback runction needed elif (_packettype == PEER_REG_REQ): -# TO DO TO DO TO DO TO DO ***ADD CODE TO VALIDATE THE PEER IS IN OUR PEER-LIST HERE*** - peer_reg_reply_packet = self.hashed_packet(self._local['AUTH_KEY'], self.PEER_REG_REPLY_PKT) - self._notify_event(self._network, 'peer_registration', {'peer_id': _dec_peerid}) - self.transport.write(peer_reg_reply_packet, (host, port)) + if valid_peer(self._peer_list, _peerid): + peer_reg_reply_packet = self.hashed_packet(self._local['AUTH_KEY'], self.PEER_REG_REPLY_PKT) + self.transport.write(peer_reg_reply_packet, (host, port)) + self._notify_event(self._network, 'peer_registration', {'peer_id': _dec_peerid}) elif (_packettype == PEER_REG_REPLY): self._notify_event(self._network, 'peer_registration_reply', {'peer_id': _dec_peerid})