diff --git a/lib/ildus/server/backend.rb b/lib/ildus/server/backend.rb index 284f727..0fd24d2 100644 --- a/lib/ildus/server/backend.rb +++ b/lib/ildus/server/backend.rb @@ -196,6 +196,7 @@ module Ildus # (*Interface*) Updates the address of the given # _host_ to the give address _addr_. + # If _addr_ is *nil*, the entry should be removed. def update_host(host, addr) raise Handler::NotImplementedError end diff --git a/lib/ildus/server/domain_backends/ldap.rb b/lib/ildus/server/domain_backends/ldap.rb index 5332137..039cd52 100644 --- a/lib/ildus/server/domain_backends/ldap.rb +++ b/lib/ildus/server/domain_backends/ldap.rb @@ -59,7 +59,7 @@ module Ildus::Server::DomainBackend end # def hosts # Updates the address of _host_ to _addr_ providing that _addr_ is in a - # correct IPv4 or IPv6 address format. + # correct IPv4 or IPv6 address format or *nil*. def update_host(host, addr) entry = all_entries.find do |entry| entry['associatedDomain'][0] == "#{host}.#{config['name']}" @@ -69,11 +69,19 @@ module Ildus::Server::DomainBackend if addr.ipv4? record = entry['aRecord'] return false if record and record[0] == addr.to_s - @ldap.modify(entry['dn'][0], {"aRecord" => [addr.to_s]}) + if addr.to_i.zero? + @ldap.modify(entry['dn'][0], {"aRecord" => []}) + else + @ldap.modify(entry['dn'][0], {"aRecord" => [addr.to_s]}) + end elsif addr.ipv6? record = entry['aAAARecord'] return false if record and record[0] == addr.to_s - @ldap.modify(entry['dn'][0], {"aAAARecord" => [addr.to_s]}) + if addr.to_i.zero? + @ldap.modify(entry['dn'][0], {"aAAARecord" => []}) + else + @ldap.modify(entry['dn'][0], {"aAAARecord" => [addr.to_s]}) + end else return false end diff --git a/lib/ildus/server/handler.rb b/lib/ildus/server/handler.rb index 67abba3..bef0745 100644 --- a/lib/ildus/server/handler.rb +++ b/lib/ildus/server/handler.rb @@ -69,7 +69,7 @@ module Ildus @io = io @commit = false - # Create the domain backend. + # Create the domain name service backend. type = @config["domain"]["type"] klass = Backend.get_domain(type) raise "domain backend type `#{type}' not found" if klass.nil?