HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/dns/__pycache__/zonefile.cpython-310.pyc
o

!wem�@s�dZddlZddlZddlmZmZmZmZmZm	Z	m
Z
ddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZGdd�dejj�ZGdd�dejj�Zdd	�Ze	e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	dedee
ejj e.fdee!dee
ej+j/e.fde
ej+j/e.fdee
ej0j1e.fdee
e!e.fdeejj2dee
ejj e.fde"deej3j4fdd�Z5dS) z
DNS Zones.�N)�Any�Iterable�List�Optional�Set�Tuple�Unionc@�eZdZdZdS)�
UnknownOriginzUnknown originN��__name__�
__module__�__qualname__�__doc__�rr�E/home/arjun/projects/env/lib/python3.10/site-packages/dns/zonefile.pyr
&�r
c@r	)�CNAMEAndOtherDataz!A node has a CNAME and other dataNrrrrrr*rrcCs|tjj�|�}|�|�}|durdS|��}|tjjjkr(|tjjjkr(td��|tjjjkr:|tjjjkr<td��dSdS)Nz1rdataset type is not compatible with a CNAME nodez9CNAME rdataset is not compatible with a regular data node)	�dns�node�NodeKind�classify_rdataset�get_node�classify�CNAME�REGULARr)�txn�name�rdataset�
rdataset_kindr�	node_kindrrr�_check_cname_and_other_data.s
��r!cCs|��}|�d�s
d|}|S)N�$)�upper�
startswith)�srrr�_upper_dollarizeQs
r&c@s�eZdZdZ							ddejjdejjdej	j
ded	eee
efd
eejjdeedeejjd
eejjdeefdd�Zdd�Zdd�Zdd�Zdedeeeeeeffdd�Zdd�Zd 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|_|dur|}
|
dur(d|_d|_	n|
|_d|_	|j|_
||_||_g|_
d|_||durRhd�|_|rQ|j�d�n|dur[t�|_n
tdd�|D��|_||_||_||_|	|_|j�t�dS)NrFT>�$TTL�$ORIGIN�	$GENERATE�$INCLUDEcss�|]}t|�VqdS�N)r&)�.0�drrr�	<genexpr>�s�z"Reader.__init__.<locals>.<genexpr>)r(�manager�origin_information�zone_origin�
relativize�current_origin�last_ttl�last_ttl_knownr0�default_ttl_known�	last_name�zone_rdclassr�saved_state�current_file�allowed_directives�add�setr,r-r.r/�check_put_rdatasetr!)�selfr(r)rr*r+r,r-r.r/r0�_rrr�__init__\s>

�
zReader.__init__cCs	|j��}|��rdSqr5)r(�get�
is_eol_or_eof�rI�tokenrrr�	_eat_line�s

�zReader._eat_linecCs|j��}|��s
tjj�|Sr5)r(rL�
is_identifierr�	exception�SyntaxErrorrNrrr�_get_identifier�s
zReader._get_identifierc	
Cs&d}|jdur|j}nE|jdurt�|jjdd�}|��s'|j�||j�|_n|j��}|��r2dS|j�	|�|j}|�
|j�sG|��dS|j
rP|�
|j�}|jdur_|j}||_d|_n)|��}d}ztj�|j�}||_d|_d}Wntjjy�|j�	|�Ynw|jdur�|j}n4|��}z	tj�|j�}Wntjjy��ty�|j}|j�	|�Ynw||jkr�tj�d��|dur�|��}d}ztj�|j�}||_d|_d}Wntjjy�|jr�|j}n|jr�|j}|j�	|�Ynw|jdu�r	|j}n|��}z	tj �|j�}Wnt�y'tj�d|j��wztj!�|||j|j|j
|j�}Wn*tjj�yD�t�yct"�#�dd�\}}tj�d�$t%|�t%|����w|j�s~|tj j&k�r~|j'|_d|_|du�r~|j'}|du�r�tj�d��|j(�)|||�dS)	z&Process one line from a DNS zone file.NT)�want_leading�RR class is not zone's class�unknown rdatatype '%s'�zcaught exception {}: {}�Missing default TTL value)*r,r=r
r(rL�
is_whitespace�as_namerArM�unget�is_subdomainr;rPr<r-r>r?rTr�ttl�	from_text�value�BadTTLr.�
rdataclassrRrS�	ExceptionrBr@r0r/�	rdatatype�rdata�sys�exc_info�format�str�SOA�minimumrrF)	rIrOrr^r)�rdtype�rd�ty�varrr�_rr_line�s�



�
�
�����

