當前位置: 首頁>>代碼示例>>Python>>正文


Python dns.NS屬性代碼示例

本文整理匯總了Python中twisted.names.dns.NS屬性的典型用法代碼示例。如果您正苦於以下問題:Python dns.NS屬性的具體用法?Python dns.NS怎麽用?Python dns.NS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在twisted.names.dns的用法示例。


在下文中一共展示了dns.NS屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _referralTest

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import 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)
        result = []
        d.addCallback(result.append)
        answer, authority, additional = result[0]
        self.assertEquals(answer, [])
        self.assertEquals(
            authority, [dns.RRHeader(
                    subdomain, dns.NS, ttl=soa_record.expire,
                    payload=nameserver, auth=False)])
        self.assertEquals(additional, []) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:26,代碼來源:test_names.py

示例2: extractAuthority

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def extractAuthority(msg, cache):
    records = msg.answers + msg.authority + msg.additional
    nameservers = [r for r in records if r.type == dns.NS]

    # print 'Records for', soFar, ':', records
    # print 'NS for', soFar, ':', nameservers

    if not nameservers:
        return None, nameservers
    if not records:
        raise IOError("No records")
    for r in records:
        if r.type == dns.A:
            cache[str(r.name)] = r.payload.dottedQuad()
    for r in records:
        if r.type == dns.NS:
            if str(r.payload.name) in cache:
                return cache[str(r.payload.name)], nameservers
    for addr in records:
        if addr.type == dns.A and addr.name == r.name:
            return addr.payload.dottedQuad(), nameservers
    return None, nameservers 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:24,代碼來源:root.py

示例3: lookupNameservers

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def lookupNameservers(self, name, timeout=None):
        return self._lookup(name, dns.IN, dns.NS, timeout) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:4,代碼來源:common.py

示例4: extractRecord

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def extractRecord(resolver, name, answers, level=10):
    if not level:
        return None
    if hasattr(socket, 'inet_ntop'):
        for r in answers:
            if r.name == name and r.type == dns.A6:
                return socket.inet_ntop(socket.AF_INET6, r.payload.address)
        for r in answers:
            if r.name == name and r.type == dns.AAAA:
                return socket.inet_ntop(socket.AF_INET6, r.payload.address)
    for r in answers:
        if r.name == name and r.type == dns.A:
            return socket.inet_ntop(socket.AF_INET, r.payload.address)
    for r in answers:
        if r.name == name and r.type == dns.CNAME:
            result = extractRecord(
                resolver, r.payload.name, answers, level - 1)
            if not result:
                return resolver.getHostByName(
                    str(r.payload.name), effort=level - 1)
            return result
    # No answers, but maybe there's a hint at who we should be asking about
    # this
    for r in answers:
        if r.type == dns.NS:
            from twisted.names import client
            r = client.Resolver(servers=[(str(r.payload.name), dns.PORT)])
            return r.lookupAddress(str(name)
                ).addCallback(
                    lambda records: extractRecord(
                        r, name,
                        records[_ANS] + records[_AUTH] + records[_ADD],
                        level - 1)) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:35,代碼來源:common.py

示例5: test_nameserver

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import 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

示例6: setUp

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import 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

示例7: test_recordMissing

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import 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

示例8: test_referral

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def test_referral(self):
        """
        When an I{NS} record is found for a child zone, it is included in the
        authority section of the response. It is marked as non-authoritative if
        the authority is not also authoritative for the child zone (RFC 2181,
        section 6.1).
        """
        self._referralTest('lookupAddress') 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:10,代碼來源:test_names.py

示例9: _additionalNSTest

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def _additionalNSTest(self, addresses):
        """
        Verify that a response to an NS query has certain records in the
        I{additional} section.

        @param addresses: See C{_additionalTest}
        """
        self._additionalTest(
            "lookupNameservers", dns.Record_NS, addresses) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:11,代碼來源:test_names.py

示例10: test_nameserverAdditionalA

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def test_nameserverAdditionalA(self):
        """
        If the name of the NS response has A records, they are included in the
        additional section of the response.
        """
        self._additionalNSTest([self._A]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:8,代碼來源:test_names.py

示例11: test_nameserverAdditionalAAAA

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def test_nameserverAdditionalAAAA(self):
        """
        If the name of the NS response has AAAA records, they are included in
        the additional section of the response.
        """
        self._additionalNSTest([self._AAAA]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:8,代碼來源:test_names.py

示例12: test_nameserverAdditionalBoth

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def test_nameserverAdditionalBoth(self):
        """
        If the name of the NS response has both A and AAAA records, they are
        all included in the additional section of the response.
        """
        self._additionalNSTest([self._A, self._AAAA]) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:8,代碼來源:test_names.py

示例13: test_ns

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import 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

示例14: lookupNameservers

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def lookupNameservers(host, atServer, p=None):
    warnings.warn(
        'twisted.names.root.lookupNameservers is deprecated since Twisted '
        '10.0.  Use twisted.names.root.Resolver.lookupNameservers instead.',
        category=DeprecationWarning, stacklevel=2)
    # print 'Nameserver lookup for', host, 'at', atServer, 'with', p
    if p is None:
        p = dns.DNSDatagramProtocol(_DummyController())
        p.noisy = False
    return retry(
        (1, 3, 11, 45),                     # Timeouts
        p,                                  # Protocol instance
        (atServer, dns.PORT),               # Server to query
        [dns.Query(host, dns.NS, dns.IN)]   # Question to ask
    ) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:17,代碼來源:root.py

示例15: extractAuthority

# 需要導入模塊: from twisted.names import dns [as 別名]
# 或者: from twisted.names.dns import NS [as 別名]
def extractAuthority(msg, cache):
    warnings.warn(
        'twisted.names.root.extractAuthority is deprecated since Twisted '
        '10.0.  Please inspect the Message object directly.',
        category=DeprecationWarning, stacklevel=2)
    records = msg.answers + msg.authority + msg.additional
    nameservers = [r for r in records if r.type == dns.NS]

    # print 'Records for', soFar, ':', records
    # print 'NS for', soFar, ':', nameservers

    if not nameservers:
        return None, nameservers
    if not records:
        raise IOError("No records")
    for r in records:
        if r.type == dns.A:
            cache[str(r.name)] = r.payload.dottedQuad()
    for r in records:
        if r.type == dns.NS:
            if str(r.payload.name) in cache:
                return cache[str(r.payload.name)], nameservers
    for addr in records:
        if addr.type == dns.A and addr.name == r.name:
            return addr.payload.dottedQuad(), nameservers
    return None, nameservers 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:28,代碼來源:root.py


注:本文中的twisted.names.dns.NS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。