
    h/                     P   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ej                   j"                        Z G d dej&                  j(                        ZeZej.                  Zej0                  Zej2                  Zej4                  Zy)zDNS Dynamic Update Support    )AnyListNc                   0    e Zd ZdZdZdZdZdZed        Z	y)UpdateSectionzUpdate sectionsr            c                      y)Nr	    )clss    H/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/dns/update.py_maximumzUpdateSection._maximum+   s        N)
__name__
__module____qualname____doc__ZONEPREREQUPDATE
ADDITIONALclassmethodr   r   r   r   r   r   #   s+    DFFJ r   r   c                   2    e Zd ZeZdej                  j                  ddej                  j                  dfdej                  j                  ez  dz  dej                  j                  dedz  dej                  j                  dz  dej                  j                  ez  dedz  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j                  j                  ez  ded	dfdZdej                  j                  ez  ded	dfdZdej                  j                  ez  ded	dfdZdej                  j                  ez  ded	dfdZ	 ddej                  j                  ez  dej>                  j@                  ez  dz  d	dfdZ!d Z"d Z# xZ$S )UpdateMessageNzonerdclasskeyringkeynamekeyalgorithmidc                 R   t         |   |       | xj                  t        j                  j                  t        j                  j                        z  c_        t        |t              rt        j                  j                  |      }|| _        t        j                  j                  j                  |      }|| _        | j                  rC| j!                  | j"                  | j                  |t        j$                  j&                  dd       || j)                  |||       yy)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__4   s    0 	B

cjj))#***;*;<<
dC 88%%d+D..++009#;;OO		!!!   MM'7lMC r   returnc                      | j                   d   S )zThe zone section.r   sectionsr8   s    r   r   zUpdateMessage.zone_        }}Qr   c                 "    || j                   d<   y )Nr   r<   r8   vs     r   r   zUpdateMessage.zoned       ar   c                      | j                   d   S )zThe prerequisite section.r   r<   r>   s    r   prerequisitezUpdateMessage.prerequisiteh   r?   r   c                 "    || j                   d<   y )Nr   r<   rA   s     r   rE   zUpdateMessage.prerequisitem   rC   r   c                      | j                   d   S )zThe update section.r   r<   r>   s    r   updatezUpdateMessage.updateq   r?   r   c                 "    || j                   d<   y )Nr   r<   rA   s     r   rH   zUpdateMessage.updatev   rC   r   c           
          || j                   }|j                         }| j                  ||| j                  |j                  ||dd      }|j                  ||       y)z&Add a single RR to the update section.NT)rH   coversr4   r3   rdtypeadd)r8   r-   ttlrddeletingsectionrK   rrsets           r   _add_rrzUpdateMessage._add_rrz   sW     ?kkGT4,,bii4QU
 			"cr   c                    t        |t              r t        j                  j	                  |d      }t        |d   t        j
                  j                        rL|D ]F  }|r| j                  ||j                         |D ]!  }| j                  ||j                  ||       # H yt        |      }t        |j                  d            }t        |d   t        j                  j                        r>|r| j                  ||d   j                         |D ]  }| j                  ||||        yt        j                   j"                  j%                  |j                  d            }|r| j                  ||       |D ]M  }	t        j                  j	                  | j&                  ||	| j(                        }| j                  ||||       O y)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   )rQ   )r+   r,   r(   r-   r.   rdatasetRdatasetdeleterL   rS   rN   listintpoprdataRdatar5   	RdataTyper2   r3   r/   )
