soa = None
- def __init__(self, domain, database=None):
+ def __init__(self, domains, database=None):
common.ResolverBase.__init__(self)
if database is not None:
sipb_xen_database.connect(database)
- self.domain = domain
+ self.domains = domains
self.soa = dns.Record_SOA(mname='sipb-xen-dev.mit.edu',
rname='sipb-xen.mit.edu',
serial=1, refresh=3600, retry=900,
def _lookup_unsafe(self, name, cls, type, timeout):
sipb_xen_database.clear_cache()
- if not (name.lower() == self.domain or
- name.lower().endswith('.'+self.domain)):
- #Not us
- return defer.fail(failure.Failure(dns.DomainError(name)))
+ if name.lower() in self.domains:
+ domain = name.lower()
+ else:
+ found = False
+ for domain in self.domains:
+ if name.lower().endswith('.'+domain):
+ found = True
+ break
+ if not found:
+ #Not us
+ return defer.fail(failure.Failure(dns.DomainError(name)))
results = []
if cls == dns.IN and type in (dns.A, dns.ALL_RECORDS):
- host = name[:-len(self.domain)-1]
+ host = name[:-len(domain)-1]
value = sipb_xen_database.Machine.get_by(name=host)
if value is None or not value.nics:
return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name)))
results.append(dns.RRHeader(name, dns.A, dns.IN,
ttl, record, auth=True))
authority = []
- authority.append(dns.RRHeader(self.domain, dns.SOA, dns.IN, 3600,
+ authority.append(dns.RRHeader(domain, dns.SOA, dns.IN, 3600,
self.soa, auth=True))
return defer.succeed((results, authority, []))
#Doesn't exist
return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name)))
if '__main__' == __name__:
- resolver = DatabaseAuthority('servers.csail.mit.edu',
+ resolver = DatabaseAuthority(['servers.csail.mit.edu',
+ 'xvm.mit.edu'],
'postgres://sipb-xen@sipb-xen-dev/sipb_xen')
verbosity = 0