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


Python dns.opcode方法代码示例

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


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

示例1: _make_dns_message

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def _make_dns_message(self, zone_name, notify=False):
        """
        This constructs a SOA query or a dns NOTIFY message.
        :param zone_name: The zone name for which a SOA/NOTIFY needs to be
            sent.
        :param notify: If true, a notify message is constructed else a SOA
            message is constructed.
        :return: The constructed message.
        """
        dns_message = dns.message.make_query(zone_name, dns.rdatatype.SOA)
        dns_message.flags = 0
        if notify:
            dns_message.set_opcode(dns.opcode.NOTIFY)
            dns_message.flags |= dns.flags.AA
        else:
            # Setting the flags to RD causes BIND9 to respond with a NXDOMAIN.
            dns_message.set_opcode(dns.opcode.QUERY)
            dns_message.flags |= dns.flags.RD

        return dns_message 
开发者ID:openstack,项目名称:designate,代码行数:22,代码来源:notify.py

示例2: is_response

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def is_response(self, other):
        """Is other a response to self?
        @rtype: bool"""
        if other.flags & dns.flags.QR == 0 or \
           self.id != other.id or \
           dns.opcode.from_flags(self.flags) != \
           dns.opcode.from_flags(other.flags):
            return False
        if dns.rcode.from_flags(other.flags, other.ednsflags) != \
                dns.rcode.NOERROR:
            return True
        if dns.opcode.is_update(self.flags):
            return True
        for n in self.question:
            if n not in other.question:
                return False
        for n in other.question:
            if n not in self.question:
                return False
        return True 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:22,代码来源:message.py

示例3: read

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def read(self):
        """Read a wire format DNS message and build a dns.message.Message
        object."""

        l = len(self.wire)
        if l < 12:
            raise ShortHeader
        (self.message.id, self.message.flags, qcount, ancount,
         aucount, adcount) = struct.unpack('!HHHHHH', self.wire[:12])
        self.current = 12
        if dns.opcode.is_update(self.message.flags):
            self.updating = True
        self._get_question(qcount)
        if self.question_only:
            return
        self._get_section(self.message.answer, ancount)
        self._get_section(self.message.authority, aucount)
        self._get_section(self.message.additional, adcount)
        if not self.ignore_trailing and self.current != l:
            raise TrailingJunk
        if self.message.multi and self.message.tsig_ctx and \
                not self.message.had_tsig:
            self.message.tsig_ctx.update(self.wire) 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:25,代码来源:message.py

示例4: is_response

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def is_response(self, other):
        """Is other a response to self?
        @rtype: bool"""
        if other.flags & dns.flags.QR == 0 or \
           self.id != other.id or \
           dns.opcode.from_flags(self.flags) != \
           dns.opcode.from_flags(other.flags):
            return False
        if dns.rcode.from_flags(other.flags, other.ednsflags) != \
               dns.rcode.NOERROR:
            return True
        if dns.opcode.is_update(self.flags):
            return True
        for n in self.question:
            if n not in other.question:
                return False
        for n in other.question:
            if n not in self.question:
                return False
        return True 
开发者ID:blackye,项目名称:luscan-devel,代码行数:22,代码来源:message.py

示例5: read

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def read(self):
        """Read a wire format DNS message and build a dns.message.Message
        object."""

        l = len(self.wire)
        if l < 12:
            raise ShortHeader
        (self.message.id, self.message.flags, qcount, ancount,
         aucount, adcount) = struct.unpack('!HHHHHH', self.wire[:12])
        self.current = 12
        if dns.opcode.is_update(self.message.flags):
            self.updating = True
        self._get_question(qcount)
        if self.question_only:
            return
        self._get_section(self.message.answer, ancount)
        self._get_section(self.message.authority, aucount)
        self._get_section(self.message.additional, adcount)
        if not self.ignore_trailing and self.current != l:
            raise TrailingJunk
        if self.message.multi and self.message.tsig_ctx and \
               not self.message.had_tsig:
            self.message.tsig_ctx.update(self.wire) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:25,代码来源:message.py

示例6: __call__

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def __call__(self, request):
        """
        :param request: DNS Request Message
        :return: DNS Response Message
        """
        # TODO(Tim): Handle multiple questions
        rdtype = request.question[0].rdtype
        rdclass = request.question[0].rdclass
        opcode = request.opcode()
        if opcode == dns.opcode.NOTIFY:
            response = self._handle_notify(request)
        elif opcode == pcodes.CC:
            if rdclass == pcodes.CLASSCC:
                if rdtype == pcodes.CREATE:
                    response = self._handle_create(request)
                elif rdtype == pcodes.DELETE:
                    response = self._handle_delete(request)
                else:
                    response = self._handle_query_error(request,
                                                        dns.rcode.REFUSED)
            else:
                response = self._handle_query_error(request, dns.rcode.REFUSED)
        else:
            # Unhandled OpCodes include STATUS, QUERY, IQUERY, UPDATE
            response = self._handle_query_error(request, dns.rcode.REFUSED)

        # TODO(Tim): Answer Type 65XXX queries
        yield response
        return 
开发者ID:openstack,项目名称:designate,代码行数:31,代码来源:handler.py

示例7: __call__

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def __call__(self, request):
        """
        :param request: DNS Request Message
        :return: DNS Response Message
        """
        if request.opcode() == dns.opcode.QUERY:
            # Currently we expect exactly 1 question in the section
            # TSIG places the pseudo records into the additional section.
            if (len(request.question) != 1 or
                    request.question[0].rdclass != dns.rdataclass.IN):
                LOG.debug('Refusing due to numbers of questions or rdclass')
                yield self._handle_query_error(request, dns.rcode.REFUSED)
                return

            q_rrset = request.question[0]
            # Handle AXFR and IXFR requests with an AXFR responses for now.
            # It is permissible for a server to send an AXFR response when
            # receiving an IXFR request.
            if q_rrset.rdtype in (dns.rdatatype.AXFR, dns.rdatatype.IXFR):
                for response in self._handle_axfr(request):
                    yield response
                return

            else:
                for response in self._handle_record_query(request):
                    yield response
                return

        elif request.opcode() == dns.opcode.NOTIFY:
            for response in self._handle_notify(request):
                yield response
            return

        else:
            # Unhandled OpCode's include STATUS, IQUERY, UPDATE
            LOG.debug('Refusing unhandled opcode')
            yield self._handle_query_error(request, dns.rcode.REFUSED)
            return 
开发者ID:openstack,项目名称:designate,代码行数:40,代码来源:handler.py

示例8: _make_dns_message

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def _make_dns_message(self, zone_name, opcode, rdatatype, rdclass):
        dns_message = dns.message.make_query(zone_name, rdatatype,
                                             rdclass=rdclass)
        dns_message.flags = 0

        dns_message.set_opcode(opcode)
        dns_message.flags |= dns.flags.AA

        return dns_message 
开发者ID:openstack,项目名称:designate,代码行数:11,代码来源:agent.py

示例9: opcode

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def opcode(self):
        """Return the opcode.
        @rtype: int
        """
        return dns.opcode.from_flags(self.flags) 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:7,代码来源:message.py

示例10: set_opcode

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def set_opcode(self, opcode):
        """Set the opcode.
        @param opcode: the opcode
        @type opcode: int
        """
        self.flags &= 0x87FF
        self.flags |= dns.opcode.to_flags(opcode) 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:9,代码来源:message.py

示例11: make_response

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def make_response(query, recursion_available=False, our_payload=8192,
                  fudge=300):
    """Make a message which is a response for the specified query.
    The message returned is really a response skeleton; it has all
    of the infrastructure required of a response, but none of the
    content.

    The response's question section is a shallow copy of the query's
    question section, so the query's question RRsets should not be
    changed.

    @param query: the query to respond to
    @type query: dns.message.Message object
    @param recursion_available: should RA be set in the response?
    @type recursion_available: bool
    @param our_payload: payload size to advertise in EDNS responses; default
    is 8192.
    @type our_payload: int
    @param fudge: TSIG time fudge; default is 300 seconds.
    @type fudge: int
    @rtype: dns.message.Message object"""

    if query.flags & dns.flags.QR:
        raise dns.exception.FormError('specified query message is not a query')
    response = dns.message.Message(query.id)
    response.flags = dns.flags.QR | (query.flags & dns.flags.RD)
    if recursion_available:
        response.flags |= dns.flags.RA
    response.set_opcode(query.opcode())
    response.question = list(query.question)
    if query.edns >= 0:
        response.use_edns(0, 0, our_payload, query.payload)
    if query.had_tsig:
        response.use_tsig(query.keyring, query.keyname, fudge, None, 0, '',
                          query.keyalgorithm)
        response.request_mac = query.mac
    return response 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:39,代码来源:message.py

示例12: make_response

# 需要导入模块: import dns [as 别名]
# 或者: from dns import opcode [as 别名]
def make_response(query, recursion_available=False, our_payload=8192):
    """Make a message which is a response for the specified query.
    The message returned is really a response skeleton; it has all
    of the infrastructure required of a response, but none of the
    content.

    The response's question section is a shallow copy of the query's
    question section, so the query's question RRsets should not be
    changed.

    @param query: the query to respond to
    @type query: dns.message.Message object
    @param recursion_available: should RA be set in the response?
    @type recursion_available: bool
    @param our_payload: payload size to advertise in EDNS responses; default
    is 8192.
    @type our_payload: int
    @rtype: dns.message.Message object"""

    if query.flags & dns.flags.QR:
        raise dns.exception.FormError('specified query message is not a query')
    response = dns.message.Message(query.id)
    response.flags = dns.flags.QR | (query.flags & dns.flags.RD)
    if recursion_available:
        response.flags |= dns.flags.RA
    response.set_opcode(query.opcode())
    response.question = list(query.question)
    if query.edns >= 0:
        response.use_edns(0, 0, our_payload, query.payload)
    if not query.keyname is None:
        response.keyname = query.keyname
        response.keyring = query.keyring
        response.request_mac = query.mac
    return response 
开发者ID:blackye,项目名称:luscan-devel,代码行数:36,代码来源:message.py


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