r8   replacerQ   r-   argsrdsrO   rN   rL   ss
             r   _addzUpdateMessage._add   sz     dC 88%%dD1Dd1gs||445 EKKcjj1 EBLLswwGLDEE :Ddhhqk"C$q'399??3KKd1gnn5 ABLLsBL@A 0055dhhqkBKKf- AA,,T->->4;;WBLLsBL@Ar   r-   r_   c                 B     | j                   d| j                  |g|  y)zAdd records.

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

                - rdataset...

                - ttl, rdata...

                - ttl, rdtype, string...
        FNrb   rH   r8   r-   r_   s      r   rM   zUpdateMessage.add   s     			%d2T2r   c           
      .   t        |t              r t        j                  j	                  |d      }t        |      dk(  r| j                  | j                  |t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  dd       yt        |d   t        j                  j                        r;|D ]5  }|D ].  }| j                  |d|t        j                  j                         0 7 yt        |      }t        |d   t        j                   j"                        r4|D ].  }| j                  |d|t        j                  j                         0 yt        j                  j$                  j'                  |j)                  d            }t        |      dk(  r]| j                  | j                  || j*                  |t        j                  j                  t        j                  j                  dd       y|D ]d  }t        j                   j	                  | j*                  ||| j,                        }| j                  |d|t        j                  j                         f y)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.   lenr4   rH   r0   ANYr5   NONErU   rV   rS   rX   r[   r\   r]   r2   rZ   r3   r/   )r8   r-   r_   r`   rO   largsrL   ra   s           r   rW   zUpdateMessage.delete   s    dC 88%%dD1Dt9>OO""!!""""	 Q!6!67 C CBLLq"cnn.A.ABCC JE%(CIIOO4 CBLLq"cnn.A.ABC 0055eiilCu:?OO))****	 # G YY00 --" KK	 T1b#..2E2EFGr   c                 B     | j                   d| j                  |g|  y)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.
        TNrd   re   s      r   r^   zUpdateMessage.replace   s      			$T1D1r   c           
         t        |t              r t        j                  j	                  |d      }t        |      dk(  rk| j                  | j                  |t        j                  j                  t        j                  j                  t        j                  j                  ddd       yt        |d   t        j                  j                        s5t        |d   t        j                  j                        st        |      dkD  rt        |d   t        j                  j                        s=t!        |      }|j#                  dd        | j$                  d| j                  |g|  y | j$                  d| j                  |g|  yt        j                  j&                  j)                  |d         }| j                  | j                  |t        j                  j                  |t        j                  j                  ddd       y)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.   rg   r4   rE   r0   rh   r5   ri   rU   rV   r[   r\   rX   insertrb   r]   r2   )r8   r-   r_   rj   rL   s        r   presentzUpdateMessage.present
  sw    dC 88%%dD1Dt9>OO!!""!!""	 tAw 5 56$q'399??34y1}d1gs||'<'<=T
Q"		%!2!2DA5A		%!2!2D@4@]],,11$q':FOO!!""""	r   rL   c           
      4   t        |t              r t        j                  j	                  |d      }|k| j                  | j                  |t        j                  j                  t        j                  j                  t        j                  j                  ddd       yt        j                  j                  j                  |      }| j                  | j                  |t        j                  j                  |t        j                  j                  ddd       y)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.   r4   rE   r0   ri   r5   rh   r]   r2   )r8   r-   rL   s      r   absentzUpdateMessage.absent?  s     dC 88%%dD1D>OO!!##!!""	 ]],,11&9FOO!!##""	r   c                      y)NTr   )r8   values     r   _get_one_rr_per_rrsetz#UpdateMessage._get_one_rr_per_rrseta  s    r   c                 R   d }d}|t         j                  k(  rbt        j                  j	                  |      s)|t        j
                  j                  k7  s| j                  rt        j                  j                  | j                  st        j                  j                  |t        j                  j                  t        j                  j                  fv rM|}| j                  d   j                  }|t        j                  j                  k(  xs |t         j                  k(  }||||fS )NFr   )r   r   r(   r0   is_metaclassr5   r6   r   	exception	FormErrorrh   ri   r   r   )r8   rQ   r-   r   rL   rP   emptys          r   _parse_rr_headerzUpdateMessage._parse_rr_headere  s    m(((++G4S]]...99mm---99mm---3>>--s~~/B/BCC"))A,.. 2 22UgAUAU6U  511r   )NN)N)%r   r   r   r   _section_enumr(   r0   INtsigdefault_algorithmr-   Namer,   r1   r   rY   r&   propertyr   rR   RRsetr   setterrE   rH   rS   rb   rM   rW   r^   rn   r5   r]   rp   rs   ry   __classcell__)r9   s   @r   r   r   0   sw   !M ,0-0^^->->"(,,/HH,F,F)Dhhmmc!D()D **)D t	)D
 %)D hhmmc))D $J)DV  d399??+     
[[   d399??3        SYY__-     ]] 	&AP3+ 3C 3D 3:G388==3. :Gs :Gt :Gx2CHHMMC/ 2 2 2$3CHHMMC/ 3 3 3p 8< hhmmc!  ''#-4  
	 D2r   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   <module>r      s   $ !            
CHH$$ 
H2CKK'' H2X
 
 						%%
r   