All pastes #259226 Raw Edit

Unnamed

public text v1 · immutable
#259226 ·published 2006-11-27 07:12 UTC
rendered paste body

from twisted.internet import reactor
from twisted.protocols import dns
from twisted.names import client, server, authority, common

class NoFileAuthority(authority.FileAuthority):
    def __init__(self, soa, records):
        # Yes, skip FileAuthority
        common.ResolverBase.__init__(self)
        self.soa, self.records = soa, records

soa_record = dns.Record_SOA(
                    mname = 'i.poly9.com',
                    rname = 'elephant.poly9.com',
                    serial = 1,
                    refresh = 1234,
                    minimum = 7654,
                    expire = 19283784,
                    retry = 15,
                    ttl=1
                )

test_domain_com = NoFileAuthority(
    soa = ('i.poly9.com', soa_record),
    records = {
        'i.poly9.com': [
            soa_record,
            dns.Record_A('127.0.0.1')],
        'test.i.poly9.com': [dns.Record_A('127.0.0.1') ]
        }
)

factory = server.DNSServerFactory([test_domain_com], verbose=2)

p = dns.DNSDatagramProtocol(factory)

reactor.listenUDP(53, p)
reactor.run()