Store opened port status per IP version
This commit is contained in:
parent
ce78e330d3
commit
447f5fd5c8
7 changed files with 65 additions and 36 deletions
|
@ -347,7 +347,7 @@ class Connection(object):
|
|||
"protocol": "v2",
|
||||
"peer_id": peer_id,
|
||||
"fileserver_port": self.server.port,
|
||||
"port_opened": self.server.port_opened,
|
||||
"port_opened": self.server.port_opened.get(self.ip_type, None),
|
||||
"target_ip": self.ip,
|
||||
"rev": config.rev,
|
||||
"crypt_supported": crypt_supported,
|
||||
|
|
|
@ -164,7 +164,9 @@ class ConnectionServer(object):
|
|||
pass
|
||||
|
||||
def getConnection(self, ip=None, port=None, peer_id=None, create=True, site=None, is_tracker_connection=False):
|
||||
if (ip.endswith(".onion") or self.port_opened == False) and self.tor_manager.start_onions and site: # Site-unique connection for Tor
|
||||
ip_type = helper.getIpType(ip)
|
||||
has_per_site_onion = (ip.endswith(".onion") or self.port_opened.get(ip_type, None) == False) and self.tor_manager.start_onions and site
|
||||
if has_per_site_onion: # Site-unique connection for Tor
|
||||
if ip.endswith(".onion"):
|
||||
site_onion = self.tor_manager.getOnion(site.address)
|
||||
else:
|
||||
|
@ -206,7 +208,7 @@ class ConnectionServer(object):
|
|||
raise Exception("This peer is blacklisted")
|
||||
|
||||
try:
|
||||
if (ip.endswith(".onion") or self.port_opened == False) and self.tor_manager.start_onions and site: # Lock connection to site
|
||||
if has_per_site_onion: # Lock connection to site
|
||||
connection = Connection(self, ip, port, target_onion=site_onion, is_tracker_connection=is_tracker_connection)
|
||||
else:
|
||||
connection = Connection(self, ip, port, is_tracker_connection=is_tracker_connection)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue