
    Eqg/                         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ej        j                  Z G 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                   8    e Zd ZdZdZdZdZdZed             Z	dS )UpdateSectionzUpdate sectionsr            c                     dS )Nr    )clss    </var/www/html/env/lib/python3.11/site-packages/dns/update.py_maximumzUpdateSection._maximum(   s    q    N)
__name__
__module____qualname____doc__ZONEPREREQUPDATE
ADDITIONALclassmethodr   r   r   r   r   r       sG        DFFJ  [  r   r   c                       e Zd ZeZdej        j        ddej        j	        dfde
eej        j        ef                  dej        j        de
e         de
ej        j                 deej        j        ef         de
e         f fdZed	eej        j                 fd
            Zej        d             Zed	eej        j                 fd            Zej        d             Zed	eej        j                 fd            Zej        d             ZddZd Zdeej        j        ef         ded	dfdZdeej        j        ef         ded	dfdZdeej        j        ef         ded	dfdZdeej        j        ef         ded	dfdZ 	 ddeej        j        ef         de
eej!        j"        ef                  d	dfdZ#d Z$d Z% xZ&S )UpdateMessageNzonerdclasskeyringkeynamekeyalgorithmidc                 >   t                                          |           | xj        t          j                            t          j        j                  z  c_        t          |t                    rt          j	        
                    |          }|| _        t          j        j                            |          }|| _        | j        r4|                     | j        | j        |t          j        j        d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__s          r   r(   zUpdateMessage.__init__1   s   0 	B

cj))#**;<<<

dC   	,8%%d++D.+0099#; 	OO	!!     MM'7lMCCCCC r   returnc                     | j         d         S )zThe zone section.r   sectionsr:   s    r   r   zUpdateMessage.zone\        }Qr   c                     || j         d<   d S )Nr   r>   r:   vs     r   r   zUpdateMessage.zonea       ar   c                     | j         d         S )zThe prerequisite section.r	   r>   r@   s    r   prerequisitezUpdateMessage.prerequisitee   rA   r   c                     || j         d<   d S )Nr	   r>   rC   s     r   rG   zUpdateMessage.prerequisitej   rE   r   c                     | j         d         S )zThe update section.r
   r>   r@   s    r   updatezUpdateMessage.updaten   rA   r   c                     || j         d<   d S )Nr
   r>   rC   s     r   rJ   zUpdateMessage.updates   rE   r   c           
          || j         }|                                }|                     ||| j        |j        ||dd          }|                    ||           dS )z&Add a single RR to the update section.NT)rJ   coversr6   r5   rdtypeadd)r:   r/   ttlrddeletingsectionrM   rrsets           r   _add_rrzUpdateMessage._add_rrw   sc     ?kGT4,bi4QU
 
 			"cr   c                    t          |t                    r t          j                            |d          }t          |d         t          j        j                  rG|D ]B}|r|                     ||j                   |D ] }| 	                    ||j
        ||           !CdS t          |          }t          |                    d                    }t          |d         t          j        j                  rC|r!|                     ||d         j                   |D ]}| 	                    ||||           dS t          j        j                            |                    d                    }|r|                     ||           |D ]G}	t          j                            | j        ||	| j                  }| 	                    ||||           Hd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   )rS   )r-   r.   r*   r/   r0   rdatasetRdatasetdeleterN   rU   rP   listintpoprdataRdatar7   	RdataTyper4   r5   r1   )
