HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/dns/__pycache__/node.cpython-37.pyc
B

��fz1�@s�dZddlmZmZmZddlZddlZddlZddl	Zddl
ZddlZddlZddl
ZddlZejjhZejjejjejjhZdd�ZejGdd�dej��ZGdd	�d	�ZejjGd
d�de��ZdS)z)DNS nodes.  A node is a set of rdatasets.�)�Any�Dict�OptionalNcCs||kp|tjjko||kS)N)�dns�	rdatatypeZRRSIG)Zrdtypes�rdtype�covers�r	�9/opt/alt/python37/lib/python3.7/site-packages/dns/node.py�_matches_type_or_its_signature.src@sReZdZdZdZdZdZeej	j
ej	j
dd�dd��Zeejj
dd�d	d
��ZdS)�NodeKindzRdatasets in nodesr��)rr�returncCs.tt||�rtjStt||�r$tjStjSdS)N)r�_cname_typesr�CNAME�_neutral_types�NEUTRAL�REGULAR)�clsrrr	r	r
�classify:s
zNodeKind.classify)�rdatasetrcCs|�|j|j�S)N)rrr)rrr	r	r
�classify_rdatasetEszNodeKind.classify_rdatasetN)�__name__�
__module__�__qualname__�__doc__rrr�classmethodrr�	RdataTyperr�Rdatasetrr	r	r	r
r2src@s(eZdZdZdgZdd�Zejje	e
efe
d�dd�Zdd	�Z
d
d�Zdd
�Zdd�Zdd�Zdd�Zejjdfejjejjejjeejjd�dd�Zejjdfejjejjejjeeejjd�dd�Zejjfejjejjejjdd�dd�Zejjdd�dd �Ze d!�d"d#�Z!ed!�d$d%�Z"dS)&�Nodea�A Node is a set of rdatasets.

    A node is either a CNAME node or an "other data" node.  A CNAME
    node contains only CNAME, KEY, NSEC, and NSEC3 rdatasets along with their
    covering RRSIG rdatasets.  An "other data" node contains any
    rdataset other than a CNAME or RRSIG(CNAME) rdataset.  When
    changes are made to a node, the CNAME or "other data" state is
    always consistent with the update, i.e. the most recent change
    wins.  For example, if you have a node which contains a CNAME
    rdataset, and then add an MX rdataset to it, then the CNAME
    rdataset will be deleted.  Likewise if you have a node containing
    an MX rdataset and add a CNAME rdataset, the MX rdataset will be
    deleted.
    �	rdatasetscCs
g|_dS)N)r!)�selfr	r	r
�__init__]sz
Node.__init__)�name�kwrcKsRt��}x8|jD].}t|�dkr|�|j|f|��|�d�qW|��dd�S)a"Convert a node to text format.

        Each rdataset at the node is printed.  Any keyword arguments
        to this method are passed on to the rdataset's to_text() method.

        *name*, a ``dns.name.Name``, the owner name of the
        rdatasets.

        Returns a ``str``.

        r�
N���)�io�StringIOr!�len�write�to_text�getvalue)r"r$r%�s�rdsr	r	r
r,as
zNode.to_textcCsdtt|��dS)Nz
<DNS node �>)�str�id)r"r	r	r
�__repr__usz
Node.__repr__cCs@x|jD]}||jkrdSqWx|jD]}||jkr&dSq&WdS)NFT)r!)r"�other�rdr	r	r
�__eq__xs

zNode.__eq__cCs|�|�S)N)r6)r"r4r	r	r
�__ne__�szNode.__ne__cCs
t|j�S)N)r*r!)r"r	r	r
�__len__�szNode.__len__cCs
t|j�S)N)�iterr!)r"r	r	r
�__iter__�sz
Node.__iter__cCsbt|j�dkrRt�|�}|tjkr6dd�|jD�|_n|tjkrRdd�|jD�|_|j�|�dS)a�Append rdataset to the node with special handling for CNAME and
        other data conditions.

        Specifically, if the rdataset being appended has ``NodeKind.CNAME``,
        then all rdatasets other than KEY, NSEC, NSEC3, and their covering
        RRSIGs are deleted.  If the rdataset being appended has
        ``NodeKind.REGULAR`` then CNAME and RRSIG(CNAME) are deleted.
        rcSs g|]}t�|�tjkr|�qSr	)rrr)�.0r/r	r	r
�
<listcomp>�sz)Node._append_rdataset.<locals>.<listcomp>cSs g|]}t�|�tjkr|�qSr	)rrr)r;r/r	r	r
r<�sN)r*r!rrrr�append)r"r�kindr	r	r
�_append_rdataset�s



zNode._append_rdatasetF)�rdclassrr�creatercCsHx |jD]}|�|||�r|SqW|s*t�tj�|||�}|�|�|S)a*Find an rdataset matching the specified properties in the
        current node.

        *rdclass*, a ``dns.rdataclass.RdataClass``, the class of the rdataset.

        *rdtype*, a ``dns.rdatatype.RdataType``, the type of the rdataset.

        *covers*, a ``dns.rdatatype.RdataType``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.

        *create*, a ``bool``.  If True, create the rdataset if it is not found.

        Raises ``KeyError`` if an rdataset of the desired type and class does
        not exist and *create* is not ``True``.

        Returns a ``dns.rdataset.Rdataset``.
        )r!�match�KeyErrorrrrr?)r"r@rrrAr/r	r	r
