当前位置: 首页>>代码示例>>Python>>正文


Python dns.Record_NS方法代码示例

本文整理汇总了Python中twisted.names.dns.Record_NS方法的典型用法代码示例。如果您正苦于以下问题:Python dns.Record_NS方法的具体用法?Python dns.Record_NS怎么用?Python dns.Record_NS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.names.dns的用法示例。


在下文中一共展示了dns.Record_NS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _referralTest

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def _referralTest(self, method):
        """
        Create an authority and make a request against it.  Then verify that the
        result is a referral, including no records in the answers or additional
        sections, but with an I{NS} record in the authority section.
        """
        subdomain = 'example.' + str(soa_record.mname)
        nameserver = dns.Record_NS('1.2.3.4')
        authority = NoFileAuthority(
            soa=(str(soa_record.mname), soa_record),
            records={
                subdomain: [
                    nameserver,
                    ]})
        d = getattr(authority, method)(subdomain)
        answer, authority, additional = self.successResultOf(d)
        self.assertEqual(answer, [])
        self.assertEqual(
            authority, [dns.RRHeader(
                    subdomain, dns.NS, ttl=soa_record.expire,
                    payload=nameserver, auth=False)])
        self.assertEqual(additional, []) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:test_names.py

示例2: test_lookupAddress

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_lookupAddress(self):
        """
        L{root.Resolver.lookupAddress} looks up the I{A} records for the
        specified hostname by first querying one of the root servers the
        resolver was created with and then following the authority delegations
        until a result is received.
        """
        servers = {
            ('1.1.2.3', 53): {
                ('foo.example.com', A): {
                    'authority': [('foo.example.com', Record_NS('ns1.example.com'))],
                    'additional': [('ns1.example.com', Record_A('34.55.89.144'))],
                    },
                },
            ('34.55.89.144', 53): {
                ('foo.example.com', A): {
                    'answers': [('foo.example.com', Record_A('10.0.0.1'))],
                    }
                },
            }
        resolver = self._getResolver(servers)
        d = resolver.lookupAddress('foo.example.com')
        d.addCallback(lambda (ans, auth, add): ans[0].payload.dottedQuad())
        d.addCallback(self.assertEquals, '10.0.0.1')
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:27,代码来源:test_rootresolve.py

示例3: test_delegationLookupError

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_delegationLookupError(self):
        """
        If there is an error resolving the nameserver in a delegation response,
        the L{Deferred} returned by L{Resolver.lookupAddress} fires with that
        error.
        """
        servers = {
            ('1.1.2.3', 53): {
                ('example.com', A): {
                    'authority': [('example.com', Record_NS('ns1.example.com'))],
                    },
                ('ns1.example.com', A): {
                    'rCode': ENAME,
                    },
                },
            }
        resolver = self._getResolver(servers)
        d = resolver.lookupAddress('example.com')
        return self.assertFailure(d, DNSNameError) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:test_rootresolve.py

示例4: test_delegationLookupEmpty

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_delegationLookupEmpty(self):
        """
        If there are no records in the response to a lookup of a delegation
        nameserver, the L{Deferred} returned by L{Resolver.lookupAddress} fires
        with L{ResolverError}.
        """
        servers = {
            ('1.1.2.3', 53): {
                ('example.com', A): {
                    'authority': [('example.com', Record_NS('ns1.example.com'))],
                    },
                ('ns1.example.com', A): {
                    },
                },
            }
        resolver = self._getResolver(servers)
        d = resolver.lookupAddress('example.com')
        return self.assertFailure(d, ResolverError) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:test_rootresolve.py

