Skip to content

Commit ab84264

Browse files
WillowSauceRWillowSauceR
authored andcommitted
support resolve hostname
1 parent f08f46d commit ab84264

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ def log(*content, level: str = "INFO", info: str = "", quiet: bool = False):
3535
print(f"[{date}] {content}")
3636

3737

38-
def get_ip_list(ip: str):
38+
def get_ip_list(addr: str):
3939
# ip = "42.186.0-255.0-255" -> len(ip_list) == 65536
40+
try:
41+
int(addr[-1])
42+
except:
43+
return [socket.gethostbyname(addr)]
4044
ip_list = []
4145
processed_ip_segs = [[], [], [], []]
4246
ip_seg_index = 0
43-
ip_segs = ip.split(".") # 42.186.0-255.0-255 -> [42, 186, 0-255, 0-255]
47+
ip_segs = addr.split(".") # 42.186.0-255.0-255 -> [42, 186, 0-255, 0-255]
4448
for ip_seg in ip_segs:
4549
if "-" in ip_seg:
4650
seg_list = ip_seg.split("-") # 0-255 -> [0, 255]

0 commit comments

Comments
 (0)