root/lib/dns_api.rb @ fcc0d38b
2b9164ca | Ohad Levy | require "proxy/dns/bind"
|
|
b65f3926 | Ohad Levy | ||
bba6b24b | Ohad Levy | class SmartProxy
|
|
def setup(opts)
|
|||
6b86c96f | Ohad Levy | @server = Proxy::DNS::Bind.new(opts.merge(:server => SETTINGS.dns_server))
|
|
2b9164ca | Ohad Levy | end
|
|
bba6b24b | Ohad Levy | post "/dns/" do
|
|
fqdn = params[:fqdn]
|
|||
2b9164ca | Ohad Levy | value = params[:value]
|
|
bba6b24b | Ohad Levy | type = params[:type]
|
|
begin
|
|||
setup({:fqdn => fqdn, :value => value, :type => type})
|
|||
4a767d09 | Paul Kelly | @server.create
|
|
b1b32f74 | Paul Kelly | rescue Proxy::DNS::Collision => e
|
|
fcc0d38b | Ohad Levy | log_halt 409, e
|
|
bba6b24b | Ohad Levy | rescue Exception => e
|
|
fcc0d38b | Ohad Levy | log_halt 400, e
|
|
bba6b24b | Ohad Levy | end
|
|
2b9164ca | Ohad Levy | end
|
|
bba6b24b | Ohad Levy | ||
delete "/dns/:value" do
|
|||
case params[:value]
|
|||
when /.in-addr.arpa$/
|
|||
type = "PTR"
|
|||
value = params[:value]
|
|||
else
|
|||
fqdn = params[:value]
|
|||
end
|
|||
begin
|
|||
setup({:fqdn => fqdn, :value => value, :type => type})
|
|||
4a767d09 | Paul Kelly | @server.remove
|
|
bba6b24b | Ohad Levy | rescue => e
|
|
fcc0d38b | Ohad Levy | log_halt 400, e
|
|
bba6b24b | Ohad Levy | end
|
|
2b9164ca | Ohad Levy | end
|
|
end
|