route fix

This commit is contained in:
Kload 2013-06-16 08:39:41 +00:00
parent 35ae88c705
commit 6eacfb61ba
2 changed files with 16 additions and 5 deletions

View file

@ -12,17 +12,16 @@ for url in urls:
domains = json.loads(str(urlopen(url +'/domains').read())) domains = json.loads(str(urlopen(url +'/domains').read()))
for domain in domains: for domain in domains:
result = json.loads(str(urlopen(url +'/all').read())) result = json.loads(str(urlopen(url +'/all/'+ domain).read()))
lines.extend([ lines.extend([
'zone "'+ domain +'" {', 'zone "'+ domain +'" {',
' type master;', ' type master;',
' file "/var/named/data/yoyoyo.fr.db"; ', ' file "/var/named/data/'+ domain +'.db"; ',
' update-policy {', ' update-policy {',
]) ])
for entry in result: for entry in result:
fqdn = entry['subdomain'] +'.'+ domain +'.' fqdn = entry['subdomain'] +'.'
lines.extend([ lines.extend([
' grant '+ fqdn +' name '+ fqdn +' A TXT;', ' grant '+ fqdn +' name '+ fqdn +' A TXT;',
' grant '+ fqdn +' name pubsub.'+ fqdn +' A;', ' grant '+ fqdn +' name pubsub.'+ fqdn +' A;',
@ -38,7 +37,7 @@ for url in urls:
]) ])
for entry in result: for entry in result:
fqdn = entry['subdomain'] +'.'+ domain +'.' fqdn = entry['subdomain'] +'.'
lines.extend([ lines.extend([
'key '+ fqdn +' {', 'key '+ fqdn +' {',
' algorithm hmac-md5;', ' algorithm hmac-md5;',

View file

@ -161,6 +161,18 @@ get '/all' do
Entry.all.to_json Entry.all.to_json
end 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 get '/ips/:public_key' do
unless request.ip == ALLOWED_IP unless request.ip == ALLOWED_IP
status 403 status 403