Skip to content

Commit

Permalink
returning CNAME if no A record is available
Browse files Browse the repository at this point in the history
  • Loading branch information
progrium authored and jpf committed Jul 17, 2010
1 parent 9afc0a4 commit 38a097d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,15 @@ def get(self):
records = ResourceRecord.get_all_by_name(domain)
type = self.request.GET.get('type', None)
if type and not type == 'ANY':
if type == 'SOA' and domain == records[0].zone.domain:
records = [records[0].zone.soa_record()]
elif type == 'SOA':
records = [{'name': domain, 'type': 'CNAME', 'rdata': records[0].zone.domain, 'ttl': 1, 'class': 'IN',}]
if type == 'SOA':
if domain == records[0].zone.domain:
records = [records[0].zone.soa_record()]
else:
records = [{'name': domain, 'type': 'CNAME', 'rdata': records[0].zone.domain, 'ttl': 1, 'class': 'IN',}]
else:
records = records.filter('type =', type)
if type == 'A' and records.count() == 0:
records = ResourceRecord.get_all_by_name(domain).filter('type =', 'CNAME')
self.response.out.write(simplejson.dumps(records, cls=BetterJSONEncoder))

class RecordsHandler(webapp.RequestHandler):
Expand Down

0 comments on commit 38a097d

Please sign in to comment.