aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdnsutil-update.csh8
-rw-r--r--pdnsutil-update.sh14
-rw-r--r--wsgi.py22
3 files changed, 34 insertions, 10 deletions
diff --git a/pdnsutil-update.csh b/pdnsutil-update.csh
new file mode 100644
index 0000000..8cc00d1
--- /dev/null
+++ b/pdnsutil-update.csh
@@ -0,0 +1,8 @@
1#!/bin/csh
2set host=$1
3shift
4pdnsutil delete-rrset wire-me.de $host A
5foreach ip ($*)
6 echo "Adding $ip to $host"
7 pdnsutil add-record wire-me.de $host A $ip
8end
diff --git a/pdnsutil-update.sh b/pdnsutil-update.sh
new file mode 100644
index 0000000..6f46279
--- /dev/null
+++ b/pdnsutil-update.sh
@@ -0,0 +1,14 @@
1#!/bin/sh
2
3zone=$1
4shift
5host=$1
6shift
7
8set -x
9pdnsutil delete-rrset $zone $host A
10for ip in "$@"
11do
12 echo " Adding $ip"
13 pdnsutil add-record $zone $host A $ip
14done
diff --git a/wsgi.py b/wsgi.py
index 49224b9..cfa1326 100644
--- a/wsgi.py
+++ b/wsgi.py
@@ -1,19 +1,21 @@
1#!/usr/bin/env python3.6 1#!/usr/bin/env python3.6
2
3import time 2import time
4import re 3import re
5import subprocess 4import subprocess
6from cgi import parse_qs 5from cgi import parse_qs
7 6
8def application(environ, start_response): 7zone = "wire-me.de"
9 d = parse_qs(environ['QUERY_STRING'])
10 8
9def application(environ, start_response):
11 start_response('200 OK', [('Content-Type', 'text/plain')]) 10 start_response('200 OK', [('Content-Type', 'text/plain')])
12 if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', d.get('ip', ['0'])[0]): 11 args = parse_qs(environ['QUERY_STRING'])
13 ip = d.get('ip', ['0'])[0].encode() 12 host = args.get('host', ['0'])[0]
14 if re.match('[0-9a-z]+', d.get('host', [''])[0]): 13
15 host = d.get('host', ['0'])[0].encode() 14 if re.match('[0-9a-z-_]+', host):
16 yield(subprocess.run(["/usr/local/bin/pdnsutil", "delete-rrset", "wire-me.de", host, "A"], stdout=subprocess.PIPE).stdout) 15 yield(subprocess.run(["/usr/local/bin/pdnsutil", "delete-rrset", zone, host, "A"], stdout=subprocess.PIPE).stdout)
17 yield(subprocess.run(["/usr/local/bin/pdnsutil", "add-record", "wire-me.de", host, "A", ip], stdout=subprocess.PIPE)) 16
18 yield(subprocess.run(["/usr/local/bin/pdnsutil", "list-zone", "wire-me.de"], stdout=subprocess.PIPE).stdout) 17 for ip in args.get('ip', ['0']):
18 if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip):
19 yield(subprocess.run(["/usr/local/bin/pdnsutil", "add-record", zone, host, "A", ip], stdout=subprocess.PIPE))
19 20
21 yield(subprocess.run(["/usr/local/bin/pdnsutil", "list-zone", zone], stdout=subprocess.PIPE).stdout)
..