o
    2cp.                  	   @   s   d dl Zd dlZd dlZd dlZd dlZd dlZd dlZG dd dejj	Z
G dd dejjZG dd dejj	ZG dd	 d	Zd dddddddejjf	d
dZdS )    Nc                       s    e Zd ZdZ fddZ  ZS )TransferErrorz.A zone transfer response got a non-zero rcode.c                    s&   dt j| }t | || _d S )NzZone transfer error: %s)dnsrcodeto_textsuper__init__)selfr   message	__class__ =/var/www/html/gps/gps/lib/python3.10/site-packages/dns/xfr.pyr      s   
zTransferError.__init__)__name__
__module____qualname____doc__r   __classcell__r   r   r
   r   r      s    r   c                   @      e Zd ZdZdS )SerialWentBackwardsz:The current serial number is less than the serial we know.Nr   r   r   r   r   r   r   r   r   $       r   c                   @   r   )UseTCPz'This IXFR cannot be completed with UDP.Nr   r   r   r   r   r   (   r   r   c                   @   s<   e Zd ZdZejjddfddZdd Zdd	 Z	d
d Z
dS )Inboundz+
    State machine for zone transfers.
    NFc                 C   st   || _ d| _|| _|tjjkr|du rtdn|rtd|| _|| _|	 \}}| _
d| _d| _d| _d| _dS )aq  Initialize 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 IXFRszis_udp specified for AXFRF)txn_managertxnrdtyper   	rdatatypeIXFR
ValueErrorserialis_udporigin_informationoriginsoa_rdatasetdoneexpecting_SOAdelete_mode)r   r   r   r   r    _r   r   r   r   1   s    
zInbound.__init__c                 C   sh  | j du r| jtjjk}| j|| _ | }|tjjkr!t	|t
|jdkrF|jd j| jkr7tjd|jd j| jkrFtjdd}| jdu r|jrY|jd j| jkr_tjd|jd }|j}|}|jtjjkrvtjdd}| | _| jtjjkr| jd j| jkrd| _n0tj| jd j| jk rttj| jd j| j t| jrt
|j|d dkrtd| _|j|d D ]}|j}|}| jrtjd	|jtjjkrt|| jkrt| jtjjkr| j | _|| jkr@| jtjjks| jtjjkr@| jr@| jrtjd
| jtjjkr-| j|d jkr-tjd| j || | j   d| _ d| _n3d| _| jtjjkrm| jr_|d j| jkr^tjdn|d j| _| j || ntjdq| jrtjj| _d| _d| _| j    | jd| _ | jr| j !|| q| j "|| q| jr| jstjd| jS )aZ  Process 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.
        Nr   zwrong question namezwrong question rdatatypez&No answer or RRset not for zone originzfirst RRset is not an SOA   Tzanswers after final SOAzempty IXFR sequencezunexpected end of IXFR sequenceFzIXFR base serial mismatchzunexpected origin SOA in AXFRzunexpected end of UDP IXFR)#r   r   r   r   AXFRr   writerr   NOERRORr   lenquestionnamer"   	exception	FormErrorr#   answerSOAcopyr   r   r$   Serialprintr   r    r   r%   r&   replacecommitrollbackdelete_exactadd)r   r	   replacementr   answer_indexrrsetr.   rdatasetr   r   r   process_messageO   s   
	






zInbound.process_messagec                 C   s   | S )Nr   )r   r   r   r   	__enter__   s   zInbound.__enter__c                 C   s   | j r| j   dS )NF)r   r8   )r   exc_typeexc_valexc_tbr   r   r   __exit__   s   
zInbound.__exit__)r   r   r   r   r   r   r)   r   r?   r@   rD   r   r   r   r   r   ,   s    
 r   c
                 C   s&  |   \}
}}|du rtjj}nKt|tstd|dkrJ|   }||d}|r4|d j	}tjj
}nd}tjj}W d   n1 sDw   Y  n|dkrW|dk rWtjj
}ntdtj|
||  |d||||	}|durtj|
dddd	| d
}|j| |dur|j|||	d ||fS )a  Make 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.
    Nzserial is not an integerr   r2   l        zserial out-of-rangeFINz. . z 0 0 0 0)	algorithm)r!   r   r   r)   
isinstanceintr   readergetr   r   r	   
make_query	get_classr=   	from_text	authorityappenduse_tsig)r   r   use_edns	ednsflagspayloadrequest_payloadoptionskeyringkeynamekeyalgorithmzone_originr'   r"   r   r   r>   qr=   r   r   r   rK      s>   






rK   )dns.exceptionr   dns.messagedns.name	dns.rcode
dns.serialdns.rdatatypedns.zoner/   DNSExceptionr   r0   r   r   r   tsigdefault_algorithmrK   r   r   r   r   <module>   s$   	 I