From e3647a7063c54e68898c0cdfc0373c4804f0bfc5 Mon Sep 17 00:00:00 2001 From: Marius Halden Date: Mon, 17 Mar 2014 04:18:38 +0100 Subject: - --- ddns.wsgi | 4 ++++ ddns/main.py | 61 ------------------------------------------------------------ main.wsgi | 4 ---- 3 files changed, 4 insertions(+), 65 deletions(-) create mode 100644 ddns.wsgi delete mode 100755 ddns/main.py delete mode 100644 main.wsgi diff --git a/ddns.wsgi b/ddns.wsgi new file mode 100644 index 0000000..9e5292c --- /dev/null +++ b/ddns.wsgi @@ -0,0 +1,4 @@ +#import sys +#sys.path.insert(0, '/path/to/ddns/dir/') +#from main import app as application +from ddns import app as application 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) diff --git a/main.wsgi b/main.wsgi deleted file mode 100644 index 9e5292c..0000000 --- a/main.wsgi +++ /dev/null @@ -1,4 +0,0 @@ -#import sys -#sys.path.insert(0, '/path/to/ddns/dir/') -#from main import app as application -from ddns import app as application -- cgit v1.2.3