diff options
-rw-r--r-- | ddns.wsgi (renamed from main.wsgi) | 0 | ||||
-rwxr-xr-x | ddns/main.py | 61 |
2 files changed, 0 insertions, 61 deletions
diff --git a/ddns/main.py b/ddns/main.py deleted file mode 100755 index 5ee6eaa..0000000 --- a/ddns/main.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python - -from flask import Flask, request, Response -import ddns -import cfg_parser -import auth -from IPy import IP - -cfg_file="/srv/http/lden.org/ddns/ddns/ddns.cfg" -cfg = cfg_parser.read_config(cfg_file) - -auth.auth_cfg = cfg['users'] -ddns.zone_cfg = cfg['zones'] -ddns.gen_keyring(cfg['dnskeys']) - -app = Flask(__name__) - -@app.route("/nic/update") -@auth.require_auth -def dyndns(): - 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 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.update_dns(zone_name, hostname, ip) - return "good" - return auth.authenticate("!yours") - return "nohost" - return "nohost" - -if __name__ == "__main__": - app.run(host="0.0.0.0", debug=True) |