#!/usr/bin/env python3.6 import time import re import subprocess from cgi import parse_qs def application(environ, start_response): d = parse_qs(environ['QUERY_STRING']) start_response('200 OK', [('Content-Type', 'text/plain')]) if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', d.get('ip', ['0'])[0]): ip = d.get('ip', ['0'])[0].encode() if re.match('[0-9a-z]+', d.get('host', [''])[0]): host = d.get('host', ['0'])[0].encode() yield(subprocess.run(["/usr/local/bin/pdnsutil", "delete-rrset", "wire-me.de", host, "A"], stdout=subprocess.PIPE).stdout) yield(subprocess.run(["/usr/local/bin/pdnsutil", "add-record", "wire-me.de", host, "A", ip], stdout=subprocess.PIPE)) yield(subprocess.run(["/usr/local/bin/pdnsutil", "list-zone", "wire-me.de"], stdout=subprocess.PIPE).stdout)