def main(): api_url, username, password = get_account_data(True) backup_files = get_nsbackup_files(True) if 'pickle_backup_file' in backup_files.keys(): from pickle import Pickler if 'json_backup_file' in backup_files.keys(): import json # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, 'en', False) # get the list of all domains: domains = inwx_conn.nameserver.list()['domains'] # get all the nameserver entries for each domain current, total = 0, len(domains) nsentries = dict() for domain in domains: current += 1 domain = domain['domain'] print "%i of %i - Currently backing up %s." % (current, total, domain) nsentries[domain] = inwx_conn.nameserver.info({'domain': domain})['record'] if 'pickle_backup_file' in backup_files.keys(): Pickler(open(backup_files['pickle_backup_file'],'wb')).dump(nsentries) print "Wrote backup file using Python Module Pickle : %s." % backup_files['pickle_backup_file'] if 'json_backup_file' in backup_files.keys(): json.dump(nsentries, open(backup_files['json_backup_file'], 'w')) print "Wrote backup file using Python Module JSON: %s." % backup_files['json_backup_file']
def main(): api_url, username, password = get_account_data(True) invoices_folder = get_invoices_folder(True) # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, 'en', False) # get the list of all invoices up to now invoices = inwx_conn.accounting.listInvoices() # download each invoice (if not already downloaded) current, total = 0, invoices['count'] if total > 0: print "Saving the %i invoices to %s" % (total, invoices_folder) for invoice in invoices['invoice']: current += 1 id = invoice['invoiceId'] date = invoice['date'] amount_after_tax = invoice['afterTax'] amount_before_tax = invoice['preTax'] type = invoice['type'] filename = "%s_%.2f_%s.pdf" % (date, amount_before_tax, id) full_path = invoices_folder + '/' + filename if isfile(full_path): print "%i of %i - Invoice %s (%s) already downloaded and saved to %s" % (current, total, id, date, filename) else: print "%i of %i - Currently fetching invoice %s (%s) and saving to %s..." % (current, total, id, date, filename) invoice_data = inwx_conn.accounting.getInvoice({'invoiceid': id}) with open(full_path, "wb") as handle: handle.write(invoice_data['pdf'].data)
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.contacts(inwx_conn.contact.list()['contact']) print prettyprint.nameserversets(inwx_conn.nameserverset.list()['nsset']) print "\nRegister a new domain\n" domainname = raw_input('New Domain [e.g. example.com]: ') check = inwx_conn.domain.check({'domain': domainname}) if check['domain'][0]['status'] == 'free': if raw_input( "The domain %s is available. Do you want to register now? [yes/no]: " % domainname) != 'yes': return registrant_id = int( raw_input( 'Please give the ID for the registrant and admin contact [e.g. 1023532]: ' )) admin_id = registrant_id tech_id, billing_id = 1, 1 nameservers = ['ns.inwx.de', 'ns2.inwx.de', 'ns3.inwx.de'] reg_result = inwx_conn.domain.create({ 'domain': domainname, 'registrant': registrant_id, 'admin': admin_id, 'tech': tech_id, 'billing': billing_id, 'ns': nameservers }) if reg_result == None: print "Successfully registered the domain." else: print "Sorry, the domain %s is not available anymore." % domainname print "The current status of the domain is '%s'." % check['domain'][0][ 'status']
def main(): api_url, username, password = get_account_data(True) domain, subdomain, _ = get_domain_update(True) # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, 'en', False) nsentries = inwx_conn.nameserver.info({'domain': domain}) # Filter entries for subdomain nsentries = [ record for record in nsentries['record'] if subdomain == record['name'] ] assert nsentries, "Subdomain %s not in list of nameserver entries." % subdomain # There may be multiple entries for one subdomain, one for each type (A, AAAA, ...) for record in nsentries: record_type = record['type'] # A, AAAA assert record_type in record_type_to_api, "Unsupported record type: %s" % record_type new_ip = get_ip(record_type_to_api[record_type]) if new_ip: print "Updating %s record of %s from %s to %s" % ( record_type, record['name'], record['content'], new_ip) inwx_conn.nameserver.updateRecord({ 'id': record['id'], 'content': new_ip, 'ttl': 3600 })
def update_dns(new_ip): record_types = ['A', 'AAAA'] api_url, username, password = get_account_data(True, config_file) domain, subdomain, _ = get_domain_update(True, config_file) # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, 'en', False) nsentries = inwx_conn.nameserver.info({'domain': domain}) # Filter entries for subdomain records = [record for record in nsentries['record'] if subdomain == record['name']] if not records: status = "404 Failed" return "Subdomain {0} not in list of nameserver entries".format(subdomain), status for record in records: record_type = record['type'] if record_type not in record_types: status = "404 Failed" return "Unsupported record type: {0}".format(record_type), status if new_ip != record['content']: try: inwx_conn.nameserver.updateRecord({'id': record['id'], 'content': new_ip, 'ttl': 3600}) status = "200 OK" return "Updating record {0} from {1} to {2}".format(record['name'], record['content'], new_ip), status except Exception as e: status = "404 Failed" return "Failed {0} record of {1} from {2} to {3}::::{4}".format(record_type, record['name'], record['content'], new_ip, e.message), status else: status = "200 OK" return "Same IP", status
def main(): api_url, username, password = get_account_data(True) invoices_folder = get_invoices_folder(True) # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, 'en', False) # get the list of all invoices up to now invoices = inwx_conn.accounting.listInvoices() # download each invoice (if not already downloaded) current, total = 0, invoices['count'] if total > 0: print "Saving the %i invoices to %s" % (total, invoices_folder) for invoice in invoices['invoice']: current += 1 id = invoice['invoiceId'] date = invoice['date'] amount_after_tax = invoice['afterTax'] amount_before_tax = invoice['preTax'] type = invoice['type'] filename = "%s_%.2f_%s.pdf" % (date, amount_before_tax, id) full_path = invoices_folder + '/' + filename if isfile(full_path): print "%i of %i - Invoice %s (%s) already downloaded and saved to %s" % ( current, total, id, date, filename) else: print "%i of %i - Currently fetching invoice %s (%s) and saving to %s..." % ( current, total, id, date, filename) invoice_data = inwx_conn.accounting.getInvoice({'invoiceid': id}) with open(full_path, "wb") as handle: handle.write(invoice_data['pdf'].data)
def main(): api_url, username, password = get_account_data(True) backup_files = get_nsbackup_files(True) if 'pickle_backup_file' in backup_files.keys(): from pickle import Pickler if 'json_backup_file' in backup_files.keys(): import json # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, 'en', False) # get the list of all domains: domains = inwx_conn.nameserver.list()['domains'] # get all the nameserver entries for each domain current, total = 0, len(domains) nsentries = dict() for domain in domains: current += 1 domain = domain['domain'] print "%i of %i - Currently backing up %s." % (current, total, domain) nsentries[domain] = inwx_conn.nameserver.info({'domain': domain})['record'] if 'pickle_backup_file' in backup_files.keys(): Pickler(open(backup_files['pickle_backup_file'], 'wb')).dump(nsentries) print "Wrote backup file using Python Module Pickle : %s." % backup_files[ 'pickle_backup_file'] if 'json_backup_file' in backup_files.keys(): json.dump(nsentries, open(backup_files['json_backup_file'], 'w')) print "Wrote backup file using Python Module JSON: %s." % backup_files[ 'json_backup_file']
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, False) loginRet = inwx_conn.account.login({'lang': 'en', 'user': username, 'pass': password}) domain = "mydomain.com" checkRet = inwx_conn.domain.check({'domain': domain}) print prettyprint.domain_check(checkRet)
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.domains(inwx_conn.nameserver.list()['domains']) # get the list of all domains: domains = inwx_conn.nameserver.list()['domains'] for domain in domains: domain = domain['domain'] print "Logs for domain %s:" % domain print prettyprint.domain_log(inwx_conn.domain.log({'domain': domain})['domain'])
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.contacts(inwx_conn.contact.list()['contact']) print "\nCreate a new contact\n" type = raw_input('Type [PERSON, ORG or ROLE]: ') name = raw_input('Prename and Surname: ') street, city, postal_code, country_code = raw_input('Street: '), raw_input('City: '), raw_input('Postal Code [60438]: '), raw_input('Country Code [de]: ') phone, email = raw_input('Phone [+49.123123123]: '), raw_input('E-Mail: ') print inwx_conn.contact.create({'type': type, 'name': name, 'street': street, 'city': city, 'pc': postal_code, 'cc': country_code, 'voice': phone, 'email': email})
def main(): api_url, username, password, shared_secret = get_account_data(True) inwx_conn = domrobot(api_url, False) loginRet = inwx_conn.account.login({'lang': 'en', 'user': username, 'pass': password}) if 'tfa' in loginRet and loginRet['tfa'] == 'GOOGLE-AUTH': loginRet = inwx_conn.account.unlock({'tan': getOTP(shared_secret)}) domain = "mydomain.com" checkRet = inwx_conn.domain.check({'domain': domain}) print(prettyprint.domain_check(checkRet))
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.domains(inwx_conn.nameserver.list()['domains']) # get the list of all domains: domains = inwx_conn.nameserver.list()['domains'] for domain in domains: domain = domain['domain'] print "Logs for domain %s:" % domain print prettyprint.domain_log( inwx_conn.domain.log({'domain': domain})['domain'])
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, False) loginRet = inwx_conn.account.login({ 'lang': 'en', 'user': username, 'pass': password }) domain = "mydomain.com" checkRet = inwx_conn.domain.check({'domain': domain}) print prettyprint.domain_check(checkRet)
def main(): api_url, username, password, shared_secret = get_account_data(True, config_section="live") inwx_conn = domrobot(api_url, True) loginRet = inwx_conn.account.login({'user': username, 'pass': password}) if 'resData' in loginRet: loginRet = loginRet['resData'] if 'tfa' in loginRet and loginRet['tfa'] == 'GOOGLE-AUTH': loginRet = inwx_conn.account.unlock({'tan': getOTP(shared_secret)}) domain = "tonihds.de" checkRet = inwx_conn.domain.check({'domain': domain}) print((prettyprint.domain_check(checkRet)))
def main(): api_url, username, password, shared_secret = get_account_data(True, "config.cfg", "live") inwx_conn = domrobot(api_url, False) loginRet = inwx_conn.account.login({'lang': 'en', 'user': username, 'pass': password}) if 'resData' in loginRet: loginRet = loginRet['resData'] if 'tfa' in loginRet and loginRet['tfa'] == 'GOOGLE-AUTH': loginRet = inwx_conn.account.unlock({'tan': getOTP(shared_secret)}) page = 1 pageLimit = 20 runLoop = True while runLoop: print("Page: "+str(page)) domainList = inwx_conn.domain.list({'page': page, 'pagelimit': pageLimit}) if(pageLimit * page < domainList["resData"]["count"] ): page = page + 1 else: runLoop = False print(domainList) for domain in domainList["resData"]["domain"]: reDate = dateutil.parser.parse(str(domain["reDate"])) upDate = dateutil.parser.parse(str(domain["upDate"])) preReData = (reDate - datetime.timedelta(days = 5)) event = Event() event.add('summary', 'REMINDER! Domain Renewal '+domain["domain"]) event.add('dtstart', preReData) event.add('dtend', (preReData + datetime.timedelta(minutes = 10))) event.add('dtstamp', upDate) cal.add_component(event) event = Event() event.add('summary', 'Domain Renewal '+domain["domain"]) event.add('dtstart', reDate) event.add('dtend', (reDate + datetime.timedelta(minutes = 10))) event.add('dtstamp', upDate) cal.add_component(event) f = open('domains.ical', 'wb') f.write(cal.to_ical()) f.close()
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.contacts(inwx_conn.contact.list()['contact']) print prettyprint.nameserversets(inwx_conn.nameserverset.list()['nsset']) print "\nRegister a new domain\n" domainname = raw_input('New Domain [e.g. example.com]: ') check = inwx_conn.domain.check({'domain': domainname}) if check['domain'][0]['status'] == 'free': if raw_input("The domain %s is available. Do you want to register now? [yes/no]: " % domainname) != 'yes': return registrant_id = int(raw_input('Please give the ID for the registrant and admin contact [e.g. 1023532]: ')) admin_id = registrant_id tech_id, billing_id = 1,1 nameservers = ['ns.inwx.de','ns2.inwx.de','ns3.inwx.de'] reg_result = inwx_conn.domain.create({'domain':domainname, 'registrant': registrant_id, 'admin': admin_id, 'tech': tech_id, 'billing': billing_id, 'ns': nameservers}) if reg_result == None: print "Successfully registered the domain." else: print "Sorry, the domain %s is not available anymore." % domainname print "The current status of the domain is '%s'." % check['domain'][0]['status']
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.contacts(inwx_conn.contact.list()['contact']) print "\nCreate a new contact\n" type = raw_input('Type [PERSON, ORG or ROLE]: ') name = raw_input('Prename and Surname: ') street, city, postal_code, country_code = raw_input('Street: '), raw_input( 'City: '), raw_input('Postal Code [60438]: '), raw_input( 'Country Code [de]: ') phone, email = raw_input('Phone [+49.123123123]: '), raw_input('E-Mail: ') print inwx_conn.contact.create({ 'type': type, 'name': name, 'street': street, 'city': city, 'pc': postal_code, 'cc': country_code, 'voice': phone, 'email': email })
def main(): api_url, username, password, shared_secret = get_account_data( True, config_section="live") inwx_conn = domrobot(api_url, True) loginRet = inwx_conn.account.login({'user': username, 'pass': password}) if 'resData' in loginRet: loginRet = loginRet['resData'] if 'tfa' in loginRet and loginRet['tfa'] == 'GOOGLE-AUTH': loginRet = inwx_conn.account.unlock({'tan': getOTP(shared_secret)}) domain = "tonihds.de" ip = requests.get('https://api.ipify.org').text checkRet = inwx_conn.domain.check({'domain': domain}) nameserv_info = inwx_conn.nameserver.info({'domain': domain}) #add checks inwx_conn.nameserver.updateRecord({ 'id': '289183459', 'type': 'A', 'content': ip })
def main(): api_url, username, password = get_account_data(True) domain, subdomain, _ = get_domain_update(True) # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, "en", False) nsentries = inwx_conn.nameserver.info({"domain": domain}) # Filter entries for subdomain nsentries = [record for record in nsentries["record"] if subdomain == record["name"]] assert nsentries, "Subdomain %s not in list of nameserver entries." % subdomain # There may be multiple entries for one subdomain, one for each type (A, AAAA, ...) for record in nsentries: record_type = record["type"] # A, AAAA assert record_type in record_type_to_api, "Unsupported record type: %s" % record_type new_ip = get_ip(record_type_to_api[record_type]) if new_ip: print "Updating %s record of %s from %s to %s" % (record_type, record["name"], record["content"], new_ip) inwx_conn.nameserver.updateRecord({"id": record["id"], "content": new_ip, "ttl": 3600})
def main(): api_url, username, password = get_account_data(True) domain, subdomain, default_ip = get_domain_update(True) try: new_ip = urlopen(IPV6_DETECTION_API).read().decode('ascii') except: # If something failed with the IPv6 detection, we may abort at this point return # or simply set the default value: new_ip = default_ip # Instantiate the inwx class (does not connect yet but dispatches calls to domrobot objects with the correct API URL inwx_conn = domrobot(api_url, username, password, 'en', False) # get all the nameserver entries for a certain domain nsentries = inwx_conn.nameserver.info({'domain': domain}) for record in nsentries['record']: if subdomain == record['name']: id = record['id'] break if id: print "Setting subdomain %s to the new IPv6 IP %s." % (subdomain, new_ip) inwx_conn.nameserver.updateRecord({'id':id,'content':new_ip,'ttl':3600}) else: print "Subdomain not in list of nameserver entries."
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.nameserversets(inwx_conn.nameserverset.list()['nsset'])
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.domains(inwx_conn.nameserver.list()['domains'])
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.domain_check(inwx_conn.domain.check({'domain': "klaus.bz"}))
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with inwx-dyndns. If not, see <http://www.gnu.org/licenses/>. # This is obviously heavily borrowed (almost everything is the same) from Philipp Klaus' python-inwx-xmlrpc. import os import time from inwx import domrobot from configuration import get_account_data, get_domain_update MINUTES = 15 while True: api_url, username, password = get_account_data(True) domain, subdomain, default_ip = get_domain_update(True) with open(os.environ.get("IPv4_PATH")) as f: new_ip = f.read() inwx_conn = domrobot(api_url, username, password, "en", False) nsentries = inwx_conn.nameserver.info({"domain": domain}) ids = [] for record in nsentries["record"]: if record["name"] in ["", "*"]: ids.append(record["id"]) for id_ in ids: print("Setting subdomain %s to the new IPv4 IP %s." % (subdomain, new_ip)) inwx_conn.nameserver.updateRecord({"id": id_, "content": new_ip, "ttl": 3600}) print(f"Going to sleep for {MINUTES} minutes") time.sleep(MINUTES * 60)
def main(): api_url, username, password = get_account_data(True) inwx_conn = domrobot(api_url, username, password, 'en', False) print prettyprint.domain_check( inwx_conn.domain.check({'domain': "klaus.bz"}))