�
find_rdataset�s 
zNode.find_rdatasetcCs2y|�||||�}Wntk
r,d}YnX|S)a�Get an rdataset matching the specified properties in the
        current node.

        None is returned if an rdataset of the specified type and
        class does not exist and *create* is not ``True``.

        *rdclass*, an ``int``, the class of the rdataset.

        *rdtype*, an ``int``, the type of the rdataset.

        *covers*, an ``int``, the covered type.  Usually this value is
        dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or
        dns.rdatatype.RRSIG, then the covers value will be the rdata
        type the SIG/RRSIG covers.  The library treats the SIG and RRSIG
        types as if they were a family of
        types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).  This makes RRSIGs much
        easier to work with than if RRSIGs covering different rdata
        types were aggregated into a single RRSIG rdataset.

        *create*, a ``bool``.  If True, create the rdataset if it is not found.

        Returns a ``dns.rdataset.Rdataset`` or ``None``.
        N)rDrC)r"r@rrrAr/r	r	r
�get_rdataset�s

zNode.get_rdatasetN)r@rrrcCs&|�|||�}|dk	r"|j�|�dS)aDDelete the rdataset matching the specified properties in the
        current node.

        If a matching rdataset does not exist, it is not an error.

        *rdclass*, an ``int``, the class of the rdataset.

        *rdtype*, an ``int``, the type of the rdataset.

        *covers*, an ``int``, the covered type.
        N)rEr!�remove)r"r@rrr/r	r	r
�delete_rdataset�szNode.delete_rdataset)�replacementrcCsNt|tjj�std��t|tjj�r,|��}|�|j	|j
|j�|�|�dS)a�Replace an rdataset.

        It is not an error if there is no rdataset matching *replacement*.

        Ownership of the *replacement* object is transferred to the node;
        in other words, this method does not store a copy of *replacement*
        at the node, it stores *replacement* itself.

        *replacement*, a ``dns.rdataset.Rdataset``.

        Raises ``ValueError`` if *replacement* is not a
        ``dns.rdataset.Rdataset``.
        zreplacement is not an rdatasetN)
�
isinstancerrr�
ValueErrorZrrsetZRRsetZto_rdatasetrGr@rrr?)r"rHr	r	r
�replace_rdataset
szNode.replace_rdataset)rcCs4x,|jD]"}t�|j|j�}|tjkr|SqWtjS)aTClassify a node.

        A node which contains a CNAME or RRSIG(CNAME) is a
        ``NodeKind.CNAME`` node.

        A node which contains only "neutral" types, i.e. types allowed to
        co-exist with a CNAME, is a ``NodeKind.NEUTRAL`` node.  The neutral
        types are NSEC, NSEC3, KEY, and their associated RRSIGS.  An empty node
        is also considered neutral.

        A node which contains some rdataset which is not a CNAME, RRSIG(CNAME),
        or a neutral type is a a ``NodeKind.REGULAR`` node.  Regular nodes are
        also commonly referred to as "other data".
        )r!rrrrr)r"rr>r	r	r
r's

z
Node.classifycCsdS)NFr	)r"r	r	r
�is_immutable<szNode.is_immutable)#rrrr�	__slots__r#rr$�Namerr1rr,r3r6r7r8r:r?r�NONE�
rdataclass�
RdataClassr�boolrrrDrrErGrKrrrLr	r	r	r
r Js* '#r cs�eZdZ�fdd�Zejjdfejjejj	ejj	e
ejjd��fdd�
Z
ejjdfejjejj	ejj	e
eejjd��fdd�
Zejjfejjejj	ejj	d	d
�dd�Zejjd	d
�dd�Ze
d�dd�Z�ZS)�
ImmutableNodecs$t���tdd�|jD��|_dS)NcSsg|]}tj�|��qSr	)rrZImmutableRdataset)r;r/r	r	r
r<Esz*ImmutableNode.__init__.<locals>.<listcomp>)�superr#�tupler!)r"�node)�	__class__r	r
r#Bs
zImmutableNode.__init__F)r@rrrArcs|rtd��t��|||d�S)N�	immutableF)�	TypeErrorrTrD)r"r@rrrA)rWr	r
rDHszImmutableNode.find_rdatasetcs|rtd��t��|||d�S)NrXF)rYrTrE)r"r@rrrA)rWr	r
rESszImmutableNode.get_rdatasetN)r@rrrcCstd��dS)NrX)rY)r"r@rrr	r	r
rG^szImmutableNode.delete_rdataset)rHrcCstd��dS)NrX)rY)r"rHr	r	r
rKfszImmutableNode.replace_rdataset)rcCsdS)NTr	)r"r	r	r
rLiszImmutableNode.is_immutable)rrrr#rrrOrPrQrrRrrrDrrErGrKrL�
__classcell__r	r	)rWr
rS@s
		rS)r�typingrrr�enumr(Z
dns.immutablerZdns.nameZdns.rdataclassZdns.rdatasetZ
dns.rdatatypeZ	dns.rrsetZdns.rendererrrrZNSECZNSEC3ZKEYrr�unique�Enumrr rXrSr	r	r	r
�<module>s*


w