diff options
-rw-r--r-- | pdnsutil-update.csh | 8 | ||||
-rw-r--r-- | pdnsutil-update.sh | 14 | ||||
-rw-r--r-- | wsgi.py | 22 |
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 | ||
2 | set host=$1 | ||
3 | shift | ||
4 | pdnsutil delete-rrset wire-me.de $host A | ||
5 | foreach ip ($*) | ||
6 | echo "Adding $ip to $host" | ||
7 | pdnsutil add-record wire-me.de $host A $ip | ||
8 | end | ||
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 | |||
3 | zone=$1 | ||
4 | shift | ||
5 | host=$1 | ||
6 | shift | ||
7 | |||
8 | set -x | ||
9 | pdnsutil delete-rrset $zone $host A | ||
10 | for ip in "$@" | ||
11 | do | ||
12 | echo " Adding $ip" | ||
13 | pdnsutil add-record $zone $host A $ip | ||
14 | done | ||
@@ -1,19 +1,21 @@ | |||
1 | #!/usr/bin/env python3.6 | 1 | #!/usr/bin/env python3.6 |
2 | |||
3 | import time | 2 | import time |
4 | import re | 3 | import re |
5 | import subprocess | 4 | import subprocess |
6 | from cgi import parse_qs | 5 | from cgi import parse_qs |
7 | 6 | ||
8 | def application(environ, start_response): | 7 | zone = "wire-me.de" |
9 | d = parse_qs(environ['QUERY_STRING']) | ||
10 | 8 | ||
9 | def 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) | ||