This commit is contained in:
yumoqing 2022-05-10 16:31:12 +08:00
parent 2d22940819
commit bc9012e8b5

View File

@ -32,16 +32,26 @@ class AcrossNat(object):
def get_external_ip(self):
if self.pmp_supported:
try:
self.external_ip = pmp.get_public_address()
return self.external_ip
except:
self.pmp_supported = False
if self.upnp_supported:
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: