From 6eacfb61bac60513c084365961437ff640a5bd4f Mon Sep 17 00:00:00 2001 From: Kload Date: Sun, 16 Jun 2013 08:39:41 +0000 Subject: [PATCH] route fix --- dynette.cron.py | 9 ++++----- dynette.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dynette.cron.py b/dynette.cron.py index 4c03e81..d64cb2f 100755 --- a/dynette.cron.py +++ b/dynette.cron.py @@ -12,17 +12,16 @@ for url in urls: domains = json.loads(str(urlopen(url +'/domains').read())) for domain in domains: - result = json.loads(str(urlopen(url +'/all').read())) - + result = json.loads(str(urlopen(url +'/all/'+ domain).read())) lines.extend([ 'zone "'+ domain +'" {', ' type master;', - ' file "/var/named/data/yoyoyo.fr.db"; ', + ' file "/var/named/data/'+ domain +'.db"; ', ' update-policy {', ]) for entry in result: - fqdn = entry['subdomain'] +'.'+ domain +'.' + fqdn = entry['subdomain'] +'.' lines.extend([ ' grant '+ fqdn +' name '+ fqdn +' A TXT;', ' grant '+ fqdn +' name pubsub.'+ fqdn +' A;', @@ -38,7 +37,7 @@ for url in urls: ]) for entry in result: - fqdn = entry['subdomain'] +'.'+ domain +'.' + fqdn = entry['subdomain'] +'.' lines.extend([ 'key '+ fqdn +' {', ' algorithm hmac-md5;', diff --git a/dynette.rb b/dynette.rb index 57c1c2e..c008342 100755 --- a/dynette.rb +++ b/dynette.rb @@ -161,6 +161,18 @@ get '/all' do Entry.all.to_json end +get '/all/:domain' do + unless request.ip == ALLOWED_IP + status 403 + return "Access denied" + end + result = [] + Entry.all.each do |entry| + result.push(entry) if params[:domain] == entry.subdomain.gsub(entry.subdomain.split('.')[0]+'.', '') + end + halt 200, result.to_json +end + get '/ips/:public_key' do unless request.ip == ALLOWED_IP status 403