r:   replacerS   r/   argsrdsrQ   rP   rN   ss
             r   _addzUpdateMessage._add   s     dC   	28%%dD11Dd1gs|455 	A E E 2KKcj111 E EBLLswGLDDDDEE E ::Ddhhqkk""C$q'39?33 A 6KKd1gn555 A ABLLsBL@@@@A A 055dhhqkkBB .KKf--- A AA,,T->4;WWBLLsBL@@@@A Ar   r/   ra   c                 0     | 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rd   rJ   r:   r/   ra   s      r   rO   zUpdateMessage.add   s*     		%d2T222222r   c           
         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                  r3|D ].}|D ])}|                     |d|t          j        j                   */dS t          |          }t          |d         t          j        j                  r.|D ])}|                     |d|t          j        j                   *dS t          j
        j                            |                    d                    }t          |          dk    rF|                     | j        || j        |t          j
        j        t          j        j	        dd           dS |D ]U}t          j                            | j        ||| j                  }|                     |d|t          j        j                   Vd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/   r0   lenr6   rJ   r2   ANYr7   NONErW   rX   rU   rZ   r]   r^   r_   r4   r\   r5   r1   )r:   r/   ra   rb   rQ   largsrN   rc   s           r   rY   zUpdateMessage.delete   sD    dC   	28%%dD11Dt99>>OO"!""	 	 	 	 	 Q!677 	G C C C CBLLq"cn.ABBBBCC C JJE%(CIO44 G C CBLLq"cn.ABBBBC C 055eiillCCu::??OO)**	 	 	 	 	 # G G Y00 -" K	  T1b#.2EFFFFG Gr   c                 0     | j         d| j        |g|R   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.
        TNrf   rg   s      r   r`   zUpdateMessage.replace   s*      		$T1D111111r   c           
         t          |t                    r t          j                            |d          }t          |          dk    rP|                     | j        |t          j        j	        t          j
        j	        t          j
        j        ddd           dS t          |d         t          j        j                  s8t          |d         t          j        j                  st          |          dk    rxt          |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/   r0   ri   r6   rG   r2   rj   r7   rk   rW   rX   r]   r^   rZ   insertrd   r_   r4   )r:   r/   ra   rl   rN   s        r   presentzUpdateMessage.present  s    dC   	28%%dD11Dt99>>OO!"!"	 	 	 	 	 tAw 566	$q'39?33	 4yy1}}d1gs|'<== AT

Q"""	%!2DA5AAAAAA	%!2D@4@@@@@@],11$q'::FOO!""	 	 	 	 	r   rN   c           
         t          |t                    r t          j                            |d          }|P|                     | 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/   r0   r6   rG   r2   rk   r7   rj   r_   r4   )r:   r/   rN   s      r   absentzUpdateMessage.absent<  s     dC   	28%%dD11D>OO!#!"	 	 	 	 	 ],11&99FOO!#"	 	 	 	 	r   c                     dS )NTr   )r:   values     r   _get_one_rr_per_rrsetz#UpdateMessage._get_one_rr_per_rrset^  s    tr   c                    d }d}|t           j        k    rMt          j                            |          s|t          j        j        k    s| j        rt          j        j	        nu| j        st          j        j	        |t          j        j
        t          j        j        fv r9|}| j        d         j        }|t          j        j
        k    p|t           j        k    }||||fS )NFr   )r   r   r*   r2   is_metaclassr7   r8   r   	exception	FormErrorrj   rk   r   r   )r:   rS   r/   r   rN   rR   emptys          r   _parse_rr_headerzUpdateMessage._parse_rr_headerb  s    m(((++G44.S]...9 / m-- /
 9 .m--3>-s~/BCCC")A,. 22UgAU6U  511r   )NN)N)'r   r   r   r   _section_enumr*   r2   INtsigdefault_algorithmr   r   r/   Namer.   r3   r   r[   r(   propertyr   rT   RRsetr   setterrG   rJ   rU   rd   rO   rY   r`   rp   r7   r_   rr   ru   r{   __classcell__)r;   s   @r   r   r   -   sV       !M 59-0^->!%+/25(2L )D )DuSX]C/01)D *)D #	)D
 #(-()D CHM3./)D SM)D )D )D )D )D )DV  d39?+       X  
[  [  d39?3       X      SY_-       X  ]  ]	 	 	 	&A &A &AP3chmS01 3# 3$ 3 3 3 3:G5!34 :GS :GT :G :G :G :Gx2E#(-"45 2c 2d 2 2 2 2$3E#(-"45 3c 3d 3 3 3 3p AE   CHM3&'  s}6;<=  
	       D  2 2 2 2 2 2 2r   r   )r   typingr   r   r   r   dns.messager*   dns.name
dns.opcode	dns.rdatadns.rdataclassdns.rdatasetdns.rdatatypedns.tsigenumIntEnumr   messageMessager   Updater   r   r   r   r   r   r   <module>r      s  $ !   - - - - - - - - - - - -                          
 
 
 
 
CH$ 
 
 
H2 H2 H2 H2 H2CK' H2 H2 H2X
 
 				%


r   