2013-04-27 14:30:41 +02:00
|
|
|
|
|
|
|
module Dyndnsd
|
|
|
|
module Responder
|
|
|
|
class DynDNSStyle
|
2013-04-27 15:42:29 +02:00
|
|
|
def response_for_error(state)
|
2013-04-27 14:30:41 +02:00
|
|
|
# general http errors
|
|
|
|
return [405, {"Content-Type" => "text/plain"}, ["Method Not Allowed"]] if state == :method_forbidden
|
|
|
|
return [404, {"Content-Type" => "text/plain"}, ["Not Found"]] if state == :not_found
|
|
|
|
# specific errors
|
|
|
|
return [200, {"Content-Type" => "text/plain"}, ["notfqdn"]] if state == :hostname_missing
|
|
|
|
return [200, {"Content-Type" => "text/plain"}, ["nohost"]] if state == :host_forbidden
|
|
|
|
return [200, {"Content-Type" => "text/plain"}, ["notfqdn"]] if state == :hostname_malformed
|
2013-04-27 15:42:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def response_for_changes(states, ip)
|
|
|
|
body = states.map { |state| "#{state} #{ip}" }.join("\n")
|
|
|
|
return [200, {"Content-Type" => "text/plain"}, [body]]
|
2013-04-27 14:30:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|