U
    Â@ÛfÓ/  ã                   @   s¤   d Z ddlmZmZmZm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ddlZddlZG dd„ dejjƒZG dd„ dejjƒZeZejZejZejZejZdS )zDNS Dynamic Update Supporté    )ÚAnyÚListÚOptionalÚUnionNc                   @   s,   e Zd ZdZdZdZdZdZedd„ ƒZ	dS )	ÚUpdateSectionzUpdate sectionsr   é   é   é   c                 C   s   dS )Nr	   © )Úclsr
   r
   úD/var/www/html/chatgpt/venv/lib/python3.8/site-packages/dns/update.pyÚ_maximum(   s    zUpdateSection._maximumN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚZONEÚPREREQÚUPDATEÚ
ADDITIONALÚclassmethodr   r
   r
   r
   r   r       s   r   c                       s¸  e Zd ZeZdejjddejj	dfe
eejjef  ejje
e e
ejj eejjef e
e dœ‡ fdd„Zeeejj dœdd„ƒZejdd„ ƒZeeejj dœd	d
„ƒZejdd
„ ƒZeeejj dœdd„ƒZejdd„ ƒZd#dd„Zdd„ Zeejjef eddœdd„Zeejjef eddœdd„Zeejjef eddœdd„Zeejjef eddœdd„Z d$eejjef e
eej!j"ef  ddœdd„Z#dd „ Z$d!d"„ Z%‡  Z&S )%ÚUpdateMessageN)ÚzoneÚrdclassÚkeyringÚkeynameÚkeyalgorithmÚidc                    s˜   t ƒ j|d� |  jtj tjj¡O  _t|tƒr>tj	 
|¡}|| _tjj |¡}|| _| jr|| j| j| j|tjjddd� |dk	r”| j|||d� dS )ax  Initialize a new DNS Update object.

        See the documentation of the Message class for a complete
        description of the keyring dictionary.

        *zone*, a ``dns.name.Name``, ``str``, or ``None``, the zone
        which is being updated.  ``None`` should only be used by dnspython's
        message constructors, as a zone is required for the convenience
        methods like ``add()``, ``replace()``, etc.

        *rdclass*, an ``int`` or ``str``, the class of the zone.

        The *keyring*, *keyname*, and *keyalgorithm* parameters are passed to
        ``use_tsig()``; see its documentation for details.
        )r   T)ÚcreateZforce_uniqueN)Ú	algorithm)ÚsuperÚ__init__ÚflagsÚdnsÚopcodeZto_flagsr   Ú
isinstanceÚstrÚnameÚ	from_textÚoriginÚ
rdataclassÚ
RdataClassÚmakeÚzone_rdclassÚ
find_rrsetr   Ú	rdatatypeÚSOAZuse_tsig)Úselfr   r   r   r   r   r   ©Ú	__class__r
   r   r!   1   s$    
úzUpdateMessage.__init__)Úreturnc                 C   s
   | j d S )zThe zone section.r   ©Úsections©r1   r
   r
   r   r   \   s    zUpdateMessage.zonec                 C   s   || j d< d S )Nr   r5   ©r1   Úvr
   r
   r   r   a   s    c                 C   s
   | j d S )zThe prerequisite section.r   r5   r7   r
   r
   r   Úprerequisitee   s    zUpdateMessage.prerequisitec                 C   s   || j d< d S )Nr   r5   r8   r
   r
   r   r:   j   s    c                 C   s
   | j d S )zThe update section.r   r5   r7   r
   r
   r   Úupdaten   s    zUpdateMessage.updatec                 C   s   || j d< d S )Nr   r5   r8   r
   r
   r   r;   s   s    c              
   C   sB   |dkr| j }| ¡ }|  ||| j|j||dd¡}| ||¡ dS )z&Add a single RR to the update section.NT)r;   Úcoversr.   r-   ÚrdtypeÚadd)r1   r'   ÚttlÚrdÚdeletingÚsectionr<   Úrrsetr
   r
   r   Ú_add_rrw   s           ÿzUpdateMessage._add_rrc           
      G   s  t |tƒrtj |d¡}t |d tjjƒrf|D ]4}|rD|  ||j¡ |D ]}| j	||j
||d� qHq.n²t|ƒ}t| d¡ƒ}t |d tjjƒrÂ|r¤|  ||d j¡ |D ]}| j	||||d� q¨nVtjj | d¡¡}|ræ|  ||¡ |D ],}	tj | j||	| j¡}| j	||||d� qêdS )a°  Add records.

        *replace* is the replacement mode.  If ``False``,
        RRs are added to an existing RRset; if ``True``, the RRset
        is replaced with the specified contents.  The second
        argument is the section to add to.  The third argument
        is always a name.  The other arguments can be:

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...
        Nr   )rB   )r%   r&   r#   r'   r(   ÚrdatasetÚRdatasetÚdeleter=   rD   r?   ÚlistÚintÚpopÚrdataÚRdatar/   Ú	RdataTyper,   r-   r)   )
