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__/zonefile.cpython-37.pyc
B

��f\k�
@s�dZddlmZmZmZmZmZmZmZddl	Z	ddl
Z
ddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZGdd�dejj�ZGdd�dejj�Zdd	�Zeejjeejj eejj eee!e"e!e"fZ#d
d�Z$Gdd
�d
�Z%Gdd�dej&j'�Z(Gdd�dej&j)�Z*ddej+j,ej+j,dddejj-df	eeeejj e.fee!eeej+j/e.feej+j/e.feeej0j1e.feee!e.feejj2eeejj e.fe"eej3j4d�dd�Z5dS)z
DNS Zones.�)�Any�Iterable�List�Optional�Set�Tuple�UnionNc@seZdZdZdS)�
UnknownOriginzUnknown originN)�__name__�
__module__�__qualname__�__doc__�rr�=/opt/alt/python37/lib/python3.7/site-packages/dns/zonefile.pyr	'sr	c@seZdZdZdS)�CNAMEAndOtherDataz!A node has a CNAME and other dataN)r
rrr
rrrrr+srcCsztjj�|�}|�|�}|dkr$dS|��}|tjjjkrR|tjjjkrRtd��n$|tjjjkrv|tjjjkrvtd��dS)Nz1rdataset type is not compatible with a CNAME nodez9CNAME rdataset is not compatible with a regular data node)	�dns�nodeZNodeKindZclassify_rdatasetZget_nodeZclassifyZCNAMEZREGULARr)�txn�name�rdatasetZ
rdataset_kindrZ	node_kindrrr�_check_cname_and_other_data/s

rcCs|��}|�d�sd|}|S)N�$)�upper�
startswith)�srrr�_upper_dollarizeRs
rc@s�eZdZdZdejjejjej	j
eeee
efeejjeeeejjeejjeed�
dd�Zdd	�Zd
d�Zdd
�Zeeeeeeefd�dd�Zdd�Zdd�dd�ZdS)�Readerz(Read a DNS zone file into a transaction.FTN)
�tok�rdclassr�
allow_include�allow_directives�
force_name�	force_ttl�
force_rdclass�force_rdtype�default_ttlcCs�||_|j��\|_|_}|j|_d|_d|_|dk	r:|}
|
dkrPd|_d|_	n|
|_d|_	|j|_
||_||_g|_
d|_||dkr�dddh|_|r�|j�d�n&|dkr�t�|_ntdd	�|D��|_||_||_||_|	|_|j�t�dS)
NrFTz	$GENERATEz$ORIGINz$TTLz$INCLUDEcss|]}t|�VqdS)N)r)�.0�drrr�	<genexpr>�sz"Reader.__init__.<locals>.<genexpr>)r�manager�origin_information�zone_origin�
relativize�current_origin�last_ttl�last_ttl_knownr%�default_ttl_known�	last_name�zone_rdclassr�saved_state�current_file�allowed_directives�add�setr!r"r#r$Zcheck_put_rdatasetr)�selfrrrrr r!r"r#r$r%�_rrr�__init__]s<

