Changeset 582 for trunk/packages/sipb-xen-dns/code/dnsserver.py
- Timestamp:
- Jun 3, 2008, 2:05:10 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-dns/code/dnsserver.py
r541 r582 26 26 serial=1, refresh=3600, retry=900, 27 27 expire=3600000, minimum=21600, ttl=3600) 28 self.ns = dns.Record_NS(name='ns1.xvm.mit.edu', ttl=3600) 29 28 30 def _lookup(self, name, cls, type, timeout = None): 29 31 for i in range(3): … … 41 43 def _lookup_unsafe(self, name, cls, type, timeout): 42 44 sipb_xen_database.clear_cache() 45 46 ttl = 900 43 47 if name.lower() in self.domains: 44 48 domain = name.lower() 45 49 else: 50 # This works because domain will remain bound after breaking out of the loop 46 51 for domain in self.domains: 47 52 if name.lower().endswith('.'+domain): … … 50 55 return defer.fail(failure.Failure(dns.DomainError(name))) 51 56 results = [] 52 if cls == dns.IN and type in (dns.A, dns.ALL_RECORDS):53 host = name[:-len(domain)-1]54 if not host:55 ttl = 90056 record = dns.Record_CNAME('sipb-xen-dev.mit.edu', ttl)57 results.append(dns.RRHeader(name, dns.CNAME, dns.IN,58 ttl, record, auth=True))59 else:60 value = sipb_xen_database.Machine.get_by(name=host)61 if value is None or not value.nics:62 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name)))63 ip = value.nics[0].ip64 if ip is None: #Deactivated?65 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name)))66 ttl = 90067 record = dns.Record_A(ip, ttl)68 results.append(dns.RRHeader(name, dns.A, dns.IN,69 ttl, record, auth=True))70 57 authority = [] 71 a uth_record = dns.Record_NS(name='ns1.xvm.mit.edu', ttl=3600)58 additional = [] 72 59 authority.append(dns.RRHeader(domain, dns.NS, dns.IN, 73 3600, auth_record, auth=True)) 74 return defer.succeed((results, authority, [])) 75 #Doesn't exist 76 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 60 3600, self.ns, auth=True)) 61 if cls == dns.IN: 62 if type in (dns.A, dns.ALL_RECORDS): 63 host = name[:-len(domain)-1] 64 if not host: 65 record = dns.Record_CNAME('sipb-xen-dev.mit.edu', ttl) 66 results.append(dns.RRHeader(name, dns.CNAME, dns.IN, 67 ttl, record, auth=True)) 68 else: 69 value = sipb_xen_database.Machine.get_by(name=host) 70 if value is None or not value.nics: 71 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 72 ip = value.nics[0].ip 73 if ip is None: #Deactivated? 74 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 75 record = dns.Record_A(ip, ttl) 76 results.append(dns.RRHeader(name, dns.A, dns.IN, 77 ttl, record, auth=True)) 78 elif type == dns.NS: 79 results.append(dns.RRHeader(domain, dns.NS, dns.IN, 80 ttl, self.ns, auth=True)) 81 authority = [] 82 record = dns.Record_A(address='18.181.0.62', ttl=ttl) 83 additional.append(dns.RRHeader('ns1.xvm.mit.edu', dns.A, dns.IN, 84 ttl, record, auth=True)) 85 elif type == dns.SOA: 86 results.append(dns.RRHeader(domain, dns.SOA, dns.IN, 87 ttl, self.soa, auth=True)) 88 return defer.succeed((results, authority, additional)) 89 else: 90 #Doesn't exist 91 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 77 92 78 93 if '__main__' == __name__:
Note: See TracChangeset
for help on using the changeset viewer.