update Code/ddns.py.

This commit is contained in:
Bigsk 2020-07-30 17:09:17 +08:00 committed by Gitee
parent 0c66cf9c0c
commit 0dbbd9f646

View File

@ -37,14 +37,20 @@ ipv6 = setload['IPV6']
#---------------------------------------------------------------------------------
if __name__ == '__main__':
v4api = 'http://v4.ipv6-test.com/api/myip.php'#Get IPV4 Address
v4 = requests.get(url=v4api) #IPV4 Address Variable"v4.text"
v4api = 'http://ipv4.test-ipv6.com/ip/?callback='#Get IPV4 Address
v4jsonback = requests.get(url=v4api).text #IPV4 Address Variable"v4.text"
v4json = v4jsonback.replace("(","").replace(")","")
v4json = json.loads(v4json)
v4, sep, tail = v4json['ip'].partition(',')
print("Your IPV4 Address:")
print(v4.text)
v6api = 'http://v6.ipv6-test.com/api/myip.php'#Get IPV6 Address
v6 = requests.get(url=v6api) #IPV6 Address Variable"v6.text"
print(v4)
v6api = 'http://ipv6.test-ipv6.com/ip/?callback='#Get IPV6 Address
v6jsonback = requests.get(url=v6api).text #IPV6 Address Variable"v6.text"
v6json = v6jsonback.replace("(","").replace(")","")
v6json = json.loads(v6json)
v6, sep, tail = v6json['ip'].partition(',')
print("Your IPV6 Address:")
print(v6.text)
print(v6)
#---------------------------------------------------------------------------------
@ -83,7 +89,7 @@ if ipv4 == 'true':#Judging whether IPV4 DDNS is open
#---------------------------------------------------------------------------------
if valuev4 == v4.text:#Judging whether IPV4 address has changed
if valuev4 == v4:#Judging whether IPV4 address has changed
#No Change
print('Your IPV4 Record is Right,Noting to do.')
@ -99,7 +105,7 @@ if ipv4 == 'true':#Judging whether IPV4 DDNS is open
updv4.set_accept_format('json')
updv4.set_RecordId(recordidv4)
updv4.set_Value(v4.text)#Set Domain Record From Machine's Internet IPV4 Address
updv4.set_Value(v4)#Set Domain Record From Machine's Internet IPV4 Address
updv4.set_Type("A")#Set Domain Record Type
updv4.set_RR(rr)#Set Domain Record RR
@ -143,7 +149,7 @@ if ipv6 == "true":#Judging whether IPV6 DDNS is open
#---------------------------------------------------------------------------------
if valuev6 == v6.text:#Judging whether IPV6 address has changed
if valuev6 == v6:#Judging whether IPV6 address has changed
#No Change
print('Your IPV6 Record is Right,Noting to do.')
@ -159,7 +165,7 @@ if ipv6 == "true":#Judging whether IPV6 DDNS is open
updv6.set_accept_format('json')
updv6.set_RecordId(recordidv6)
updv6.set_Value(v6.text)#Set Domain Record From Machine's Internet IPV6 Address
updv6.set_Value(v6)#Set Domain Record From Machine's Internet IPV6 Address
updv6.set_Type("AAAA")#Set Domain Record Type
updv6.set_RR(rr)#Set Domain Record RR