Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Visit https://www.duckdns.org for more information.
- It's a free dyndns service with easy registration.
- """
- from urllib.request import urlopen
- def update(token, *domains, ip=""):
- """
- The token and at least one domain is required for update.
- The IP is optional. If the IP is not given, duckdns.org
- uses the IP from the request source IP, which is your host.
- """
- url = "https://www.duckdns.org/update"
- query = {
- "domains": ",".join(domains),
- "token": token,
- "ip": ip,
- }
- url += "?" + "&".join(f"{key}={val}" for key, val in query.items())
- try:
- req = urlopen(url, timeout=10)
- except Exception as e:
- print(repr(e))
- return False
- if req.status == 200 and req.read() == b"OK":
- return True
- else:
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement