bugfix
This commit is contained in:
parent
1801a8d467
commit
d6f9c636fd
@ -119,9 +119,9 @@ class IPgetter(object):
|
|||||||
|
|
||||||
random.shuffle(self.server_list)
|
random.shuffle(self.server_list)
|
||||||
myip = ''
|
myip = ''
|
||||||
for server in self.server_list[:3]:
|
for server in self.server_list:
|
||||||
myip = self.fetch(server)
|
myip = self.defaultparser(self.fetch(server))
|
||||||
if myip != '':
|
if myip != '' and not (myip.startswith('192.') or myip.startswith('10.')) and not myip.startswith('127'):
|
||||||
return myip
|
return myip
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
@ -135,14 +135,15 @@ class IPgetter(object):
|
|||||||
p = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.('
|
p = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.('
|
||||||
p += '25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|['
|
p += '25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|['
|
||||||
p += '01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
|
p += '01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
|
||||||
m = re.search(
|
try:
|
||||||
p,
|
m = re.search(p, content)
|
||||||
content)
|
|
||||||
myip = m.group(0)
|
myip = m.group(0)
|
||||||
if len(myip) > 0:
|
if len(myip) > 0:
|
||||||
return myip
|
return myip
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
except:
|
||||||
|
return ''
|
||||||
|
|
||||||
def handle_timeout(self, url):
|
def handle_timeout(self, url):
|
||||||
if self.url is not None:
|
if self.url is not None:
|
||||||
@ -235,9 +236,4 @@ if __name__ == '__main__':
|
|||||||
g = IPgetter()
|
g = IPgetter()
|
||||||
server = 'http://ipinfo.io/json'
|
server = 'http://ipinfo.io/json'
|
||||||
g.add_server(server, p)
|
g.add_server(server, p)
|
||||||
print(g.fetch(server))
|
print(g.get_external_ip())
|
||||||
"""
|
|
||||||
while True:
|
|
||||||
print(myip())
|
|
||||||
time.sleep(0.5)
|
|
||||||
"""
|
|
||||||
|
Loading…
Reference in New Issue
Block a user