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


Python dns.rcode方法代码示例

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


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

示例1: is_response

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

示例2: is_response

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

示例3: adjust_reply

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def adjust_reply(
                self,
                query: dns.message.Message,
                copy_id: bool = True,
                copy_query: bool = True
            ) -> None:
        answer = dns.message.from_wire(self.message.to_wire(),
                                       xfr=self.message.xfr,
                                       one_rr_per_rrset=True)
        answer.use_edns(query.edns, query.ednsflags, options=self.message.options)
        if copy_id:
            answer.id = query.id
            # Copy letter-case if the template has QD
            if answer.question:
                answer.question[0].name = query.question[0].name
        if copy_query:
            answer.question = query.question
        # Re-set, as the EDNS might have reset the ext-rcode
        answer.set_rcode(self.message.rcode())

        # sanity check: adjusted answer should be almost the same
        assert len(answer.answer) == len(self.message.answer)
        assert len(answer.authority) == len(self.message.authority)
        assert len(answer.additional) == len(self.message.additional)
        self.message = answer 
开发者ID:CZ-NIC,项目名称:deckard,代码行数:27,代码来源:scenario.py

示例4: process_match

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def process_match(self):
        try:
            self.node["/match_present"]
        except KeyError:
            return None

        fields = set(m.value for m in self.node.match("/match"))

        if 'all' in fields:
            fields.remove("all")
            fields |= set(["opcode", "qtype", "qname", "flags",
                           "rcode", "answer", "authority", "additional"])

        if 'question' in fields:
            fields.remove("question")
            fields |= set(["qtype", "qname"])

        return fields 
开发者ID:CZ-NIC,项目名称:deckard,代码行数:20,代码来源:scenario.py

示例5: get_rcode

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def get_rcode(cls, fields):
        """
        From `fields` extracts and returns rcode.
        Throws `ValueError` if there are more then one rcodes
        """
        rcodes = []
        for code in fields:
            try:
                rcodes.append(dns.rcode.from_text(code))
            except dns.rcode.UnknownRcode:
                pass
        if len(rcodes) > 1:
            raise ValueError("Parse failed, too many rcode values.", rcodes)
        if not rcodes:
            return None
        return rcodes[0] 
开发者ID:CZ-NIC,项目名称:deckard,代码行数:18,代码来源:scenario.py

示例6: __call__

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

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def _handle_query_error(self, request, rcode):
        """
        Construct an error response with the rcode passed in.
        :param request: The decoded request from the wire.
        :param rcode: The response code to send back.
        :return: A dns response message with the response code set to rcode
        """
        response = dns.message.make_response(request)
        response.set_rcode(rcode)

        return response 
开发者ID:openstack,项目名称:designate,代码行数:13,代码来源:handler.py

示例8: _create_axfr_renderer

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def _create_axfr_renderer(self, request):
        # Build up a dummy response, we're stealing it's logic for building
        # the Flags.
        response = dns.message.make_response(request)
        response.flags |= dns.flags.AA
        response.set_rcode(dns.rcode.NOERROR)

        max_message_size = self._get_max_message_size(request.had_tsig)

        renderer = dns.renderer.Renderer(
            response.id, response.flags, max_message_size)
        for q in request.question:
            renderer.add_question(q.name, q.rdtype, q.rdclass)
        return renderer 
开发者ID:openstack,项目名称:designate,代码行数:16,代码来源:handler.py

示例9: _handle_query_error

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def _handle_query_error(request, rcode):
        """
        Construct an error response with the rcode passed in.
        :param request: The decoded request from the wire.
        :param rcode: The response code to send back.
        :return: A dns response message with the response code set to rcode
        """
        response = dns.message.make_response(request)
        response.set_rcode(rcode)

        return response 
开发者ID:openstack,项目名称:designate,代码行数:13,代码来源:handler.py

示例10: rcode

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

示例11: set_rcode

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def set_rcode(self, rcode):
        """Set the rcode.
        @param rcode: the rcode
        @type rcode: int
        """
        (value, evalue) = dns.rcode.to_flags(rcode)
        self.flags &= 0xFFF0
        self.flags |= value
        self.ednsflags &= long(0x00FFFFFF)
        self.ednsflags |= evalue
        if self.ednsflags != 0 and self.edns < 0:
            self.edns = 0 
开发者ID:elgatito,项目名称:script.elementum.burst,代码行数:14,代码来源:message.py

示例12: set_rcode

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def set_rcode(self, rcode):
        """Set the rcode.
        @param rcode: the rcode
        @type rcode: int
        """
        (value, evalue) = dns.rcode.to_flags(rcode)
        self.flags &= 0xFFF0
        self.flags |= value
        self.ednsflags &= 0x00FFFFFFL
        self.ednsflags |= evalue
        if self.ednsflags != 0 and self.edns < 0:
            self.edns = 0 
开发者ID:blackye,项目名称:luscan-devel,代码行数:14,代码来源:message.py

示例13: match_rcode

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def match_rcode(exp, got):
    return compare_val(dns.rcode.to_text(exp.rcode()),
                       dns.rcode.to_text(got.rcode())) 
开发者ID:CZ-NIC,项目名称:deckard,代码行数:5,代码来源:matchpart.py

示例14: __init__

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def __init__(self, query: dns.message.Message) -> None:
        message = dns.message.make_response(query)
        message.set_rcode(dns.rcode.SERVFAIL)
        super().__init__(message) 
开发者ID:CZ-NIC,项目名称:deckard,代码行数:6,代码来源:scenario.py

示例15: process_reply_line

# 需要导入模块: import dns [as 别名]
# 或者: from dns import rcode [as 别名]
def process_reply_line(self):
        """Extracts flags, rcode and opcode from given node and adjust dns message accordingly"""
        self.fields = [f.value for f in self.node.match("/reply")]
        if 'DO' in self.fields:
            self.message.want_dnssec(True)
        opcode = self.get_opcode(fields=self.fields)
        rcode = self.get_rcode(fields=self.fields)
        self.message.flags = self.get_flags(fields=self.fields)
        if rcode is not None:
            self.message.set_rcode(rcode)
        if opcode is not None:
            self.message.set_opcode(opcode) 
开发者ID:CZ-NIC,项目名称:deckard,代码行数:14,代码来源:scenario.py


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