Changeset 505 for trunk/packages/sipb-xen-dns/code
- Timestamp:
- May 7, 2008, 7:21:10 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-dns/code/dnsserver.py
r312 r505 17 17 soa = None 18 18 19 def __init__(self, domain , database=None):19 def __init__(self, domains, database=None): 20 20 common.ResolverBase.__init__(self) 21 21 if database is not None: 22 22 sipb_xen_database.connect(database) 23 self.domain = domain23 self.domains = domains 24 24 self.soa = dns.Record_SOA(mname='sipb-xen-dev.mit.edu', 25 25 rname='sipb-xen.mit.edu', … … 41 41 def _lookup_unsafe(self, name, cls, type, timeout): 42 42 sipb_xen_database.clear_cache() 43 if not (name.lower() == self.domain or 44 name.lower().endswith('.'+self.domain)): 45 #Not us 46 return defer.fail(failure.Failure(dns.DomainError(name))) 43 if name.lower() in self.domains: 44 domain = name.lower() 45 else: 46 found = False 47 for domain in self.domains: 48 if name.lower().endswith('.'+domain): 49 found = True 50 break 51 if not found: 52 #Not us 53 return defer.fail(failure.Failure(dns.DomainError(name))) 47 54 results = [] 48 55 if cls == dns.IN and type in (dns.A, dns.ALL_RECORDS): 49 host = name[:-len( self.domain)-1]56 host = name[:-len(domain)-1] 50 57 value = sipb_xen_database.Machine.get_by(name=host) 51 58 if value is None or not value.nics: … … 59 66 ttl, record, auth=True)) 60 67 authority = [] 61 authority.append(dns.RRHeader( self.domain, dns.SOA, dns.IN, 3600,68 authority.append(dns.RRHeader(domain, dns.SOA, dns.IN, 3600, 62 69 self.soa, auth=True)) 63 70 return defer.succeed((results, authority, [])) … … 66 73 67 74 if '__main__' == __name__: 68 resolver = DatabaseAuthority('servers.csail.mit.edu', 75 resolver = DatabaseAuthority(['servers.csail.mit.edu', 76 'xvm.mit.edu'], 69 77 'postgres://sipb-xen@sipb-xen-dev/sipb_xen') 70 78
Note: See TracChangeset
for help on using the changeset viewer.