From 3ba2ecedce6f82aecb26243bc4259665a904ee13 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Mon, 7 Nov 2016 22:36:14 +0100 Subject: [PATCH] Only try to close upnp opened port if necessary --- src/File/FileServer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/File/FileServer.py b/src/File/FileServer.py index 8faf9c63..5449ad9f 100644 --- a/src/File/FileServer.py +++ b/src/File/FileServer.py @@ -24,6 +24,7 @@ class FileServer(ConnectionServer): SiteManager.peer_blacklist.append((config.ip_external, self.port)) # Add myself to peer blacklist else: self.port_opened = None # Is file server opened on router + self.upnp_port_opened = False self.sites = {} self.last_request = time.time() self.files_parsing = {} @@ -77,6 +78,7 @@ class FileServer(ConnectionServer): return False if self.testOpenport(port)["result"] is True: + self.upnp_port_opened = True return True self.log.info("Upnp mapping failed :( Please forward port %s on your router to your ipaddress" % port) @@ -276,7 +278,7 @@ class FileServer(ConnectionServer): self.log.debug("Stopped.") def stop(self): - if self.running and self.port_opened: + if self.running and self.upnp_port_opened: self.log.debug('Closing port %d' % self.port) try: UpnpPunch.ask_to_close_port(self.port, protos=["TCP"])