
    g(                         S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
   " S S\R                  R                  5      rg)zDNS Dynamic Update Support    N   )string_typesc                      ^  \ rS rSr\R
                  R                  SS\R                  R                  4U 4S jjr	SS jr
S rS rS rS rS	 rSS
 jrSU 4S jjrSrU =r$ )Update   Nc           	      N  > [         [        U ]  5         U =R                  [        R
                  R                  [        R
                  R                  5      -  sl        [        U[        5      (       a  [        R                  R                  U5      nXl        [        U[        5      (       a  [        R                  R                  U5      nX l        U R                  U R                   U R                  U[        R"                  R$                  SSS9  Ub  U R'                  X4US9  gg)a*  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`` or ``text``, the zone which is being
updated.

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

*keyring*, a ``dict``, the TSIG keyring to use.  If a
*keyring* is specified but a *keyname* is not, then the key
used will be the first key in the *keyring*.  Note that the
order of keys in a dictionary is not defined, so applications
should supply a keyname when a keyring is used, unless they
know the keyring contains only one key.

*keyname*, a ``dns.name.Name`` or ``None``, the name of the TSIG key
to use; defaults to ``None``. The key must be defined in the keyring.

*keyalgorithm*, a ``dns.name.Name``, the TSIG algorithm to use.
T)createforce_uniqueN)	algorithm)superr   __init__flagsdnsopcodeto_flagsUPDATE
isinstancer   name	from_textorigin
rdataclasszone_rdclass
find_rrsetquestion	rdatatypeSOAuse_tsig)selfzonerdclasskeyringkeynamekeyalgorithm	__class__s         lib/third_party/dns/update.pyr   Update.__init__!   s    0 	fd$&

cjj))#***;*;<<
dL))88%%d+Dg|,,nn..w7G#t{{GS]]=N=N#$ 	 	8MM'lMC     c           
          Uc  U R                   nUR                  5       nU R                  XQU R                  UR                  XdSS5      nUR                  X25        g)z&Add a single RR to the update section.NT)	authoritycoversr   r   rdtypeadd)r   r   ttlrddeletingsectionr*   rrsets           r%   _add_rrUpdate._add_rrF   sN     ?nnGt/@/@")) &$>		"r'   c           	         [        U[        5      (       a   [        R                  R	                  US5      n[        US   [        R
                  R                  5      (       aO  U HH  nU(       a  U R                  X5R                  5        U H  nU R                  X5R                  XbS9  M     MJ     g[        U5      n[        UR                  S5      5      n[        US   [        R                  R                  5      (       a?  U(       a  U R                  X4S   R                  5        U H  nU R                  X7XbS9  M     gUR                  S5      n[        U[        5      (       a  [        R                   R	                  U5      nU(       a  U R                  X85        U HH  n	[        R                  R	                  U R"                  XU R$                  5      nU R                  X7XbS9  MJ     g)ah  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   )r0   )r   r   r   r   r   rdatasetRdatasetdeleter+   r2   r-   listintpoprdataRdatar   r   r   )
r   replacer0   r   argsrdsr.   r-   r+   ss
             r%   _addUpdate._addP   sb     dL))88%%dD1Dd1gs||4455KKjj1BLLwwLD   :Ddhhqk"C$q'399??33KK1gnn5BLLBL@  !fl33 ]]44V<FKK-A,,T->->-1[[:BLLBL@ r'   c                 B    U R                   " SU R                  U/UQ76   g)zAdd records.

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

        - rdataset...

        - ttl, rdata...

        - ttl, rdtype, string...
FNrA   r)   r   r   r>   s      r%   r,   
Update.add{   s     			%55r'   c           
      x   [        U[        5      (       a   [        R                  R	                  US5      n[        U5      S:X  a  U R                  U R                  U[        R                  R                  [        R                  R                  [        R                  R                  [        R                  R                  SS5        g[        US   [        R                  R                  5      (       a?  U H8  nU H/  nU R                  USU[        R                  R                  5        M1     M:     g[        U5      n[        US   [        R                   R"                  5      (       a6  U H/  nU R                  USU[        R                  R                  5        M1     gUR%                  S5      n[        U[        5      (       a  [        R                  R	                  U5      n[        U5      S:X  a]  U R                  U R                  UU R&                  U[        R                  R                  [        R                  R                  SS5        gU Hd  n[        R                   R	                  U R&                  XVU R(                  5      nU R                  USU[        R                  R                  5        Mf     g)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   lenr   r)   r   ANYr   NONEr5   r6   r2   r8   r;   r<   r:   r   r   )r   r   r>   r?   r.   r+   r@   s          r%   r7   Update.delete   s    dL))88%%dD1Dt9>OODNND#..2D2DMM--s}}/A/AMM--tT; Q!6!677BLLq"cnn.A.AB   :D$q'399??33BLLq"cnn.A.AB  !fl33 ]]44V<Ft9>OODNND$($5$5v$'MM$6$6$'NN$6$6$($	0 " YY001B1BF15>T1b#..2E2EF "r'   c                 B    U R                   " SU R                  U/UQ76   g)a"  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=   Update.replace   s      			$4t4r'   c           
         [        U[        5      (       a   [        R                  R	                  US5      n[        U5      S:X  ak  U R                  U R                  U[        R                  R                  [        R                  R                  [        R                  R                  SSS5        g[        US   [        R                  R                  5      (       d;  [        US   [        R                  R                  5      (       d  [        U5      S:  ai  [        US   [        R                  R                  5      (       d  [!        U5      nUR#                  SS5        U R$                  " SU R                  U/UQ76   gUS   n[        U[        5      (       a  [        R                  R	                  U5      nU R                  U R                  U[        R                  R                  U[        R                  R                  SSS5        g)a  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   rH   r   answerr   rI   r   rJ   r5   r6   r;   r<   r8   insertrA   )r   r   r>   r+   s       r%   presentUpdate.present   s`    dL))88%%dD1Dt9>OODKKNN..0A0AMM.. $( Q!6!677tAw		00D	Ad1gs||'<'<==DzAq!IIeT[[$66!WF&,//008OODKKNN..MM.. $(r'   c           
      V   [        U[        5      (       a   [        R                  R	                  US5      nUck  U R                  U R                  U[        R                  R                  [        R                  R                  [        R                  R                  SSS5        g[        U[        5      (       a  [        R                  R	                  U5      nU R                  U R                  U[        R                  R                  U[        R                  R                  SSS5        g)zzRequire 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   rO   r   rJ   r   rI   )r   r   r+   s      r%   absentUpdate.absent   s     dL))88%%dD1D>OODKKNN//1B1BMM.. $(
 &,//008OODKKNN//MM.. $(r'   c                 H   > Uc  U R                   n[        [        U ]  X5      $ )a  Return a string containing the update in DNS compressed wire
format.

*origin*, a ``dns.name.Name`` or ``None``, the origin to be
appended to any relative names.  If *origin* is ``None``, then
the origin of the ``dns.update.Update`` message object is used
(i.e. the *zone* parameter passed when the Update object was
created).

*max_size*, an ``int``, the maximum size of the wire format
output; default is 0, which means "the message's request
payload, if nonzero, or 65535".

Returns a ``binary``.
)r   r   r   to_wire)r   r   max_sizer$   s      r%   rW   Update.to_wire  s%    " >[[FVT*6<<r'   )r   r   )NN)N)Ni  )__name__
__module____qualname____firstlineno__r   r   INtsigdefault_algorithmr   r2   rA   r,   r7   r=   rQ   rT   rW   __static_attributes____classcell__)r$   s   @r%   r   r      sZ    %(^^%6%6CHH,F,F#DJ)AV6,G\5$%(N(&= =r'   r   )__doc__dns.messager   dns.name
dns.opcode	dns.rdatadns.rdataclassdns.rdatasetdns.tsig_compatr   messageMessager    r'   r%   <module>ro      s<   $ !        !x=S[[   x=r'   