zReader.__init__cCsx|j��}|��rPqWdS)N)r�get�
is_eol_or_eof)r8�tokenrrr�	_eat_line�s
zReader._eat_linecCs|j��}|��stjj�|S)N)rr;�
is_identifierr�	exception�SyntaxError)r8r=rrr�_get_identifier�s
zReader._get_identifierc	
Cs�d}|jdk	r|j}n�|jdkr$t�|jjdd�}|��sN|j�||j�|_n"|j��}|��rddS|j�	|�|j}|�
|j�s�|��dS|j
r�|�
|j�}|jdk	r�|j}||_d|_nt|��}d}y"tj�|j�}||_d|_d}WnDtjjk
�r0|j�r|j}n|j�r |j}|j�	|�YnX|jdk	�rF|j}nv|��}ytj�|j�}WnBtjjk
�r|�Yn(tk
�r�|j}|j�	|�YnX||jk�r�tj�d��|jdk	�r�|j}nD|��}ytj �|j�}Wn(tk
�rtj�d|j��YnXy"tj!�|||j|j|j
|j�}Wn`tjjk
�rR�YnFtk
�r�t"�#�dd�\}}tj�d�$t%|�t%|����YnX|j�s�|tj j&k�r�|j'|_d|_|dk�r�|j'}|dk�r�tj�d��|j(�)|||�dS)	z&Process one line from a DNS zone file.NT)Zwant_leadingzRR class is not zone's classzunknown rdatatype '%s'�zcaught exception {}: {}zMissing default TTL value)*r!r-r	rr;Z
is_whitespaceZas_namer1r<�unget�is_subdomainr+r>r,r"r.r/rBr�ttl�	from_text�value�BadTTLr0r%r#�
rdataclassr@rA�	Exceptionr2r$�	rdatatype�rdata�sys�exc_info�format�strZSOAZminimumrr6)	r8r=rrFr�rdtype�rd�ty�varrr�_rr_line�s�





zReader._rr_line)�side�returnc
Cst�d�}t�d�}t�d�}|�|�}|rJ|��\}}}}	}
|dkrJd}|�|�}|rz|��\}}}|dkrrd}d}	d}
|�|�}|r�|��\}}}}	|dkr�d}d}
|s�|s�|s�d}d}d}d}	d}
t|�}t|	�}	|dkr�tj�d	|��|
d
k�r
tj�d|
��||||	|
fS)Nz"^.*\$({(\+|-?)(\d+),(\d+),(.)}).*$z^.*\$({(\+|-?)(\d+)}).*$z^.*\$({(\+|-?)(\d+),(\d+)}).*$��+rr')rZ�-zinvalid offset sign %s)r'�o�x�X�n�Nzinvalid type %s)�re�compile�match�groups�intrr@rA)
r8rWZis_generate1Zis_generate2Zis_generate3Zg1�mod�sign�offset�width�baseZg2Zg3rrr�
_parse_modify	sD






zReader._parse_modifyc
s�|jdkrt�|j��}y2tj�|j�\}}}|j��}|��sHtj	j
�Wntk
rftj	j
�YnXy$|j}|j��}|��s�tj	j
�Wntk
r�tj	j
�YnXy8tj�|j�}||_
d|_|j��}|��s�tj	j
�WnTtjjk
�r6|j�s|j�stj	�
d��|j�r$|j}n|j�r2|j
}YnXy.tj�|j�}|j��}|���sdtj	j
�Wn<tj	j
k
�r�tj	j
�Yntk
�r�|j}YnX||jk�r�tj	�
d��y.tj�|j�}|j��}|���s�tj	j
�Wn(tk
�rtj	�
d|j��YnX|j}	ttttd�dd�}
ttttd	��fd
d��|�|�\}}}
}}|�|	�\}}}}}�xJt||d|�D�]4}|
|||
�}|
|||�}�|||�}�|||�}|�d
||�}|	�d
||�}tj�||j|jj�|_|j}|�|j��s|��dS|j �r$|� |j�}y tj!�||||j|j |j�}Wn`tj	j
k
�r`�YnFtk
�r�t"�#�dd�\}}tj	�
dt|�t|�f��YnX|j$�%|||��q�WdS)zPProcess one line containing the GENERATE statement from a DNS
        zone file.NTzMissing default TTL valuezRR class is not zone's classzunknown rdatatype '%s')�counter�offset_signrhrXcSs|dkr|d9}||S)z0Calculate the index from the counter and offset.r[���r)rlrmrhrrr�_calculate_indexwsz/Reader._generate_line.<locals>._calculate_index)�indexrjrirXcsT|dkrt||��|�S�|d|�}d�|ddd��d|�}|dkrP|��}|S)zVFormat the index with the given base, and zero-fill it
            to the given width.)r'r\r]r^r]�.Nrnr`)rP�zfill�joinr)rprjriZhexaZnibbles)�
_format_indexrrrt}sz,Reader._generate_line.<locals>._format_index�z$%srCzcaught exception %s: %s)&r-r	rr;rZgrangerGrHr?r@rArKrFr.r/rIr0r%rJr2rLrerQrk�range�replacer�
idna_codecr1rEr+r>r,rMrNrOrr6)r8r=�start�stop�step�lhsrFrrR�rhsroZlmodZlsignZloffsetZlwidthZlbaseZrmodZrsignZroffsetZrwidthZrbase�iZlindex�rindexZlzfindexZrzfindexrrMrSrTrUr)rtr�_generate_line6s�









