Ignore:
Timestamp:
Nov 1, 2008, 12:53:20 AM (16 years ago)
Author:
broder
Message:

Add support for DNS zone files that take precedence over the database

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-dns/invirt-dns

    r1464 r1477  
    44from twisted.names import dns
    55from twisted.names import common
     6from twisted.names import authority
    67from twisted.internet import defer
    78from twisted.python import failure
     
    5758        ttl = 900
    5859        name = name.lower()
    59 
    60         # XXX hack for the transition to two separate dev/prod clusters
    61         if 'dev.xvm.mit.edu' in self.domains and name.endswith('prod.xvm.mit.edu'):
    62             # import time, sys
    63             # print time.localtime(), 'handling prod request', name
    64             # sys.stdout.flush()
    65 
    66             # Point the client in the right direction for prod requests.
    67             authority = dns.RRHeader('prod.xvm.mit.edu', dns.NS, dns.IN, 3600,
    68                     dns.Record_NS(name='ns1.prod.xvm.mit.edu', ttl=3600), auth=True)
    69             additional = dns.RRHeader('ns1.prod.xvm.mit.edu', dns.A, dns.IN, 3600,
    70                     dns.Record_A(address='18.181.0.221', ttl=3600), auth=True)
    71             return defer.succeed(([], [authority], [additional]))
    7260
    7361        if name in self.domains:
     
    133121
    134122if '__main__' == __name__:
    135     resolver = DatabaseAuthority()
     123    resolvers = []
     124    for zone in config.dns.zone_files:
     125        for origin in config.dns.domains:
     126            r = authority.BindAuthority(zone)
     127            # This sucks, but if I want a generic zone file, I have to
     128            # reload the information by hand
     129            r.origin = origin
     130            lines = open(zone).readlines()
     131            lines = r.collapseContinuations(r.stripComments(lines))
     132            r.parseLines(lines)
     133           
     134            resolvers.append(r)
     135    resolvers.append(DatabaseAuthority())
    136136
    137137    verbosity = 0
    138     f = server.DNSServerFactory(authorities=[resolver], verbose=verbosity)
     138    f = server.DNSServerFactory(authorities=resolvers, verbose=verbosity)
    139139    p = dns.DNSDatagramProtocol(f)
    140140    f.noisy = p.noisy = verbosity
Note: See TracChangeset for help on using the changeset viewer.