From bc9012e8b53187ace942c3352125b0fbe169d71c Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 10 May 2022 16:31:12 +0800 Subject: [PATCH] bugfix --- appPublic/across_nat.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/appPublic/across_nat.py b/appPublic/across_nat.py index 2ae86b4..b045ec6 100644 --- a/appPublic/across_nat.py +++ b/appPublic/across_nat.py @@ -32,16 +32,26 @@ class AcrossNat(object): def get_external_ip(self): if self.pmp_supported: - self.external_ip = pmp.get_public_address() - return self.external_ip + try: + self.external_ip = pmp.get_public_address() + return self.external_ip + except: + self.pmp_supported = False if self.upnp_supported: - x = self.upnp.GetExternalIPAddress() - return x['NewExternalIPAddress'] + try: + x = self.upnp.GetExternalIPAddress() + return x['NewExternalIPAddress'] + except: + self.upnp_supported = False try: return get('https://api.ipify.org').text except: + pass + try: return get('https://ipapi.co/ip/').text + except: + return None def upnp_check_external_port(self, eport, protocol='TCP'): try: