Handle ip change on onion connection correctly
This commit is contained in:
parent
f10233a0a6
commit
af57083afd
1 changed files with 5 additions and 1 deletions
|
@ -162,8 +162,8 @@ class Connection(object):
|
||||||
self.connected = True
|
self.connected = True
|
||||||
buff_len = 0
|
buff_len = 0
|
||||||
req_len = 0
|
req_len = 0
|
||||||
|
|
||||||
unpacker_bytes = 0
|
unpacker_bytes = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while not self.closed:
|
while not self.closed:
|
||||||
buff = self.sock.recv(64 * 1024)
|
buff = self.sock.recv(64 * 1024)
|
||||||
|
@ -330,7 +330,11 @@ class Connection(object):
|
||||||
self.port = handshake["fileserver_port"] # Set peer fileserver port
|
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 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.ip = handshake["onion"] + ".onion"
|
||||||
|
self.log("Changing ip to %s" % self.ip)
|
||||||
|
self.server.ips[self.ip] = self
|
||||||
self.updateName()
|
self.updateName()
|
||||||
|
|
||||||
# Check if we can encrypt the connection
|
# Check if we can encrypt the connection
|
||||||
|
|
Loading…
Reference in a new issue