diff options
author | Marius Halden <marius.h@lden.org> | 2014-03-17 04:16:49 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2014-03-17 04:16:49 +0100 |
commit | 7c575aaa8e98a6aa7eda8d69e2b14d014ee91b09 (patch) | |
tree | 7bd082fd216e1577440cf1ea599467993c2fef36 /ddns/frontend | |
download | DDNS.py-7c575aaa8e98a6aa7eda8d69e2b14d014ee91b09.tar.gz DDNS.py-7c575aaa8e98a6aa7eda8d69e2b14d014ee91b09.tar.bz2 DDNS.py-7c575aaa8e98a6aa7eda8d69e2b14d014ee91b09.tar.xz |
Initial commit
Diffstat (limited to 'ddns/frontend')
-rw-r--r-- | ddns/frontend/__init__.py | 0 | ||||
-rw-r--r-- | ddns/frontend/dyn_com.py | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/ddns/frontend/__init__.py b/ddns/frontend/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/ddns/frontend/__init__.py diff --git a/ddns/frontend/dyn_com.py b/ddns/frontend/dyn_com.py new file mode 100644 index 0000000..bbd61e5 --- /dev/null +++ b/ddns/frontend/dyn_com.py @@ -0,0 +1,47 @@ +from flask import request, Response +import ddns.backend.dnsupdate +from IPy import IP +import ddns.auth +import ddns.cfg_parser + +@ddns.auth.require_auth +def dyn_com(): + if request.method != 'GET': + return "badagent" + + if not request.args.has_key('hostname'): + return "nohost" + + if len(request.args.getlist('hostname')) > 1: + return "numhost" + + if not request.args.has_key('myip'): + return "nohost" + + hostname = request.args.get('hostname') + if not '.' in hostname: + return "notfqdn" + + zone_name = hostname[hostname.find('.')+1:] + if zone_name[-1] != '.': + zone_name += '.' + + hostname = hostname[0:hostname.find('.')] + + try: + ip = IP(request.args.get('myip')) + except ValueError: + return "nohost" + + for zone in ddns.cfg_parser.cfg['zones']: + if zone_name == zone['name']: + for domain in zone['domains']: + if domain['domain'] == hostname: + for user in domain['users']: + if request.authorization.username == user['username']: + ddns.backend.dnsupdate.update_dns(zone_name, hostname, ip) + # We should probably check something here... + return "good" + return auth.authenticate("!yours") + return "nohost" + return "nohost" |