o
    Þý°jÌ/  ã                   @   s´   d Z ddl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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ÚListNc                   @   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   ó   dS )Nr   © )Úclsr	   r	   ú}/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/dns/update.pyÚ_maximum+   ó   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dej
jeB dB dejjdedB dej
jdB dej
jeB dedB f‡ fdd	„Zed
eejj fdd„ƒZejdd„ ƒZed
eejj fdd„ƒZejdd„ ƒZed
eejj fdd„ƒZejdd„ ƒZd)dd„Zdd„ Zdej
jeB ded
dfdd„Zdej
jeB ded
dfdd„Zdej
jeB ded
dfdd„Zdej
jeB ded
dfd d!„Z	d*dej
jeB d"ejj eB dB d
df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urL| j|||d� dS 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)ÚcreateÚforce_uniqueN)Ú	algorithm)ÚsuperÚ__init__ÚflagsÚdnsÚopcodeÚto_flagsr   Ú
isinstanceÚstrÚnameÚ	from_textÚoriginÚ
rdataclassÚ
RdataClassÚmakeÚzone_rdclassÚ
find_rrsetr   Ú	rdatatypeÚSOAÚuse_tsig)Úselfr   r   r   r   r   r   ©Ú	__class__r	   r   r"   4   s&   
úÿzUpdateMessage.__init__Úreturnc                 C   ó
   | j d S )zThe zone section.r   ©Úsections©r4   r	   r	   r   r   _   ó   
zUpdateMessage.zonec                 C   ó   || j d< d S )Nr   r9   ©r4   Úvr	   r	   r   r   d   ó   c                 C   r8   )zThe prerequisite section.r   r9   r;   r	   r	   r   Úprerequisiteh   r<   zUpdateMessage.prerequisitec                 C   r=   )Nr   r9   r>   r	   r	   r   rA   m   r@   c                 C   r8   )zThe update section.r   r9   r;   r	   r	   r   Úupdateq   r<   zUpdateMessage.updatec                 C   r=   )Nr   r9   r>   r	   r	   r   rB   v   r@   c              
   C   sB   |du r| j }| ¡ }|  ||| j|j||dd¡}| ||¡ dS )z&Add a single RR to the update section.NT)rB   Úcoversr0   r/   ÚrdtypeÚadd)r4   r)   ÚttlÚrdÚdeletingÚsectionrC   Úrrsetr	   r	   r   Ú_add_rrz   s   ÿzUpdateMessage._add_rrc           
      G   s   t |tƒrtj |d¡}t |d tjjƒr4|D ]}|r"|  ||j¡ |D ]}| j	||j
||d� q$qdS t|ƒ}t| d¡ƒ}t |d tjjƒrc|rS|  ||d j¡ |D ]}| j	||||d� qUdS tjj | d¡¡}|ru|  ||¡ |D ]}	tj | j||	| j¡}| j	||||d� qwd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   )rI   )r'   r(   r$   r)   r*   ÚrdatasetÚRdatasetÚdeleterD   rK   rF   ÚlistÚintÚpopÚrdataÚRdatar1   Ú	RdataTyper.   r/   r+   )
r4   ÚreplacerI   r)   ÚargsÚrdsrG   rF   rD   Úsr	   r	   r   Ú_add…   s2   
ÿýÿþzUpdateMessage._addr)   rV   c                 G   ó   | j d| j|g|¢R Ž  dS )zÒAdd records.

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

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...
        FN©rY   rB   ©r4   r)   rV   r	   r	   r   rE   ­   s   zUpdateMessage.addc              
   G   sL  t |tƒrtj |d¡}t|ƒdkr)|  | j|tjj	tj
j	tj
jtjj	dd¡ dS t |d tjjƒrH|D ]}|D ]}|  |d|tjj¡ q8q4dS t|ƒ}t |d tjjƒrf|D ]}|  |d|tjj¡ qWdS tj
j | d¡¡}t|ƒdkrŠ|  | j|| j|tj
jtjj	dd¡ dS |D ]}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*   Úlenr0   rB   r,   ÚANYr1   ÚNONErL   rM   rK   rO   rR   rS   rT   r.   rQ   r/   r+   )r4   r)   rV   rW   rG   ÚlargsrD   rX   r	   r	   r   rN   ¼   sZ   
ø
ÿÿÿøüùzUpdateMessage.deletec                 G   rZ   )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.
        TNr[   r\   r	   r	   r   rU   ø   s   zUpdateMessage.replacec              
   G   s  t |tƒrtj |d¡}t|ƒdkr'|  | j|tjj	tj
j	tj
jddd¡ dS t |d tjjƒs?t |d tjjƒs?t|ƒdkrnt |d tjjƒs`t|ƒ}| dd¡ | jd| j|g|¢R Ž  dS | jd| j|g|¢R Ž  dS t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*   r]   r0   rA   r,   r^   r1   r_   rL   rM   rR   rS   rO   ÚinsertrY   rT   r.   )r4   r)   rV   r`   rD   r	   r	   r   Úpresent
  sD   
øÿþøzUpdateMessage.presentrD   c              
   C   s~   t |tƒrtj |d¡}|du r%|  | j|tjjtj	j
tj	jddd¡ dS t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*   r0   rA   r,   r_   r1   r^   rT   r.   )r4   r)   rD   r	   r	   r   Úabsent?  s0   
øøzUpdateMessage.absentc                 C   r   )NTr	   )r4   Úvaluer	   r	   r   Ú_get_one_rr_per_rrseta  r   z#UpdateMessage._get_one_rr_per_rrsetc                 C   sŽ   d }d}|t jkrtj |¡s|tjjks| jrtjj	‚n$| js$tjj	‚|tjj
tjjfv rA|}| jd j}|tjj
kp@|t jk}||||fS )NFr   )r   r   r$   r,   Úis_metaclassr1   r2   r   Ú	exceptionÚ	FormErrorr^   r_   r   r   )r4   rI   r)   r   rD   rH   Úemptyr	   r	   r   Ú_parse_rr_headere  s$   

ÿÿýÿzUpdateMessage._parse_rr_header)NN)N)%r   r   r   r   Ú_section_enumr$   r,   ÚINÚtsigÚdefault_algorithmr)   ÚNamer(   r-   r   rP   r"   Úpropertyr   rJ   ÚRRsetr   ÚsetterrA   rB   rK   rY   rE   rN   rU   rb   r1   rT   rc   re   rj   Ú__classcell__r	   r	   r5   r   r   0   sb    ùþýü
û
úù+



(<8ý
þý
ü"r   )r   Útypingr   r   Údns.enumr$   Údns.exceptionÚdns.messageÚdns.nameÚ
dns.opcodeÚ	dns.rdataÚdns.rdataclassÚdns.rdatasetÚdns.rdatatypeÚ	dns.rrsetÚdns.tsigÚenumÚIntEnumr   ÚmessageÚMessager   ÚUpdater   r   r   r   r	   r	   r	   r   Ú<module>   s,     N
