-def update_domain(server, domain, ipv4, ipv6, password, verbose):
- '''Update the given domain, using the server, password. ipv4 or ipv6 can be None to not update that record. Returns True on success, False on failure.'''
+def getResolver(server):
+ '''Return a resovler with the given server (defined by DNS name)'''
+ addr = socket.getaddrinfo(server, None, family=socket.AF_INET)
+ addr = addr[0][4][0]
+ res = dns.resolver.Resolver()
+ res.nameservers = [addr]
+ return res
+
+def getCurIP(domain, rtype, res):
+ '''Return the current IP of the given <domain>. <rtype> can be A or AAAA.'''
+ try:
+ return res.query(domain, rtype)[0].address
+ except dns.exception.DNSException: # domain not found
+ return ""
+
+def updateDomain(server, domain, ipv4, ipv6, password, config, verbose):
+ '''Update the given domain, using the server, password. ipv4 or ipv6 can be None to not update that record, or strings with the respective addresses.
+ Updates ae only performed if necessary.
+ Returns True on success, False on failure.'''