AlkantarClanX12
Current Path : /proc/self/root/usr/lib/python3.6/site-packages/dns/__pycache__/ |
Current File : //proc/self/root/usr/lib/python3.6/site-packages/dns/__pycache__/message.cpython-36.pyc |
3 �@�Wy� � @ s� d Z ddlmZ ddlmZ ddlZddlZddlZddl Zddl ZddlZddlZddl ZddlZddlZddlZddlZddlZddlZddlZddlZddlmZmZmZ G dd� dejj�ZG d d � d ejj�ZG dd� dejj�ZG d d� dejj�Z G dd� dejj�Z!G dd� dejj�Z"G dd� de#�Z$G dd� de#�Z%d(dd�Z&G dd� de#�Z'dd� Z(d d!� Z)ej*j+ddddddfd"d#�Z,d)d&d'�Z-dS )*zDNS Messages� )�absolute_import)�StringION� )�long�xrange�string_typesc @ s e Zd ZdZdS )�ShortHeaderz2The DNS packet passed to from_wire() is too short.N)�__name__� __module__�__qualname__�__doc__� r r �/usr/lib/python3.6/message.pyr * s r c @ s e Zd ZdZdS )�TrailingJunkzEThe DNS packet passed to from_wire() has extra junk at the end of it.N)r r r r r r r r r / s r c @ s e Zd ZdZdS )�UnknownHeaderFieldzVThe header field name was not recognized when converting from text into a message.N)r r r r r r r r r 4 s r c @ s e Zd ZdZdS )�BadEDNSzVOPT record occurred somewhere other than the start of the additional data section.N)r r r r r r r r r : s r c @ s e Zd ZdZdS )�BadTSIGzWA TSIG record occurred somewhere other than the end of the additional data section.N)r r r r r r r r r @ s r c @ s e Zd ZdZdS )�UnknownTSIGKeyz(A TSIG with an unknown key was received.N)r r r r r r r r r F s r c @ s� e Zd ZdZd-dd�Zdd� Zdd� Zd.d d�Zdd � Zdd� Z dd� Z dd� Zej jdddfdd�Zej jdddfdd�Zd/dd�Zdddddejjfdd�Zd0d!d"�Zd1d#d$�Zd%d&� Zd'd(� Zd)d*� Zd+d,� ZdS )2�Messagea, A DNS message. @ivar id: The query id; the default is a randomly chosen id. @type id: int @ivar flags: The DNS flags of the message. @see: RFC 1035 for an explanation of these flags. @type flags: int @ivar question: The question section. @type question: list of dns.rrset.RRset objects @ivar answer: The answer section. @type answer: list of dns.rrset.RRset objects @ivar authority: The authority section. @type authority: list of dns.rrset.RRset objects @ivar additional: The additional data section. @type additional: list of dns.rrset.RRset objects @ivar edns: The EDNS level to use. The default is -1, no Edns. @type edns: int @ivar ednsflags: The EDNS flags @type ednsflags: long @ivar payload: The EDNS payload size. The default is 0. @type payload: int @ivar options: The EDNS options @type options: list of dns.edns.Option objects @ivar request_payload: The associated request's EDNS payload size. @type request_payload: int @ivar keyring: The TSIG keyring to use. The default is None. @type keyring: dict @ivar keyname: The TSIG keyname to use. The default is None. @type keyname: dns.name.Name object @ivar keyalgorithm: The TSIG algorithm to use; defaults to dns.tsig.default_algorithm. Constants for TSIG algorithms are defined in dns.tsig, and the currently implemented algorithms are HMAC_MD5, HMAC_SHA1, HMAC_SHA224, HMAC_SHA256, HMAC_SHA384, and HMAC_SHA512. @type keyalgorithm: string @ivar request_mac: The TSIG MAC of the request message associated with this message; used when validating TSIG signatures. @see: RFC 2845 for more information on TSIG fields. @type request_mac: string @ivar fudge: TSIG time fudge; default is 300 seconds. @type fudge: int @ivar original_id: TSIG original id; defaults to the message's id @type original_id: int @ivar tsig_error: TSIG error code; default is 0. @type tsig_error: int @ivar other_data: TSIG other data. @type other_data: string @ivar mac: The TSIG MAC for this message. @type mac: string @ivar xfr: Is the message being used to contain the results of a DNS zone transfer? The default is False. @type xfr: bool @ivar origin: The origin of the zone in messages which are used for zone transfers or for DNS dynamic updates. The default is None. @type origin: dns.name.Name object @ivar tsig_ctx: The TSIG signature context associated with this message. The default is None. @type tsig_ctx: hmac.HMAC object @ivar had_tsig: Did the message decoded from wire format have a TSIG signature? @type had_tsig: bool @ivar multi: Is this message part of a multi-message sequence? The default is false. This variable is used when validating TSIG signatures on messages which are part of a zone transfer. @type multi: bool @ivar first: Is this message standalone, or the first of a multi message sequence? This variable is used when validating TSIG signatures on messages which are part of a zone transfer. @type first: bool @ivar index: An index of rrsets in the message. The index key is (section, name, rdclass, rdtype, covers, deleting). Indexing can be disabled by setting the index to None. @type index: dict Nc C s� |d krt jj� | _n|| _d| _g | _g | _g | _g | _d| _ d| _ d| _g | _d| _ d | _d | _t jj| _d| _d| _d| _d| _| j| _d| _d| _d | _d | _d| _d| _d| _i | _d S )Nr r � i, FT���) �dnsZentropyZ random_16�id�flags�question�answer� authority� additional�edns� ednsflags�payload�options�request_payload�keyring�keyname�tsig�default_algorithm�keyalgorithm�request_mac� other_data� tsig_error�fudge�original_id�mac�xfr�origin�tsig_ctx�had_tsig�multi�first�index)�selfr r r r �__init__� s: zMessage.__init__c C s dt | j� d S )Nz<DNS message, ID �>)�reprr )r5 r r r �__repr__� s zMessage.__repr__c C s | j � S )N)�to_text)r5 r r r �__str__� s zMessage.__str__Tc K s t � }|jd| j � |jdtjjtjj| j�� � tjj| j| j �}|jdtjj|� � |jdtjj| j� � | j dkr�|jd| j � | j dkr�|jdtjj| j � � |jd| j � tjj | j�}|r�|jd � n |jd � x.| jD ]$}|j|j||f|�� |jd� q�W |�r,|jd� n |jd � x0| jD ]&}|j|j||f|�� |jd� �q>W |�rz|jd� n |jd� x0| jD ]&}|j|j||f|�� |jd� �q�W |jd� x0| jD ]&}|j|j||f|�� |jd� �q�W |j� dd� S )z�Convert the message to text. The I{origin}, I{relativize}, and any other keyword arguments are passed to the rrset to_wire() method. @rtype: string zid %d z opcode %s z rcode %s z flags %s r zedns %s z eflags %s zpayload %d z;ZONE z ;QUESTION � z;PREREQ z;ANSWER z;UPDATE z;AUTHORITY z;ADDITIONAL Nr r )r �writer r �opcoder: � from_flagsr �rcoder r Zedns_to_textr � is_updater r r r �getvalue)r5 r/ � relativize�kw�sZrcrA �rrsetr r r r: � sJ zMessage.to_textc C s� t |t�sdS | j|jkrdS | j|jkr.dS x| jD ]}||jkr6dS q6W x|jD ]}|| jkrTdS qTW x| jD ]}||jkrrdS qrW x|jD ]}|| jkr�dS q�W x| jD ]}||jkr�dS q�W x|jD ]}|| jkr�dS q�W dS )z�Two messages are equal if they have the same content in the header, question, answer, and authority sections. @rtype: boolFT)� isinstancer r r r r r )r5 �other�nr r r �__eq__� s2 zMessage.__eq__c C s | j |� S )z0Are two messages not equal? @rtype: bool)rJ )r5 rH r r r �__ne__ s zMessage.__ne__c C s� |j tj j@ dks:| j|jks:tjj| j �tjj|j �kr>dS tjj|j |j�tjjkr\dS tjj | j �rndS x| j D ]}||j krvdS qvW x|j D ]}|| j kr�dS q�W dS )z1Is other a response to self? @rtype: boolr FT)r r �QRr r>