zReader._rr_line�side�returnc
Cst�d�}t�d�}t�d�}|�|�}|r%|��\}}}}	}
|dkr%d}|�|�}|r=|��\}}}|dkr9d}d}	d}
|�|�}|rT|��\}}}}	|dkrRd}d}
|sd|sd|sdd}d}d}d}	d}
t|�}t|	�}	|dvrxtj�d	|��|
d
vr�tj�d|
��||||	|
fS)Nz"^.*\$({(\+|-?)(\d+),(\d+),(.)}).*$z^.*\$({(\+|-?)(\d+)}).*$z^.*\$({(\+|-?)(\d+),(\d+)}).*$��+rr7)rt�-zinvalid offset sign %s)r7�o�x�X�n�Nzinvalid type %s)�re�compile�match�groups�intrrRrS)
rIrq�is_generate1�is_generate2�is_generate3�g1�mod�sign�offset�width�base�g2�g3rrr�
_parse_modifysD





zReader._parse_modifyc
s�|jdurt�|j��}ztj�|j�\}}}|j��}|��s$tj	j
�Wnty0tj	j
�wz|j}|j��}|��sBtj	j
�WntyNtj	j
�wztj�|j�}||_
d|_|j��}|��sjtj	j
�Wn$tjjy�|js�|js�tj	�
d��|jr�|j}n|jr�|j
}Ynwztj�|j�}|j��}|��s�tj	j
�Wntj	j
y�tj	j
�ty�|j}Ynw||jkr�tj	�
d��ztj�|j�}|j��}|��s�tj	j
�Wnty�tj	�
d|j��w|j}	dtdtdtd	tfd
d�}
dtd
tdtd	tf�fdd��|�|�\}}}
}}|�|	�\}}}}}t||d|�D]�}|
|||
�}|
|||�}�|||�}�|||�}|�d||�}|	�d||�}tj�||j|jj�|_|j}|�|j��ss|��dS|j �r}|� |j�}ztj!�||||j|j |j�}Wn*tj	j
�y��t�y�t"�#�dd�\}}tj	�
dt|�t|�f��w|j$�%|||��q,dS)zPProcess one line containing the GENERATE statement from a DNS
        zone file.NTrYrVrW�counter�offset_signr�rrcSs|dkr|d9}||S)z0Calculate the index from the counter and offset.ru���r)r�r�r�rrr�_calculate_index�sz/Reader._generate_line.<locals>._calculate_index�indexr�r�csT|dvrt||��|�S�|d|�}d�|ddd��d|�}|dkr(|��}|S)zVFormat the index with the given base, and zero-fill it
            to the given width.)r7rvrwrxrw�.Nr�rz)rh�zfill�joinr#)r�r�r��hexa�nibbles��
_format_indexrrr��sz,Reader._generate_line.<locals>._format_index�z$%srXzcaught exception %s: %s)&r=r
r(rLr�granger_r`rQrRrSrcr^r>r?rar@r0rbrBrdrrir��range�replacer�
idna_codecrAr]r;rPr<rerfrgrrF)rIrO�start�stop�step�lhsr^r)rl�rhsr��lmod�lsign�loffset�lwidth�lbase�rmod�rsign�roffset�rwidth�rbase�i�lindex�rindex�lzfindex�rzfindexrrermrnrorr�r�_generate_lineAs�


��
��
���
�
�

��
�����zReader._generate_linec	
Cs��z,	|j�dd�}|��r9|jdur|j��t|j�dkr6|j�d�\|_|_|_	|_|_
|_|_|_
qWdS|��r>q|��rH|j��q|jddk�r#t|j�dk�r#|j��}||jvrltj�d|�d���|d	kr�|j��}|��stj�d
��tj�|j�|_d|_
|j��n�|dkr�|j��|_|j��|jdur�|j|_|j�|j�nr|dk�r|j��}|j}|j��}|��r�tj�|j|j|jj�}|j��n
|� �s�tj�d
��|j}|j�!|j|j|j	|j|j
|j|j|j
f�t"|d�|_tj#�$|j|�|_||_n|dk�r|�%�n
tj�d|�d���q|j�&|�|�'�qtjj�ya}z%|j�(�\}}|du�rFd}tj�d|||f�}t)�*�d}|�+|�d�d}~ww)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
        r�TNrr�r"zzone file directive 'z' is not allowedr1zbad $TTLr2r4zbad origin in $INCLUDE�rr3zUnknown zone file directive '�'zsyntax errorz	%s:%d: %srX),r(rL�is_eofrD�close�lenrC�popr=rAr>r?r0r@�is_eol�
is_comment�get_eolr`rEr#rrRrSrQr^r_�get_namer;r�_set_originrr�rM�append�open�	tokenizer�	Tokenizerr�r\rp�whererfrg�with_traceback)	rIrO�c�filename�
new_origin�detail�line_number�ex�tbrrr�read�s�



�
 


�





���


��R
���zReader.read)FTNNNNN)rrN)rr
rrrr�r�rb�
RdataClass�transaction�Transaction�boolrrrirr�Namerrd�	RdataTyperKrPrTrprr�r�r�rrrrr'XsJ������
��
	�

