當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。