zReader._generate_line)rXc	
Cs��yv�xn|j�dd�}|��rt|jdk	r2|j��t|j�dkrn|j�d�\|_|_|_	|_|_
|_|_|_
qP�n�|��r�q�n�|��r�|j��q�n�|jddk�r^t|j�dk�r^|j��}||jkr�tj�d|�d���|dk�r.|j��}|���stj�d	��tj�|j�|_d|_
|j��q|d
k�rr|j��|_|j��|jdk�rb|j|_|j�|j�q|dk�r4|j��}|j}|j��}|���r�tj�|j|j|jj�}|j��n|� ��s�tj�d��n|j}|j�!|j|j|j	|j|j
|j|j|j
f�t"|d
�|_tj#�$|j|�|_||_q|dk�rH|�%�qtj�d|�d���q|j�&|�|�'�qWWnrtjjk
�r�}zN|j�(�\}}|dk�r�d}tj�d|||f�}t)�*�d}|�+|�d�Wdd}~XYnXdS)z�Read a DNS zone file and build a zone object.

        @raises dns.zone.NoSOA: No SOA RR was found at the zone origin
        @raises dns.zone.NoNS: No NS RRset was found at the zone origin
        TNrrnrzzone file directive 'z' is not allowedz$TTLzbad $TTLz$ORIGINz$INCLUDEzbad origin in $INCLUDE�rz	$GENERATEzUnknown zone file directive '�'zsyntax errorz	%s:%d: %srC),rr;Zis_eofr4�close�lenr3�popr-r1r.r/r%r0Zis_eolZ
is_commentZget_eolrHr5rrr@rAr?rFrG�get_namer+r�_set_originrrxr<�append�open�	tokenizer�	Tokenizerr�rDrV�whererNrO�with_traceback)	r8r=�c�filenameZ
new_originZdetail�line_number�ex�tbrrr�read�s�


,
 















