Skip to content

Commit

Permalink
Handle ip change on onion connection correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Feb 27, 2018
1 parent f10233a commit af57083
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Connection/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def messageLoop(self):
self.connected = True
buff_len = 0
req_len = 0

unpacker_bytes = 0

try:
while not self.closed:
buff = self.sock.recv(64 * 1024)
Expand Down Expand Up @@ -330,7 +330,11 @@ def setHandshake(self, handshake):
self.port = handshake["fileserver_port"] # Set peer fileserver port

if handshake.get("onion") and not self.ip.endswith(".onion"): # Set incoming connection's onion address
if self.server.ips.get(self.ip) == self:
del self.server.ips[self.ip]
self.ip = handshake["onion"] + ".onion"
self.log("Changing ip to %s" % self.ip)
self.server.ips[self.ip] = self
self.updateName()

# Check if we can encrypt the connection
Expand Down

0 comments on commit af57083

Please sign in to comment.