Don't connect to myself

This commit is contained in:
shortcutme 2018-02-08 18:01:48 +01:00
parent 8b9d75d726
commit f9091ea951
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -290,6 +290,10 @@ class Connection(object):
return handshake return handshake
def setHandshake(self, handshake): def setHandshake(self, handshake):
if handshake.get("peer_id") == self.server.peer_id:
self.close("Same peer id, can't connect to myself")
return False
self.handshake = handshake self.handshake = handshake
if handshake.get("port_opened", None) is False and "onion" not in handshake and not self.is_private_ip: # Not connectable if handshake.get("port_opened", None) is False and "onion" not in handshake and not self.is_private_ip: # Not connectable
self.port = 0 self.port = 0