示例5: test_hashable

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_hashable(self):
        """
        Instances of all record types are hashable.
        """
        records = [
            dns.Record_NS, dns.Record_MD, dns.Record_MF, dns.Record_CNAME,
            dns.Record_MB, dns.Record_MG, dns.Record_MR, dns.Record_PTR,
            dns.Record_DNAME, dns.Record_A, dns.Record_SOA, dns.Record_NULL,
            dns.Record_WKS, dns.Record_SRV, dns.Record_AFSDB, dns.Record_RP,
            dns.Record_HINFO, dns.Record_MINFO, dns.Record_MX, dns.Record_TXT,
            dns.Record_AAAA, dns.Record_A6, dns.Record_NAPTR
        ]

        for k in records:
            k1, k2 = k(), k()
            hk1 = hash(k1)
            hk2 = hash(k2)
            self.assertEquals(hk1, hk2, "%s != %s (for %s)" % (hk1,hk2,k)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:test_dns.py

示例6: test_nameserver

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_nameserver(self):
        """Test DNS 'NS' record queries"""
        return self.namesTest(
            self.resolver.lookupNameservers('test-domain.com'),
            [dns.Record_NS('39.28.189.39', ttl=19283784)]
        ) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:test_names.py

示例7: test_someRecordsWithTTLs

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_someRecordsWithTTLs(self):
        result_soa = copy.copy(my_soa)
        result_soa.ttl = my_soa.expire
        return self.namesTest(
            self.resolver.lookupAllRecords('my-domain.com'),
            [result_soa,
             dns.Record_A('1.2.3.4', ttl='1S'),
             dns.Record_NS('ns1.domain', ttl='2M'),
             dns.Record_NS('ns2.domain', ttl='3H'),
             dns.Record_SRV(257, 16383, 43690, 'some.other.place.fool', ttl='4D')]
            ) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:test_names.py

示例8: setUp

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def setUp(self):
        self.results = None
        self.d = defer.Deferred()
        self.d.addCallback(self._gotResults)
        self.controller = client.AXFRController('fooby.com', self.d)

        self.soa = dns.RRHeader(name='fooby.com', type=dns.SOA, cls=dns.IN, ttl=86400, auth=False,
                                payload=dns.Record_SOA(mname='fooby.com',
                                                       rname='hooj.fooby.com',
                                                       serial=100,
                                                       refresh=200,
                                                       retry=300,
                                                       expire=400,
                                                       minimum=500,
                                                       ttl=600))

        self.records = [
            self.soa,
            dns.RRHeader(name='fooby.com', type=dns.NS, cls=dns.IN, ttl=700, auth=False,
                         payload=dns.Record_NS(name='ns.twistedmatrix.com', ttl=700)),

            dns.RRHeader(name='fooby.com', type=dns.MX, cls=dns.IN, ttl=700, auth=False,
                         payload=dns.Record_MX(preference=10, exchange='mail.mv3d.com', ttl=700)),

            dns.RRHeader(name='fooby.com', type=dns.A, cls=dns.IN, ttl=700, auth=False,
                         payload=dns.Record_A(address='64.123.27.105', ttl=700)),
            self.soa
            ] 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:30,代码来源:test_names.py

示例9: test_recordMissing

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_recordMissing(self):
        """
        If a L{FileAuthority} has a zone which includes an I{NS} record for a
        particular name and that authority is asked for another record for the
        same name which does not exist, the I{NS} record is not included in the
        authority section of the response.
        """
        authority = NoFileAuthority(
            soa=(str(soa_record.mname), soa_record),
            records={
                str(soa_record.mname): [
                    soa_record,
                    dns.Record_NS('1.2.3.4'),
                    ]})
        d = authority.lookupAddress(str(soa_record.mname))
        result = []
        d.addCallback(result.append)
        answer, authority, additional = result[0]
        self.assertEqual(answer, [])
        self.assertEqual(
            authority, [
                dns.RRHeader(
                    str(soa_record.mname), soa_record.TYPE,
                    ttl=soa_record.expire, payload=soa_record,
                    auth=True)])
        self.assertEqual(additional, []) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:28,代码来源:test_names.py

示例10: test_noAnswer

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_noAnswer(self):
        """
        If a request returns a L{dns.NS} response, but we can't connect to the
        given server, the request fails with the error returned at connection.
        """

        def query(self, *args):
            # Pop from the message list, so that it blows up if more queries
            # are run than expected.
            return succeed(messages.pop(0))

        def queryProtocol(self, *args, **kwargs):
            return defer.fail(socket.gaierror("Couldn't connect"))

        resolver = Resolver(servers=[('0.0.0.0', 0)])
        resolver._query = query
        messages = []
        # Let's patch dns.DNSDatagramProtocol.query, as there is no easy way to
        # customize it.
        self.patch(dns.DNSDatagramProtocol, "query", queryProtocol)

        records = [
            dns.RRHeader(name='fooba.com', type=dns.NS, cls=dns.IN, ttl=700,
                         auth=False,
                         payload=dns.Record_NS(name='ns.twistedmatrix.com',
                         ttl=700))]
        m = dns.Message(id=999, answer=1, opCode=0, recDes=0, recAv=1, auth=1,
                        rCode=0, trunc=0, maxSize=0)
        m.answers = records
        messages.append(m)
        return self.assertFailure(
            resolver.getHostByName("fooby.com"), socket.gaierror) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:34,代码来源:test_names.py

示例11: test_ns

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_ns(self):
        """
        The repr of a L{dns.Record_NS} instance includes the name of the
        nameserver and the TTL of the record.
        """
        self.assertEqual(
            repr(dns.Record_NS(b'example.com', 4321)),
            "<NS name=example.com ttl=4321>") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:test_dns.py

示例12: test_lookupChecksClass

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_lookupChecksClass(self):
        """
        If a response includes a record with a class different from the one
        in the query, it is ignored and lookup continues until a record with
        the right class is found.
        """
        badClass = Record_A('10.0.0.1')
        badClass.CLASS = HS
        servers = {
            ('1.1.2.3', 53): {
                ('foo.example.com', A): {
                    'answers': [('foo.example.com', badClass)],
                    'authority': [('foo.example.com', Record_NS('ns1.example.com'))],
                    'additional': [('ns1.example.com', Record_A('10.0.0.2'))],
                },
            },
            ('10.0.0.2', 53): {
                ('foo.example.com', A): {
                    'answers': [('foo.example.com', Record_A('10.0.0.3'))],
                },
            },
        }
        resolver = self._getResolver(servers)
        d = resolver.lookupAddress('foo.example.com')
        d.addCallback(lambda (ans, auth, add): ans[0].payload)
        d.addCallback(self.assertEquals, Record_A('10.0.0.3'))
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:29,代码来源:test_rootresolve.py

示例13: test_missingGlue

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def test_missingGlue(self):
        """
        If an intermediate response includes no glue records for the
        authorities, separate queries are made to find those addresses.
        """
        servers = {
            ('1.1.2.3', 53): {
                ('foo.example.com', A): {
                    'authority': [('foo.example.com', Record_NS('ns1.example.org'))],
                    # Conspicuous lack of an additional section naming ns1.example.com
                    },
                ('ns1.example.org', A): {
                    'answers': [('ns1.example.org', Record_A('10.0.0.1'))],
                    },
                },
            ('10.0.0.1', 53): {
                ('foo.example.com', A): {
                    'answers': [('foo.example.com', Record_A('10.0.0.2'))],
                    },
                },
            }
        resolver = self._getResolver(servers)
        d = resolver.lookupAddress('foo.example.com')
        d.addCallback(lambda (ans, auth, add): ans[0].payload.dottedQuad())
        d.addCallback(self.assertEquals, '10.0.0.2')
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:28,代码来源:test_rootresolve.py

示例14: testNameserver

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def testNameserver(self):
        """Test DNS 'NS' record queries"""
        return self.namesTest(
            self.resolver.lookupNameservers('test-domain.com'),
            [dns.Record_NS('39.28.189.39', ttl=19283784)]
        ) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:8,代码来源:test_names.py

示例15: testSomeRecordsWithTTLs

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_NS [as 别名]
def testSomeRecordsWithTTLs(self):
        result_soa = copy.copy(my_soa)
        result_soa.ttl = my_soa.expire
        return self.namesTest(
            self.resolver.lookupAllRecords('my-domain.com'),
            [result_soa,
             dns.Record_A('1.2.3.4', ttl='1S'),
             dns.Record_NS('ns1.domain', ttl='2M'),
             dns.Record_NS('ns2.domain', ttl='3H'),
             dns.Record_SRV(257, 16383, 43690, 'some.other.place.fool', ttl='4D')]
            ) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:test_names.py


注:本文中的twisted.names.dns.Record_NS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。