From f706f7508eac8afd39c85818cb5ca9401473004b Mon Sep 17 00:00:00 2001 From: shortcutme Date: Sat, 26 Jan 2019 20:42:27 +0100 Subject: [PATCH] Store detected external ips to separate variable --- plugins/AnnounceShare/AnnounceSharePlugin.py | 2 +- plugins/Sidebar/SidebarPlugin.py | 2 +- plugins/Stats/StatsPlugin.py | 2 +- plugins/Trayicon/TrayiconPlugin.py | 4 ++-- src/File/FileServer.py | 8 +++++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/AnnounceShare/AnnounceSharePlugin.py b/plugins/AnnounceShare/AnnounceSharePlugin.py index 95f1fa74..10e3a3e6 100644 --- a/plugins/AnnounceShare/AnnounceSharePlugin.py +++ b/plugins/AnnounceShare/AnnounceSharePlugin.py @@ -173,7 +173,7 @@ class FileServerPlugin(object): def portCheck(self, *args, **kwargs): res = super(FileServerPlugin, self).portCheck(*args, **kwargs) if res and not config.tor == "always" and "Bootstrapper" in PluginManager.plugin_manager.plugin_names: - for ip in config.ip_external: + for ip in self.ip_external_list: my_tracker_address = "zero://%s:%s" % (ip, config.fileserver_port) tracker_storage.onTrackerFound(my_tracker_address, my=True) return res diff --git a/plugins/Sidebar/SidebarPlugin.py b/plugins/Sidebar/SidebarPlugin.py index 1b4fadec..fd3f8239 100644 --- a/plugins/Sidebar/SidebarPlugin.py +++ b/plugins/Sidebar/SidebarPlugin.py @@ -667,7 +667,7 @@ class UiWebsocketPlugin(object): peer_locations.append(peer_location) # Append myself - for ip in config.ip_external: + for ip in self.site.connection_server.ip_external_list: my_loc = self.getLoc(geodb, ip) if my_loc: my_loc["ping"] = 0 diff --git a/plugins/Stats/StatsPlugin.py b/plugins/Stats/StatsPlugin.py index 518b5ec8..f58436cb 100644 --- a/plugins/Stats/StatsPlugin.py +++ b/plugins/Stats/StatsPlugin.py @@ -67,7 +67,7 @@ class UiRequestPlugin(object): # Memory yield "rev%s | " % config.rev - yield "%s | " % config.ip_external + yield "%s | " % main.file_server.ip_external_list yield "Port: %s | " % main.file_server.port yield "IP Network: %s | " % main.file_server.supported_ip_types yield "Opened: %s | " % main.file_server.port_opened diff --git a/plugins/Trayicon/TrayiconPlugin.py b/plugins/Trayicon/TrayiconPlugin.py index 3eed2f26..e32b5a6a 100644 --- a/plugins/Trayicon/TrayiconPlugin.py +++ b/plugins/Trayicon/TrayiconPlugin.py @@ -83,8 +83,8 @@ class ActionsPlugin(object): webbrowser.open(url, new=0) def titleIp(self): - title = "!IP: %s " % config.ip_external - if self.main.file_server.port_opened: + title = "!IP: %s " % ", ".join(self.main.file_server.ip_external_list) + if any(self.main.file_server.port_opened): title += _["(active)"] else: title += _["(passive)"] diff --git a/src/File/FileServer.py b/src/File/FileServer.py index 514d2a8c..8867c883 100644 --- a/src/File/FileServer.py +++ b/src/File/FileServer.py @@ -26,6 +26,7 @@ class FileServer(ConnectionServer): self.portchecker = PeerPortchecker.PeerPortchecker(self) self.log = logging.getLogger("FileServer") self.ip_type = ip_type + self.ip_external_list = [] self.supported_ip_types = ["ipv4"] # Outgoing ip_type support if helper.getIpType(ip) == "ipv6" or self.isIpv6Supported(): @@ -156,6 +157,7 @@ class FileServer(ConnectionServer): "ipv4": "ipv4" in ip_external_types, "ipv6": "ipv6" in ip_external_types } + self.ip_external_list = config.ip_external self.port_opened.update(res) self.log.info("Server port opened based on configuration ipv4: %s, ipv6: %s" % (res["ipv4"], res["ipv6"])) return res @@ -182,10 +184,10 @@ class FileServer(ConnectionServer): self.log.info("Invalid IPv6 address from port check: %s" % res_ipv6["ip"]) res_ipv6["opened"] = False - config.ip_external = [] + self.ip_external_list = [] for res_ip in [res_ipv4, res_ipv6]: - if res_ip["ip"] and res_ip["ip"] not in config.ip_external: - config.ip_external.append(res_ip["ip"]) + if res_ip["ip"] and res_ip["ip"] not in self.ip_external_list: + self.ip_external_list.append(res_ip["ip"]) SiteManager.peer_blacklist.append((res_ip["ip"], self.port)) self.log.info("Server port opened ipv4: %s, ipv6: %s" % (res_ipv4["opened"], res_ipv6["opened"]))