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__/xfr.cpython-310.pyc
o

!we�3�@srddlmZmZmZmZmZddlZddlZddl	Zddl
ZddlZddlZddl
ZddlZddlZddlZGdd�dejj�ZGdd�dejj�ZGdd�dejj�ZGd	d
�d
�Zddddddddejjf	dejjdeed
eeeefdeedeedeedeeejjdedeej j!deej j!e"fdeej#j$eeffdd�Z%dej#j&deefdd�Z'dS)�)�Any�List�Optional�Tuple�UnionNcs eZdZdZ�fdd�Z�ZS)�
TransferErrorz.A zone transfer response got a non-zero rcode.cs&dtj�|�}t��|�||_dS)NzZone transfer error: %s)�dns�rcode�to_text�super�__init__)�selfr	�message��	__class__��@/home/arjun/projects/env/lib/python3.10/site-packages/dns/xfr.pyr#s
zTransferError.__init__)�__name__�
__module__�__qualname__�__doc__r�
__classcell__rrrrr src@�eZdZdZdS)�SerialWentBackwardsz:The current serial number is less than the serial we know.N�rrrrrrrrr)�rc@r)�UseTCPz'This IXFR cannot be completed with UDP.Nrrrrrr-rrc	@sheZdZdZejjddfdejjdejj	de
edefdd	�Z
d
ejjdefdd
�Zdd�Zdd�ZdS)�Inboundz+
    State machine for zone transfers.
    NF�txn_manager�rdtype�serial�is_udpcCst||_d|_||_|tjjkr|durtd��n|rtd��||_||_|�	�\}}|_
d|_d|_d|_
d|_dS)aqInitialize an inbound zone transfer.

        *txn_manager* is a :py:class:`dns.transaction.TransactionManager`.

        *rdtype* can be `dns.rdatatype.AXFR` or `dns.rdatatype.IXFR`

        *serial* is the base serial number for IXFRs, and is required in
        that case.

        *is_udp*, a ``bool`` indidicates if UDP is being used for this
        XFR.
        Nz,a starting serial must be supplied for IXFRszis_udp specified for AXFRF)r�txnrr�	rdatatype�IXFR�
ValueErrorr r!�origin_information�origin�soa_rdataset�done�
expecting_SOA�delete_mode)r
rrr r!�_rrrr6s �
zInbound.__init__r�returncCsT|jdur|jtjjk}|j�|�|_|��}|tjjkr!t	|��t
|j�dkrF|jdj|j
kr7tj�d��|jdj|jkrFtj�d��d}|jdur�|jrY|jdj|j
kr_tj�d��|jd}|}|jtjjkrstj�d��d}|��|_|jtjjkr�|jdj|jkr�d|_n"tj�|jdj�|jkr�t�|jr�t
|j|d��dkr�t�d|_|j|d�D]�}|j}|}|jr�tj�d	��|jdus�J�|jtjjk�rj||j
k�rj|jtjjkr�|j|_||jk�r6|jtjjk�s|jtjjk�r6|j�r6|j�rtj�d
��|jtjjk�r#|j|djk�r#tj�d��|j�||�|j��d|_d|_n3d|_|jtjjk�rc|j�rU|dj|jk�rTtj�d
��n|dj|_|j�||�ntj�d��q�|j�r�tjj|_d|_d|_|j��|j�d�|_|j�r�|j� ||�q�|j�!||�q�|j�r�|j�s�tj�d��|jS)aZProcess one message in the transfer.

        The message should have the same relativization as was specified when
        the `dns.xfr.Inbound` was created.  The message should also have been
        created with `one_rr_per_rrset=True` because order matters.

        Returns `True` if the transfer is complete, and `False` otherwise.
        Nrzwrong question namezwrong question rdatatypez&No answer or RRset not for zone originzfirst RRset is not an SOA�Tzanswers after final SOAzempty IXFR sequencezunexpected end of IXFR sequenceFzIXFR base serial mismatchzunexpected origin SOA in AXFRzunexpected end of UDP IXFR)"r"rrr#�AXFRr�writerr	�NOERRORr�len�question�namer'�	exception�	FormErrorr(�answer�SOA�copyr$r r)�Serialrr!rr*r+�replace�commit�rollback�delete_exact�add)r
r�replacementr	�answer_index�rrset�rdatasetr4rrr�process_messageYs�
	




��

zInbound.process_messagecCs|S)Nr)r
rrr�	__enter__�szInbound.__enter__cCs|jr|j��dS)NF)r"r=)r
�exc_type�exc_val�exc_tbrrr�__exit__�s
zInbound.__exit__)rrrrrr#r/�transaction�TransactionManager�	RdataTyper�int�boolrr�MessagerDrErIrrrrr1s$����
�#rrr �use_edns�	ednsflags�payload�request_payload�options�keyring�keyname�keyalgorithmr-c
CsP|��\}
}}|
durtd��|durtjj}
nKt|t�s!td��|dkrR|��� }|�|d�}|r<|dj	}tjj
}
nd}tjj}
Wd�n1sLwYn|dkr_|dkr_tjj
}
ntd��|��}tj�
|
|
||d||||�	}|dur�tj�|dd	|�d
��}|j|j|
|tjjdd�}|�|d�|dur�|j|||	d
�||fS)aMake an AXFR or IXFR query.

    *txn_manager* is a ``dns.transaction.TransactionManager``, typically a
    ``dns.zone.Zone``.

    *serial* is an ``int`` or ``None``.  If 0, then IXFR will be
    attempted using the most recent serial number from the
    *txn_manager*; it is the caller's responsibility to ensure there
    are no write transactions active that could invalidate the
    retrieved serial.  If a serial cannot be determined, AXFR will be
    forced.  Other integer values are the starting serial to use.
    ``None`` forces an AXFR.

    Please see the documentation for :py:func:`dns.message.make_query` and
    :py:func:`dns.message.Message.use_tsig` for details on the other parameters
    to this function.

    Returns a `(query, serial)` tuple.
    Nzno zone originzserial is not an integerrr8lzserial out-of-rangeFz. . z 0 0 0 0T)�create)�	algorithm)r&r%rr#r/�
isinstancerM�reader�getr r$�	get_classr�
make_query�rdata�	from_text�
find_rrset�	authorityr8r?�use_tsig)rr rPrQrRrSrTrUrVrW�zone_originr,r'rr"rC�rdclass�qr_rBrrrr^�sT




���
��r^�querycCslt|tjj�std��|jd}|jtjjkrdS|jtjj	kr$td��|�
|j|j|j
tjj�}|djS)a7Extract the SOA serial number from query if it is an IXFR and return
    it, otherwise return None.

    *query* is a dns.message.QueryMessage that is an IXFR or AXFR request.

    Raises if the query is not an IXFR or AXFR, or if an IXFR doesn't have
    an appropriate SOA RRset in the authority section.
    zquery not a QueryMessagerNzquery is not an AXFR or IXFR)rZrr�QueryMessager%r3rr#r/r$rarbr4rer8r )rgr3�soarrr�extract_serial_from_queryDs	
�
rj)(�typingrrrrr�
dns.exceptionr�dns.message�dns.name�	dns.rcode�dns.rdataset�
dns.rdatatype�
dns.serial�dns.transaction�dns.tsig�dns.zoner5�DNSExceptionrr6rrr�tsig�default_algorithmrJrKrMrN�edns�Optionr4�Name�strrrhr^rOrjrrrr�<module>sb	L���������
	�
�
�J