Introduced A/AAAA field clearing. Updated the LDAP backend to support it.

git-svn-id: svn+ssh://svn.luon.net/svn/ildus/trunk@18 65a33f86-aa00-0410-91be-cd1bf5efb309
This commit is contained in:
paul 2008-12-14 12:06:03 +00:00
parent 14778157c6
commit bdd9c303e4
3 changed files with 13 additions and 4 deletions

View File

@ -196,6 +196,7 @@ module Ildus
# (*Interface*) Updates the address of the given # (*Interface*) Updates the address of the given
# _host_ to the give address _addr_. # _host_ to the give address _addr_.
# If _addr_ is *nil*, the entry should be removed.
def update_host(host, addr) def update_host(host, addr)
raise Handler::NotImplementedError raise Handler::NotImplementedError
end end

View File

@ -59,7 +59,7 @@ module Ildus::Server::DomainBackend
end # def hosts end # def hosts
# Updates the address of _host_ to _addr_ providing that _addr_ is in a # 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) def update_host(host, addr)
entry = all_entries.find do |entry| entry = all_entries.find do |entry|
entry['associatedDomain'][0] == "#{host}.#{config['name']}" entry['associatedDomain'][0] == "#{host}.#{config['name']}"
@ -69,11 +69,19 @@ module Ildus::Server::DomainBackend
if addr.ipv4? if addr.ipv4?
record = entry['aRecord'] record = entry['aRecord']
return false if record and record[0] == addr.to_s 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? elsif addr.ipv6?
record = entry['aAAARecord'] record = entry['aAAARecord']
return false if record and record[0] == addr.to_s 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 else
return false return false
end end

View File

@ -69,7 +69,7 @@ module Ildus
@io = io @io = io
@commit = false @commit = false
# Create the domain backend. # Create the domain name service backend.
type = @config["domain"]["type"] type = @config["domain"]["type"]
klass = Backend.get_domain(type) klass = Backend.get_domain(type)
raise "domain backend type `#{type}' not found" if klass.nil? raise "domain backend type `#{type}' not found" if klass.nil?