zReader.read)FTNNNNN)r
rrr
rr�r�rJ�
RdataClass�transaction�Transaction�boolrrrQrr�NamererL�	RdataTyper:r>rBrVrrkr�r�rrrrrYsZ'n-rcsleZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�RRsetsReaderTransactioncs"|rt�t��|||�i|_dS)N)�AssertionError�superr:�	rdatasets)r8r)�replacementZ	read_only)�	__class__rrr:!sz RRsetsReaderTransaction.__init__cCs|j�|||f�S)N)r�r;)r8rrR�coversrrr�
_get_rdataset&sz%RRsetsReaderTransaction._get_rdatasetcCsXg}x.|j��D] \\}}}}||kr|�|�qWt|�dkrDdStj��}||_|S)Nr)r��itemsr�r�rr�Node)r8rr�Z
rdataset_namer9rrrrr�	_get_node)s
z!RRsetsReaderTransaction._get_nodecCs||j||j|jf<dS)N)r�rRr�)r8rrrrr�
_put_rdataset4sz%RRsetsReaderTransaction._put_rdatasetcCsPg}x$|jD]}|d|kr|�|�qWt|�dkrLx|D]}|j|=q<WdS)Nr)r�r�r�)r8r�remove�keyrrr�_delete_name7s
z$RRsetsReaderTransaction._delete_namecCs,y|j|||f=Wntk
r&YnXdS)N)r��KeyError)r8rrRr�rrr�_delete_rdatasetAsz(RRsetsReaderTransaction._delete_rdatasetcCs&x |jD]\}}}||krdSqWdS)NTF)r�)r8rr_r9rrr�_name_existsGsz$RRsetsReaderTransaction._name_existscCst|j�dkS)Nr)r�r�)r8rrr�_changedMsz RRsetsReaderTransaction._changedcCsj|rf|��rfg}xH|j��D]:\\}}}}tj�||j|j|j�}|�	|�|�
|�qW|j�|�dS)N)
r�r�r�r�rrset�RRsetrrRr��updater�r)�
set_rrsets)r8�commit�rrsetsrr9rr�rrr�_end_transactionPs
z(RRsetsReaderTransaction._end_transactioncCsdS)Nr)r8�originrrrr�[sz#RRsetsReaderTransaction._set_origincCst�dS)N)�NotImplementedError)r8rrr�_iterate_rdatasets^sz*RRsetsReaderTransaction._iterate_rdatasets)r
rrr:r�r�r�r�r�r�r�r�r�r��
__classcell__rr)r�rr� s
r�c@sNeZdZejjdejjfdd�Zdd�Z	ddd�Z
dd	�Zd
d�Zdd
�Z
dS)�RRSetsReaderManagerFcCs||_||_||_g|_dS)N)r�r,rr�)r8r�r,rrrrr:cszRRSetsReaderManager.__init__cCst�dS)N)r�)r8rrr�readerkszRRSetsReaderManager.readercCs|dkst�t|dd�S)NTF)r�r�)r8r�rrr�writernszRRSetsReaderManager.writercCs|jS)N)r)r8rrr�	get_classrszRRSetsReaderManager.get_classcCs$|jrtjj}n|j}|j|j|fS)N)r,rr�emptyr�)r8Z	effectiverrrr*us
z&RRSetsReaderManager.origin_informationcCs
||_dS)N)r�)r8r�rrrr�|szRRSetsReaderManager.set_rrsetsN)F)r
rrrr�rootrJ�INr:r�r�r�r*r�rrrrr�bs
r�F)�textrrFr�default_rdclassrRr%rxr�r,rXc
Cst|t�rtj�|tjj|�}t|t�r8tj�|||�}t|t�rNtj�|�}t|t�rdtj�|�}|dk	r|tjj�	|�}
nd}
tjj�	|�}|dk	r�tj
j�	|�}nd}t||	|�}
|
�
d��:}tjj|d|d�}t|||d|||
||d�	}|��WdQRX|
jS)a�	Read one or more rrsets from the specified text, possibly subject
    to restrictions.

    *text*, a file object or a string, is the input to process.

    *name*, a string, ``dns.name.Name``, or ``None``, is the owner name of
    the rrset.  If not ``None``, then the owner name is "forced", and the
    input must not specify an owner name.  If ``None``, then any owner names
    are allowed and must be present in the input.

    *ttl*, an ``int``, string, or None.  If not ``None``, the the TTL is
    forced to be the specified value and the input must not specify a TTL.
    If ``None``, then a TTL may be specified in the input.  If it is not
    specified, then the *default_ttl* will be used.

    *rdclass*, a ``dns.rdataclass.RdataClass``, string, or ``None``.  If
    not ``None``, then the class is forced to the specified value, and the
    input must not specify a class.  If ``None``, then the input may specify
    a class that matches *default_rdclass*.  Note that it is not possible to
    return rrsets with differing classes; specifying ``None`` for the class
    simply allows the user to optionally type a class as that may be convenient
    when cutting and pasting.

    *default_rdclass*, a ``dns.rdataclass.RdataClass`` or string.  The class
    of the returned rrsets.

    *rdtype*, a ``dns.rdatatype.RdataType``, string, or ``None``.  If not
    ``None``, then the type is forced to the specified value, and the
    input must not specify a type.  If ``None``, then a type must be present
    for each RR.

    *default_ttl*, an ``int``, string, or ``None``.  If not ``None``, then if
    the TTL is not forced and is not specified, then this value will be used.
    if ``None``, then if the TTL is not forced an error will occur if the TTL
    is not specified.

    *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA
    encoder/decoder.  If ``None``, the default IDNA 2003 encoder/decoder
    is used.  Note that codecs only apply to the owner name; dnspython does
    not do IDNA for names in rdata, as there is no IDNA zonefile format.

    *origin*, a string, ``dns.name.Name``, or ``None``, is the origin for any
    relative names in the input, and also the origin to relativize to if
    *relativize* is ``True``.

    *relativize*, a bool.  If ``True``, names are relativized to the *origin*;
    if ``False`` then any relative names in the input are made absolute by
    appending the *origin*.
    NTz<input>)rxF)r r!r"r#r$r%)�
isinstancerQrrrGr�rFrJr��makerLr�r�r�r�r�rr�r�)r�rrFrr�rRr%rxr�r,Zthe_rdclassZthe_default_rdclassZ
the_rdtyper)rrr�rrr�read_rrsets�s<=



r�)6r
�typingrrrrrrrrarNZ
dns.exceptionrZdns.nameZdns.nodeZdns.rdataclassZ
dns.rdatatypeZ	dns.rdataZdns.rdtypes.ANY.SOAZ	dns.rrsetZ
dns.tokenizerZdns.transactionZdns.ttlZ
dns.granger@ZDNSExceptionr	rrr�r�rr�rer�ZSavedStateTyperrr�r�r�ZTransactionManagerr�rJr�r�rQr�rLr�Z	IDNACodecr�r�r�rrrr�<module>sX$

JB |