Skip to content

Commit

Permalink
API Changed
Browse files Browse the repository at this point in the history
  • Loading branch information
bigsk05 committed May 16, 2023
1 parent 0e68814 commit e6f1a0b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
import time
import threading
import json
import threading

import requests

Expand All @@ -14,8 +15,8 @@ def __init__(self,
id, secret,
sleep = 600,
ipv4 = True, ipv6 = True,
v4api = "https://ipv4.gh.ink",
v6api = "https://ipv6.gh.ink"):
v4api = "http://ipv4.ipv6-test.ch/ip/",
v6api = "http://ipv6.ipv6-test.ch/ip"):

assert domain.count(".") == 1 and \
not domain.startswith(".") and \
Expand All @@ -28,6 +29,8 @@ def __init__(self,
self.ipv6 = ipv6
self.v4api = v4api
self.v6api = v6api
self.v4re = re.compile(r"(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))")
self.v6re = re.compile(r"(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))")

self.__client = AcsClient(id, secret, 'cn-hangzhou')

Expand All @@ -44,7 +47,7 @@ def refresh(self):
# Get local public ipv4 address
if self.ipv4:
try:
self.__v4 = requests.get(self.v4api).text
self.__v4 = re.search(self.v4re, requests.get(self.v4api).text).group(0)
except Exception as e:
print("Failed to get local public ipv4 address,", e)
else:
Expand Down Expand Up @@ -83,7 +86,7 @@ def refresh(self):
# Get local public ipv6 address
if self.ipv6:
try:
self.__v6 = requests.get(self.v6api).text
self.__v6 = re.search(self.v6re, requests.get(self.v6api).text).group(0)
except Exception as e:
print("Failed to get local public ipv6 address,", e)
else:
Expand Down

0 comments on commit e6f1a0b

Please sign in to comment.