bugfix
This commit is contained in:
parent
9b4fb8c138
commit
1066e2250f
11
appPublic/uni_outip.py
Normal file → Executable file
11
appPublic/uni_outip.py
Normal file → Executable file
@ -6,23 +6,32 @@ from appPublic.ipgetter import IPgetter
|
|||||||
from multiprocessing import Process, Pipe
|
from multiprocessing import Process, Pipe
|
||||||
|
|
||||||
def pmp_get_external_ip():
|
def pmp_get_external_ip():
|
||||||
|
try:
|
||||||
return pmp.get_public_address()
|
return pmp.get_public_address()
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
def upnp_get_external_ip():
|
def upnp_get_external_ip():
|
||||||
|
try:
|
||||||
igd = upnpclient.discover()[0]
|
igd = upnpclient.discover()[0]
|
||||||
s_names = [ n for n in igd.service_map.keys() if 'WAN' in n and 'Conn' in n]
|
s_names = [ n for n in igd.service_map.keys() if 'WAN' in n and 'Conn' in n]
|
||||||
upnp = igd.service_map[s_names[0]]
|
upnp = igd.service_map[s_names[0]]
|
||||||
x = upnp.GetExternalIPAddress()
|
x = upnp.GetExternalIPAddress()
|
||||||
return x.get('NewExternalIPAddress', None)
|
return x.get('NewExternalIPAddress', None)
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
def ipgetter_get_external_ip():
|
def ipgetter_get_external_ip():
|
||||||
getter = IPgetter()
|
getter = IPgetter()
|
||||||
ip = None
|
ip = None
|
||||||
while ip is None:
|
while ip is None:
|
||||||
|
try:
|
||||||
ip = getter.get_external_ip()
|
ip = getter.get_external_ip()
|
||||||
|
except:
|
||||||
|
ip = None
|
||||||
if ip:
|
if ip:
|
||||||
return ip
|
return ip
|
||||||
time.sleep(0.5)
|
time.sleep(0.1)
|
||||||
|
|
||||||
def get_external_ip():
|
def get_external_ip():
|
||||||
ip = pmp_get_external_ip()
|
ip = pmp_get_external_ip()
|
||||||
|
Loading…
Reference in New Issue
Block a user