Skip to content

Commit c2e8eb5

Browse files
authored
Update start.py
1 parent 22e89cc commit c2e8eb5

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

start.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,9 @@
5454
with open(__dir__ / "config.json") as f:
5555
con = load(f)
5656

57-
def getMyIPAddress():
58-
global __ip__
59-
if __ip__:
60-
return __ip__
61-
with suppress(Exception):
62-
return get('https://api.my-ip.io/ip', timeout=.1).text
63-
with suppress(Exception):
64-
return get('https://ipwhois.app/json/', timeout=.1).json()["ip"]
65-
with suppress(Exception):
66-
return get('https://ipinfo.io/json', timeout=.1).json()["ip"]
67-
with suppress(Exception):
68-
return ProxyTools.Patterns.IP.search(get('http://checkip.dyndns.org/', timeout=.1).text)
69-
with suppress(Exception):
70-
return ProxyTools.Patterns.IP.search(get('https://spaceiran.com/myip/', timeout=.1).text)
71-
with suppress(Exception):
72-
return get('https://ip.42.pl/raw', timeout=.1).text
73-
return getMyIPAddress()
57+
with socket(AF_INET, SOCK_DGRAM) as s:
58+
s.connect(("8.8.8.8", 80))
59+
__ip__ = s.getsockname()[0]
7460

7561

7662
class bcolors:

0 commit comments

Comments
 (0)