Store opened port status per IP version

This commit is contained in:
shortcutme 2019-01-23 02:11:31 +01:00
parent ce78e330d3
commit 447f5fd5c8
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
7 changed files with 65 additions and 36 deletions

View file

@ -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,

View file

@ -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)