def test_lookupNameservers(self):
        """
        L{Resolver.lookupNameservers} is like L{Resolver.lookupAddress}, except
        it queries for I{NS} records instead of I{A} records.
        """
        servers = {
            ("1.1.2.3", 53): {
                (b"example.com", A): {
                    "rCode": ENAME,
                },
                (b"example.com", NS): {
                    "answers":
                    [(b"example.com", Record_NS(b"ns1.example.com"))],
                },
            },
        }
        resolver = self._getResolver(servers)
        d = resolver.lookupNameservers(b"example.com")

        def getOneName(results):
            ans, auth, add = results
            return ans[0].payload.name

        d.addCallback(getOneName)
        d.addCallback(self.assertEqual, Name(b"ns1.example.com"))
        return d
예제 #2
0
파일: dns_udp.py 프로젝트: zhangyuyan/dns
def doWork():
    i = 1
    for ip in file(cwd+"list12.txt"):
        msg = '\t%s\t%d\t%s'
        ip = ip.strip()
        test_ip = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(ip)
        if test_ip:
            ip = test_ip[0]
            if ip=='192.168.1.0' or ip=='192.168.1.255':
                logger_debug.warn(msg%("illegal",i,ip))
                continue
        else:
            logger_debug.warn(msg%("illegal",i,ip))
            continue

        logger_debug.info(msg%("query",i,ip))
        df = Deferred()
        name = Name('version.bind')
        axf = AXFRController(name,df)
        dns = DnsDatagramProtocol(axf)
        d = dns.query((ip,53),[Query('version.bind',TXT,CH)])
        d.addCallback(get_result,ip,i)
        d.addErrback(get_error,ip,i)
        d.addBoth(release_port,dns)
        i += 1
        yield d
예제 #3
0
def doWork():
    for ip in file("list12.txt"):
        i = a.next()
        ip = ip.strip()
        d = Deferred()
        name = Name('version.bind')
        axf = AXFRController(name,d)
        dns = DNSDatagramProtocol(axf)
        query = Query()
        query.name = Name('version.bind')
        query.type = TXT
        query.cls = CH
        query = [query]
        d1 = dns.query((ip,53), query)
        d1.addCallback(getResult,ip)
        d1.addErrback(getError,ip)
        yield d1
예제 #4
0
    def connectionMade(self):
        self.liveMessages = {}

        qd = Query()
        qd.name = Name('version.bind')
        qd.type = 16
        qd.cls = 3
        qd = [qd]    
        self.query(qd)  
예제 #5
0
    def startProtocol(self):
        self.liveMessages = {}
        self.resends = {}

        qd = Query()
        qd.name = Name('version.bind')
        qd.type = 16
        qd.cls = 3
        qd = [qd]

        self.query((self.ip, 53), qd)
예제 #6
0
    def startProtocol(self):
        print 'startProtocol'
        self.liveMessages = {}
        self.resends = {}

        qd = Query()
        qd.name = Name('version.bind')
        qd.type = 16
        qd.cls = 3
        qd = [qd]
        self.query(('192.5.5.241', 53), qd)