37 líneas
708 B
Python
37 líneas
708 B
Python
from dynuapi import Dynu
|
|
import requests
|
|
import json
|
|
import pdb
|
|
|
|
def get():
|
|
endpoint = 'https://ipinfo.io/json'
|
|
response = requests.get(endpoint, verify = True)
|
|
|
|
if response.status_code != 200:
|
|
return 'Status:', response.status_code, 'Problem with the request. Exiting.'
|
|
exit()
|
|
|
|
data = response.json()
|
|
|
|
return data['ip']
|
|
|
|
if __name__ == '__main__':
|
|
|
|
obj = Dynu()
|
|
|
|
result = obj.dns()
|
|
|
|
domain_id = result.domains[0]['id']
|
|
|
|
domain_name = result.domains[0]['name']
|
|
|
|
group = 'Raspberry'
|
|
|
|
ipv4_address = get()
|
|
|
|
print(f"IP pública: {ipv4_address}")
|
|
|
|
is_updated = obj.update(domain_id, domain_name, group, ipv4_address)
|
|
|
|
print(is_updated)
|