r1   ÚreplacerB   r'   ÚargsÚrdsr@   r?   r=   Úsr
   r
   r   Ú_add‚   s*    
zUpdateMessage._add)r'   rO   r4   c                 G   s   | j d| j|f|žŽ  dS )zÒAdd records.

        The first argument is always a name.  The other
        arguments can be:

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...
        FN©rR   r;   ©r1   r'   rO   r
   r
   r   r>   ª   s    zUpdateMessage.addc              
   G   sH  t |tƒrtj |d¡}t|ƒdkrP|  | j|tjj	tj
j	tj
jtjj	dd¡ nôt |d tjjƒrŒ|D ]"}|D ]}|  |d|tjj¡ qnqfn¸t|ƒ}t |d tjjƒrÆ|D ]}|  |d|tjj¡ qªn~tj
j | d¡¡}t|ƒdk�r|  | j|| j|tj
jtjj	dd¡ n6|D ]0}tj | j||| j¡}|  |d|tjj¡ �qdS )zèDelete records.

        The first argument is always a name.  The other
        arguments can be:

                - *empty*

                - rdataset...

                - rdata...

                - rdtype, [string...]
        Nr   T)r%   r&   r#   r'   r(   Úlenr.   r;   r*   ÚANYr/   ÚNONErE   rF   rD   rH   rK   rL   rM   r,   rJ   r-   r)   )r1   r'   rO   rP   r@   Úlargsr=   rQ   r
   r
   r   rG   ¹   sR    
ø
øüzUpdateMessage.deletec                 G   s   | j d| j|f|žŽ  dS )ab  Replace records.

        The first argument is always a name.  The other
        arguments can be:

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...

        Note that if you want to replace the entire node, you should do
        a delete of the name followed by one or more calls to add.
        TNrS   rT   r
   r
   r   rN   õ   s    zUpdateMessage.replacec              
   G   s
  t |tƒrtj |d¡}t|ƒdkrL|  | j|tjj	tj
j	tj
jddd¡ nºt |d tjjƒs|t |d tjjƒs|t|ƒdkrÒt |d tjjƒsºt|ƒ}| dd¡ | jd| j|f|žŽ  n| jd| j|f|žŽ  n4tj
j |d ¡}|  | j|tjj	|tj
jddd¡ dS )aS  Require that an owner name (and optionally an rdata type,
        or specific rdataset) exists as a prerequisite to the
        execution of the update.

        The first argument is always a name.
        The other arguments can be:

                - rdataset...

                - rdata...

                - rdtype, string...
        Nr   Tr   F)r%   r&   r#   r'   r(   rU   r.   r:   r*   rV   r/   rW   rE   rF   rK   rL   rH   ÚinsertrR   rM   r,   )r1   r'   rO   rX   r=   r
   r
   r   Úpresent  sF    
øÿþ
ýøzUpdateMessage.present)r'   r=   r4   c              
   C   s|   t |tƒrtj |d¡}|dkrH|  | j|tjjtj	j
tj	jddd¡ n0tj	j |¡}|  | j|tjj|tj	jddd¡ dS )z‚Require that an owner name (and optionally an rdata type) does
        not exist as a prerequisite to the execution of the update.NT)r%   r&   r#   r'   r(   r.   r:   r*   rW   r/   rV   rM   r,   )r1   r'   r=   r
   r
   r   Úabsent<  s0    
øøzUpdateMessage.absentc                 C   s   dS )NTr
   )r1   Úvaluer
   r
   r   Ú_get_one_rr_per_rrset^  s    z#UpdateMessage._get_one_rr_per_rrsetc                 C   sŽ   d }d}|t jkr:tj |¡s0|tjjks0| jr‚tjj	‚nH| jsHtjj	‚|tjj
tjjfkr‚|}| jd j}|tjj
kp€|t jk}||||fS )NFr   )r   r   r#   r*   Zis_metaclassr/   r0   r   Ú	exceptionZ	FormErrorrV   rW   r   r   )r1   rB   r'   r   r=   rA   Úemptyr
   r
   r   Ú_parse_rr_headerb  s$    

ÿ
þý
ÿzUpdateMessage._parse_rr_header)NN)N)'r   r   r   r   Z_section_enumr#   r*   ÚINZtsigZdefault_algorithmr   r   r'   ÚNamer&   r+   r   rI   r!   Úpropertyr   rC   ZRRsetr   Úsetterr:   r;   rD   rR   r>   rG   rN   rZ   r/   rM   r[   r]   r`   Ú__classcell__r
   r
   r2   r   r   -   sR   ù
ù+



(<8 ýü"r   )r   Útypingr   r   r   r   Zdns.messager#   Zdns.nameZ
dns.opcodeZ	dns.rdataZdns.rdataclassZdns.rdatasetZdns.rdatatypeZdns.tsigÚenumÚIntEnumr   ÚmessageÚMessager   ZUpdater   r   r   r   r
   r
   r
   r   Ú<module>   s$     N