�
�2 z-r'csteZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Z�ZS)�RRsetsReaderTransactioncs"|rJ�t��|||�i|_dSr5)�superrK�	rdatasets)rIr9�replacement�	read_only��	__class__rrrK,s
z RRsetsReaderTransaction.__init__cCs|j�|||f�Sr5)r�rL�rIrrl�coversrrr�
_get_rdataset1sz%RRsetsReaderTransaction._get_rdatasetcCsTg}|j��D]\\}}}}||kr|�|�qt|�dkr dStj��}||_|S�Nr)r��itemsr�r�rr�Node)rIrr��
rdataset_namerJrrrrr�	_get_node4s
�
z!RRsetsReaderTransaction._get_nodecCs||j||j|jf<dSr5)r�rlr�)rIrrrrr�
_put_rdataset?sz%RRsetsReaderTransaction._put_rdatasetcCsLg}|jD]
}|d|kr|�|�qt|�dkr"|D]}|j|=qdSdSr�)r�r�r�)rIr�remove�keyrrr�_delete_nameBs

�
�z$RRsetsReaderTransaction._delete_namecCs*z
|j|||f=WdStyYdSwr5)r��KeyErrorr�rrr�_delete_rdatasetLs
�z(RRsetsReaderTransaction._delete_rdatasetcCs$|jD]\}}}||krdSqdS�NTF)r�)rIrryrJrrr�_name_existsRs
�z$RRsetsReaderTransaction._name_existscCst|j�dkSr�)r�r��rIrrr�_changedXsz RRsetsReaderTransaction._changedcCsn|r3|��r5g}|j��D]\\}}}}tj�||j|j|j�}|�	|�|�
|�q
|j�|�dSdSdSr5)
r�r�r�r�rrset�RRsetr)rlr��updater�r9�
set_rrsets)rI�commit�rrsetsrrJrr�rrr�_end_transaction[s�
�z(RRsetsReaderTransaction._end_transactioncCsdSr5r)rI�originrrrr�f�z#RRsetsReaderTransaction._set_origincC�t�r5��NotImplementedErrorr�rrr�_iterate_rdatasetsir�z*RRsetsReaderTransaction._iterate_rdatasetscCr�r5r�r�rrr�_iterate_nameslr�z&RRsetsReaderTransaction._iterate_names)rr
rrKr�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr�rr�+s
r�c@sNeZdZejjdejjfdd�Zdd�Z	ddd�Z
dd	�Zd
d�Zdd
�Z
dS)�RRSetsReaderManagerFcCs||_||_||_g|_dSr5)r�r<r)r�)rIr�r<r)rrrrKqs
zRRSetsReaderManager.__init__cCr�r5r�r�rrr�readeryr�zRRSetsReaderManager.readercCs|dusJ�t|dd�Sr�)r�)rIr�rrr�writer|szRRSetsReaderManager.writercCs|jSr5)r)r�rrr�	get_class�szRRSetsReaderManager.get_classcCs$|jrtjj}n|j}|j|j|fSr5)r<rr�emptyr�)rI�	effectiverrrr:�s
z&RRSetsReaderManager.origin_informationcCs
||_dSr5)r�)rIr�rrrr��s
zRRSetsReaderManager.set_rrsetsN)F)rr
rrr�rootrb�INrKr�r�r�r:r�rrrrr�ps
�
r�F�textrr^r)�default_rdclassrlr0r�r�r<rrc
Cst|t�rtj�|tjj|�}t|t�rtj�|||�}t|t�r'tj�|�}t|t�r2tj�|�}|dur>tjj�	|�}nd}tjj�	|�}|durStj
j�	|�}nd}t||	|�}
|
�
d��$}tjj|d|d�}t|||d|||||d�	}
|
��Wd�|
jS1s�wY|
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>)r�F)r+r,r-r.r/r0)�
isinstancerirrr_r�r^rbr��makerdr�r�r�r�r�r'r�r�)rrr^r)rrlr0r�r�r<r9rr(r�rrr�read_rrsets�sD
=


�

��r)6rr{rf�typingrrrrrrr�
dns.exceptionr�
dns.grange�dns.name�dns.node�	dns.rdata�dns.rdataclass�
dns.rdatatype�dns.rdtypes.ANY.SOA�	dns.rrset�
dns.tokenizer�dns.transaction�dns.ttlrR�DNSExceptionr
rr!r�r�rr�rr��SavedStateTyper&r'r�r�r��TransactionManagerr�rbrr�rir�rdr��	IDNACodecr�r�rrrrr�<module>s�$

��VE ��������
�	�
�
