Class: Dyndnsd::Responder::DynDNSStyle

Inherits:
Object
  • Object
show all
Defined in:
lib/dyndnsd/responder/dyndns_style.rb

Instance Method Summary collapse

Instance Method Details

#response_for_changes(states, ip) ⇒ Object



15
16
17
18
# File 'lib/dyndnsd/responder/dyndns_style.rb', line 15

def response_for_changes(states, ip)
  body = states.map { |state| "#{state} #{ip}" }.join("\n")
  return [200, {"Content-Type" => "text/plain"}, [body]]
end

#response_for_error(state) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/dyndnsd/responder/dyndns_style.rb', line 5

def response_for_error(state)
  # 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
end