In passive mode if we have send onion address for every connection not just for tor network
This commit is contained in:
parent
4f472982da
commit
1ad966bd80
2 changed files with 17 additions and 13 deletions
|
@ -355,17 +355,9 @@ class Connection(object):
|
|||
else:
|
||||
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
|
||||
if handshake.get("crypt_supported") and handshake["peer_id"] not in self.server.broken_ssl_peer_ids:
|
||||
if self.ip.endswith(".onion"):
|
||||
if handshake.get("crypt_supported") and self.ip not in self.server.broken_ssl_ips:
|
||||
if self.ip.endswith(".onion") or self.ip in config.ip_local:
|
||||
crypt = None
|
||||
elif handshake.get("crypt"): # Recommended crypt by server
|
||||
crypt = handshake["crypt"]
|
||||
|
@ -374,6 +366,15 @@ class Connection(object):
|
|||
|
||||
if crypt:
|
||||
self.crypt = crypt
|
||||
|
||||
if self.type == "in" and 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()
|
||||
|
||||
self.event_connected.set(True) # Mark handshake as done
|
||||
self.event_connected = None
|
||||
|
||||
|
|
|
@ -110,8 +110,11 @@ class ConnectionServer(object):
|
|||
pass
|
||||
|
||||
def getConnection(self, ip=None, port=None, peer_id=None, create=True, site=None):
|
||||
if ip.endswith(".onion") and self.tor_manager.start_onions and site: # Site-unique connection for Tor
|
||||
site_onion = self.tor_manager.getOnion(site.address)
|
||||
if (ip.endswith(".onion") or self.port_opened == False) and self.tor_manager.start_onions and site: # Site-unique connection for Tor
|
||||
if ip.endswith(".onion"):
|
||||
site_onion = self.tor_manager.getOnion(site.address)
|
||||
else:
|
||||
site_onion = self.tor_manager.getOnion("global")
|
||||
key = ip + site_onion
|
||||
else:
|
||||
key = ip
|
||||
|
@ -149,7 +152,7 @@ class ConnectionServer(object):
|
|||
raise Exception("This peer is blacklisted")
|
||||
|
||||
try:
|
||||
if ip.endswith(".onion") and self.tor_manager.start_onions and site: # Lock connection to site
|
||||
if (ip.endswith(".onion") or self.port_opened == False) and self.tor_manager.start_onions and site: # Lock connection to site
|
||||
connection = Connection(self, ip, port, target_onion=site_onion)
|
||||
else:
|
||||
connection = Connection(self, ip, port)
|
||||
|
|
Loading…
Reference in a new issue