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


Python dns.Record_SOA方法代码示例

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


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

示例1: test_hashable

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [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

示例2: loadFile

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def loadFile(self, filename):
        g, l = self.setupConfigNamespace(), {}
        execfile(filename, g, l)
        if 'zone' not in l:
            raise ValueError("No zone defined in " + filename)

        self.records = {}
        for rr in l['zone']:
            if isinstance(rr[1], dns.Record_SOA):
                self.soa = rr
            self.records.setdefault(rr[0].lower(), []).append(rr[1]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:authority.py

示例3: setUp

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [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

示例4: _lookupSomeRecords

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def _lookupSomeRecords(self, method, soa, makeRecord, target, addresses):
        """
        Perform a DNS lookup against a L{FileAuthority} configured with records
        as defined by C{makeRecord} and C{addresses}.

        @param method: The name of the lookup method to use; for example,
            C{"lookupNameservers"}.
        @type method: L{str}

        @param soa: A L{Record_SOA} for the zone for which the L{FileAuthority}
            is authoritative.

        @param makeRecord: A one-argument callable which accepts a name and
            returns an L{IRecord} provider.  L{FileAuthority} is constructed
            with this record.  The L{FileAuthority} is queried for a record of
            the resulting type with the given name.

        @param target: The extra name which the record returned by
            C{makeRecord} will be pointed at; this is the name which might
            require extra processing by the server so that all the available,
            useful information is returned.  For example, this is the target of
            a CNAME record or the mail exchange host pointed to by an MX record.
        @type target: L{bytes}

        @param addresses: A L{list} of records giving addresses of C{target}.

        @return: A L{Deferred} that fires with the result of the resolver
            method give by C{method}.
        """
        authority = NoFileAuthority(
            soa=(soa.mname.name, soa),
            records={
                soa.mname.name: [makeRecord(target)],
                target: addresses,
                },
            )
        return getattr(authority, method)(soa_record.mname.name) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:39,代码来源:test_names.py

示例5: test_SOA

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def test_SOA(self):
        """
        The byte stream written by L{dns.Record_SOA.encode} can be used by
        L{dns.Record_SOA.decode} to reconstruct the state of the original
        L{dns.Record_SOA} instance.
        """
        self._recordRoundtripTest(
            dns.Record_SOA(
                mname=b'foo', rname=b'bar', serial=12, refresh=34,
                retry=56, expire=78, minimum=90)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:test_dns.py

示例6: test_soa

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def test_soa(self):
        """
        The repr of a L{dns.Record_SOA} instance includes all of the
        authority fields.
        """
        self.assertEqual(
            repr(dns.Record_SOA(mname=b'mName', rname=b'rName', serial=123,
                                refresh=456, retry=789, expire=10,
                                minimum=11, ttl=12)),
            "<SOA mname=mName rname=rName serial=123 refresh=456 "
            "retry=789 expire=10 minimum=11 ttl=12>") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:test_dns.py

示例7: test_authorityOverride

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def test_authorityOverride(self):
        """
        L{dns._EDNSMessage.authority} can be overridden in the constructor.
        """
        msg = self.messageFactory(
            authority=[
                dns.RRHeader(
                    b'example.com',
                    type=dns.SOA,
                    payload=dns.Record_SOA())])

        self.assertEqual(
            msg.authority,
            [dns.RRHeader(b'example.com', type=dns.SOA,
                          payload=dns.Record_SOA())]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:test_dns.py

示例8: loadFile

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def loadFile(self, filename):
        g, l = self.setupConfigNamespace(), {}
        execfile(filename, g, l)
        if not l.has_key('zone'):
            raise ValueError, "No zone defined in " + filename

        self.records = {}
        for rr in l['zone']:
            if isinstance(rr[1], dns.Record_SOA):
                self.soa = rr
            self.records.setdefault(rr[0].lower(), []).append(rr[1]) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:authority.py

示例9: test_soa

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def test_soa(self):
        """
        The repr of a L{dns.Record_SOA} instance includes all of the
        authority fields.
        """
        self.assertEqual(
            repr(dns.Record_SOA(mname='mName', rname='rName', serial=123,
                                refresh=456, retry=789, expire=10,
                                minimum=11, ttl=12)),
            "<SOA mname=mName rname=rName serial=123 refresh=456 "
            "retry=789 expire=10 minimum=11 ttl=12>") 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:test_dns.py

示例10: testHashable

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def testHashable(self):
        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
        ]

        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:kenorb-contrib,项目名称:BitTorrent,代码行数:17,代码来源:test_dns.py

示例11: make_soa_result

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def make_soa_result(self, serial):
        return RRHeader(
            type=SOA, cls=A, ttl=30, payload=Record_SOA(serial=serial)
        ) 
开发者ID:maas,项目名称:maas,代码行数:6,代码来源:test_region_controller.py

示例12: test_lookupAddress

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def test_lookupAddress(self):
        """
        L{SecondaryAuthority.lookupAddress} returns a L{Deferred} that fires
        with the I{A} records the authority has cached from the primary.
        """
        secondary = SecondaryAuthority.fromServerAddressAndDomain(
            ('192.168.1.2', 1234), b'example.com')
        secondary._reactor = reactor = MemoryReactorClock()

        secondary.transfer()

        host, port, factory, timeout, bindAddress = reactor.tcpClients.pop(0)

        proto = factory.buildProtocol((host, port))
        transport = StringTransport()
        proto.makeConnection(transport)

        query = Message(answer=1, auth=1)
        query.decode(BytesIO(transport.value()[2:]))

        # Generate a response with some data we can check.
        soa = Record_SOA(
            mname=b'ns1.example.com',
            rname='admin.example.com',
            serial=123456,
            refresh=3600,
            minimum=4800,
            expire=7200,
            retry=9600,
            ttl=12000,
            )
        a = Record_A(b'192.168.1.2', ttl=0)
        answer = Message(id=query.id, answer=1, auth=1)
        answer.answers.extend([
                RRHeader(b'example.com', type=SOA, payload=soa),
                RRHeader(b'example.com', payload=a),
                RRHeader(b'example.com', type=SOA, payload=soa),
                ])

        data = answer.toStr()
        proto.dataReceived(pack('!H', len(data)) + data)

        result = self.successResultOf(secondary.lookupAddress('example.com'))
        self.assertEqual((
                [RRHeader(b'example.com', payload=a, auth=True)], [], []), result) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:47,代码来源:test_names.py

示例13: kwargs

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import Record_SOA [as 别名]
def kwargs(cls):
        """
        Keyword constructor arguments which are expected to result in an
        instance which returns C{bytes} when encoded.

        @return: A L{dict} of keyword arguments.
        """
        return dict(
            id=256,
            answer=1,
            opCode=dns.OP_STATUS,
            auth=1,
            recDes=1,
            recAv=1,
            rCode=15,
            ednsVersion=None,
            queries=[dns.Query(b'example.com', dns.SOA)],
            answers=[
                dns.RRHeader(
                    b'example.com',
                    type=dns.SOA,
                    ttl=0xffffffff,
                    auth=True,
                    payload=dns.Record_SOA(
                        ttl=0xffffffff,
                        mname=b'ns1.example.com',
                        rname=b'hostmaster.example.com',
                        serial=0xfffffffe,
                        refresh=0x7ffffffd,
                        retry=0x7ffffffc,
                        expire=0x7ffffffb,
                        minimum=0xfffffffa,
                        ))],
            authority=[
                dns.RRHeader(
                    b'example.com',
                    type=dns.NS,
                    ttl=0xffffffff,
                    auth=True,
                    payload=dns.Record_NS(
                        'ns1.example.com', ttl=0xffffffff))],
            additional=[
                dns.RRHeader(
                    b'ns1.example.com',
                    type=dns.A,
                    ttl=0xffffffff,
                    auth=True,
                    payload=dns.Record_A(
                        '5.6.7.8', ttl=0xffffffff))]) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:51,代码来源:test_dns.py


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