Changeset 2197 for trunk/packages/invirt-dns/invirt-dns
- Timestamp:
- Feb 27, 2009, 2:41:51 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-dns/invirt-dns
r2037 r2197 94 94 ttl, self.soa, auth=True)) 95 95 else: # Request for a subdomain. 96 value = invirt.database.NIC.query.filter_by(hostname=host).first() 97 if value: 98 ip = value.ip 99 else: 100 value = invirt.database.Machine.query().filter_by(name=host).first() 96 if name.endswith(".in-addr.arpa"): # Reverse resolution here 97 if type in (dns.PTR, dns.ALL_RECORDS): 98 ip = '.'.join(reversed(name.split('.')[:-2])) 99 value = invirt.database.NIC.query.filter_by(ip=ip).first() 100 if value and value.hostname: 101 hostname = value.hostname 102 if '.' not in hostname: 103 hostname = hostname + "." + config.dns.domains[0] 104 record = dns.Record_PTR(hostname, ttl) 105 results.append(dns.RRHeader(name, dns.PTR, dns.IN, 106 ttl, record, auth=True)) 107 else: # IP address doesn't point to an active host 108 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 109 # FIXME: Should only return success with no records if the name actually exists 110 else: # Forward resolution here 111 value = invirt.database.NIC.query.filter_by(hostname=host).first() 101 112 if value: 102 ip = value. nics[0].ip113 ip = value.ip 103 114 else: 115 value = invirt.database.Machine.query().filter_by(name=host).first() 116 if value: 117 ip = value.nics[0].ip 118 else: 119 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 120 121 if ip is None: 104 122 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 105 106 if ip is None: 107 return defer.fail(failure.Failure(dns.AuthoritativeDomainError(name))) 108 109 if type in (dns.A, dns.ALL_RECORDS): 110 record = dns.Record_A(ip, ttl) 111 results.append(dns.RRHeader(name, dns.A, dns.IN, 112 ttl, record, auth=True)) 113 elif type == dns.SOA: 114 results.append(dns.RRHeader(domain, dns.SOA, dns.IN, 115 ttl, self.soa, auth=True)) 123 124 if type in (dns.A, dns.ALL_RECORDS): 125 record = dns.Record_A(ip, ttl) 126 results.append(dns.RRHeader(name, dns.A, dns.IN, 127 ttl, record, auth=True)) 128 elif type == dns.SOA: 129 results.append(dns.RRHeader(domain, dns.SOA, dns.IN, 130 ttl, self.soa, auth=True)) 116 131 if len(results) == 0: 117 132 authority = []
Note: See TracChangeset
for help on using the changeset viewer.