o
    h/                     @   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	   L/var/www/html/pro-man-master/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 )zAdd 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 qdS )zDelete 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 )zRequire 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
