mirror of
https://github.com/NewFuture/DDNS.git
synced 2022-04-19 20:24:44 +00:00
remove duplicate functions
This commit is contained in:
+2
-13
@@ -16,7 +16,7 @@ IPV4_REG = r'((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1
|
||||
# IPV6正则
|
||||
# https://community.helpsystems.com/forums/intermapper/miscellaneous-topics/5acc4fcf-fa83-e511-80cf-0050568460e4
|
||||
IPV6_REG = r'((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))'
|
||||
|
||||
|
||||
|
||||
def default_v4(): # 默认连接外网的ipv4
|
||||
s = socket(AF_INET, SOCK_DGRAM)
|
||||
@@ -28,7 +28,7 @@ def default_v4(): # 默认连接外网的ipv4
|
||||
|
||||
def default_v6(): # 默认连接外网的ipv6
|
||||
s = socket(AF_INET6, SOCK_DGRAM)
|
||||
s.connect(('8:8:8:8:8:8:8:8', 8))
|
||||
s.connect(('1:1:1:1:1:1:1:1', 8))
|
||||
ip = s.getsockname()[0]
|
||||
s.close()
|
||||
return ip
|
||||
@@ -40,17 +40,6 @@ def local_v6(i=0): # 本地ipv6地址
|
||||
return info[int(i)][4][0]
|
||||
|
||||
|
||||
def local_v4(i=0): # 本地ipv4地址
|
||||
info = getaddrinfo(gethostname(), 0, AF_INET)
|
||||
debug(info)
|
||||
return info[int(i)][-1][0]
|
||||
|
||||
def local_v6(i=0): # 本地ipv6地址
|
||||
info = getaddrinfo(gethostname(), 0, AF_INET6)
|
||||
debug(info)
|
||||
return info[int(i)][4][0]
|
||||
|
||||
|
||||
def local_v4(i=0): # 本地ipv4地址
|
||||
info = getaddrinfo(gethostname(), 0, AF_INET)
|
||||
debug(info)
|
||||
|
||||
Reference in New Issue
Block a user