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:
|
else:
|
||||||
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 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
|
# 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 handshake.get("crypt_supported") and self.ip not in self.server.broken_ssl_ips:
|
||||||
if self.ip.endswith(".onion"):
|
if self.ip.endswith(".onion") or self.ip in config.ip_local:
|
||||||
crypt = None
|
crypt = None
|
||||||
elif handshake.get("crypt"): # Recommended crypt by server
|
elif handshake.get("crypt"): # Recommended crypt by server
|
||||||
crypt = handshake["crypt"]
|
crypt = handshake["crypt"]
|
||||||
|
@ -374,6 +366,15 @@ class Connection(object):
|
||||||
|
|
||||||
if crypt:
|
if crypt:
|
||||||
self.crypt = 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.set(True) # Mark handshake as done
|
||||||
self.event_connected = None
|
self.event_connected = None
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,11 @@ class ConnectionServer(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getConnection(self, ip=None, port=None, peer_id=None, create=True, site=None):
|
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
|
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)
|
site_onion = self.tor_manager.getOnion(site.address)
|
||||||
|
else:
|
||||||
|
site_onion = self.tor_manager.getOnion("global")
|
||||||
key = ip + site_onion
|
key = ip + site_onion
|
||||||
else:
|
else:
|
||||||
key = ip
|
key = ip
|
||||||
|
@ -149,7 +152,7 @@ class ConnectionServer(object):
|
||||||
raise Exception("This peer is blacklisted")
|
raise Exception("This peer is blacklisted")
|
||||||
|
|
||||||
try:
|
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)
|
connection = Connection(self, ip, port, target_onion=site_onion)
|
||||||
else:
|
else:
|
||||||
connection = Connection(self, ip, port)
|
connection = Connection(self, ip, port)
|
||||||
|
|
Loading…
Reference in a new issue