
    _?iS1                        S r SSKrSSKrSSKJrJ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\R                  R                  1r\R                  R                   \R                  R"                  \R                  R$                  1rS r\R*                   " S S\R,                  5      5       r " S S5      r\R2                  R2                   " S	 S
\5      5       rg)z)DNS nodes.  A node is a set of rdatasets.    N)AnyDictc                 h    X;   =(       d(    U[         R                  R                  :H  =(       a    X ;   $ N)dns	rdatatypeRRSIG)rdtypesrdtypecoverss      L/var/www/html/livechat/backend/venv/lib/python3.13/site-packages/dns/node.py_matches_type_or_its_signaturer   +   s'    U3==+>+>!>!T6CTU    c                       \ rS rSrSrSrSrSr\S\	R                  R                  S\	R                  R                  SS 4S	 j5       r\S
\	R                  R                  SS 4S j5       rSrg)NodeKind/   zRdatasets in nodesr         r   r   returnc                     [        [        X5      (       a  [        R                  $ [        [        X5      (       a  [        R
                  $ [        R                  $ r   )r   _cname_typesr   CNAME_neutral_typesNEUTRALREGULAR)clsr   r   s      r   classifyNodeKind.classify7   s@     *,GG>>!+NFKK######r   rdatasetc                 N    U R                  UR                  UR                  5      $ r   )r   r   r   )r   r   s     r   classify_rdatasetNodeKind.classify_rdatasetB   s    ||HOOX__==r    N)__name__
__module____qualname____firstlineno____doc__r   r   r   classmethodr   r   	RdataTyper   r   Rdatasetr!   __static_attributes__r#   r   r   r   r   /   s~    GGE$]],,$69mm6M6M$	$ $ >)>)> >: > >r   r   c                      \ rS rSrSrS/rS rS\R                  R                  S\
\\4   S\4S jrS	 rS
 rS rS rS rS r\R(                  R*                  S4S\R,                  R.                  S\R(                  R0                  S\R(                  R0                  S\S\R4                  R6                  4
S jjr\R(                  R*                  S4S\R,                  R.                  S\R(                  R0                  S\R(                  R0                  S\S\R4                  R6                  S-  4
S jjr\R(                  R*                  4S\R,                  R.                  S\R(                  R0                  S\R(                  R0                  SS4S jjrS\R4                  R6                  SS4S jrS\ 4S jr!S\4S jr"Sr#g)NodeG   a  A Node is a set of rdatasets.

A node is either a CNAME node or an "other data" node.  A CNAME
node contains only CNAME, KEY, NSEC, and NSEC3 rdatasets along with their
covering RRSIG rdatasets.  An "other data" node contains any
rdataset other than a CNAME or RRSIG(CNAME) rdataset.  When
changes are made to a node, the CNAME or "other data" state is
always consistent with the update, i.e. the most recent change
wins.  For example, if you have a node which contains a CNAME
rdataset, and then add an MX rdataset to it, then the CNAME
rdataset will be deleted.  Likewise if you have a node containing
an MX rdataset and add a CNAME rdataset, the MX rdataset will be
deleted.
	rdatasetsc                     / U l         g r   r0   selfs    r   __init__Node.__init__Y   s	    r   namekwr   c                     [         R                  " 5       nU R                   HG  n[        U5      S:  d  M  UR	                  UR
                  " U40 UD65        UR	                  S5        MI     UR                  5       SS $ )zConvert a node to text format.

Each rdataset at the node is printed.  Any keyword arguments
to this method are passed on to the rdataset's to_text() method.

*name*, a ``dns.name.Name``, the owner name of the
rdatasets.

Returns a ``str``.

r   
N)ioStringIOr0   lenwriteto_textgetvalue)r4   r7   r8   srdss        r   r@   Node.to_text]   sb     KKM>>C3x!|D/B/0 " zz|CR  r   c                 6    S[        [        U 5      5      -   S-   $ )Nz
<DNS node >)stridr3   s    r   __repr__Node.__repr__q   s    c"T(m+c11r   c                     U R                    H  nX!R                   ;  d  M    g   UR                    H  nX R                   ;  d  M    g   g)NFTr2   )r4   otherrds      r   __eq__Node.__eq__t   sA     ..B( ! //B' " r   c                 .    U R                  U5      (       + $ r   )rN   )r4   rL   s     r   __ne__Node.__ne__   s    ;;u%%%r   c                 ,    [        U R                  5      $ r   )r>   r0   r3   s    r   __len__Node.__len__   s    4>>""r   c                 ,    [        U R                  5      $ r   )iterr0   r3   s    r   __iter__Node.__iter__   s    DNN##r   c                 (   [        U R                  5      S:  a  [        R                  U5      nU[        R                  :X  aL  U R                   Vs/ s H.  n[        R                  U5      [        R
                  :w  d  M,  UPM0     snU l        O_U[        R
                  :X  aK  U R                   Vs/ s H.  n[        R                  U5      [        R                  :w  d  M,  UPM0     snU l        U R                  R                  U5        gs  snf s  snf )aV  Append rdataset to the node with special handling for CNAME and
other data conditions.

Specifically, if the rdataset being appended has ``NodeKind.CNAME``,
then all rdatasets other than KEY, NSEC, NSEC3, and their covering
RRSIGs are deleted.  If the rdataset being appended has
``NodeKind.REGULAR`` then CNAME and RRSIG(CNAME) are deleted.
r   N)r>   r0   r   r!   r   r   append)r4   r   kindrC   s       r   _append_rdatasetNode._append_rdataset   s     t~~"--h7Dx~~%  $~~"-11#6(:J:JJ -"
 )))  $~~"-11#6(..H -" 	h'""s   +D
 D
1+D DFrdclassr   r   createc                     U R                    H  nUR                  XU5      (       d  M  Us  $    U(       d  [        e[        R                  R                  XU5      nU R                  U5        U$ )a  Find an rdataset matching the specified properties in the
current node.

*rdclass*, a ``dns.rdataclass.RdataClass``, the class of the rdataset.

*rdtype*, a ``dns.rdatatype.RdataType``, the type of the rdataset.

*covers*, a ``dns.rdatatype.RdataType``, the covered type.
Usually this value is ``dns.rdatatype.NONE``, but if the
rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
then the covers value will be the rdata type the SIG/RRSIG
covers.  The library treats the SIG and RRSIG types as if they
were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
This makes RRSIGs much easier to work with than if RRSIGs
covering different rdata types were aggregated into a single
RRSIG rdataset.

*create*, a ``bool``.  If True, create the rdataset if it is not found.

Raises ``KeyError`` if an rdataset of the desired type and class does
not exist and *create* is not ``True``.

Returns a ``dns.rdataset.Rdataset``.
)r0   matchKeyErrorr   r   r+   r]   r4   r_   r   r   r`   rC   s         r   find_rdatasetNode.find_rdataset   s\    @ >>Cyy&11
 " Nll##GV<c"
r   Nc                 R     U R                  XX45      nU$ ! [         a    Sn U$ f = f)ag  Get an rdataset matching the specified properties in the
current node.

None is returned if an rdataset of the specified type and
class does not exist and *create* is not ``True``.

*rdclass*, an ``int``, the class of the rdataset.

*rdtype*, an ``int``, the type of the rdataset.

*covers*, an ``int``, the covered type.  Usually this value is
dns.rdatatype.NONE, but if the rdtype is dns.rdatatype.SIG or
dns.rdatatype.RRSIG, then the covers value will be the rdata
type the SIG/RRSIG covers.  The library treats the SIG and RRSIG
types as if they were a family of
types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).  This makes RRSIGs much
easier to work with than if RRSIGs covering different rdata
types were aggregated into a single RRSIG rdataset.

*create*, a ``bool``.  If True, create the rdataset if it is not found.

Returns a ``dns.rdataset.Rdataset`` or ``None``.
N)re   rc   rd   s         r   get_rdatasetNode.get_rdataset   s;    >	$$WfEC 
  	C
	s    &&c                 f    U R                  XU5      nUb  U R                  R                  U5        gg)a  Delete the rdataset matching the specified properties in the
current node.

If a matching rdataset does not exist, it is not an error.

*rdclass*, an ``int``, the class of the rdataset.

*rdtype*, an ``int``, the type of the rdataset.

*covers*, an ``int``, the covered type.
N)rh   r0   remove)r4   r_   r   r   rC   s        r   delete_rdatasetNode.delete_rdataset   s2    $ 8?NN!!#& r   replacementc                 b   [        U[        R                  R                  5      (       d  [	        S5      e[        U[        R
                  R                  5      (       a  UR                  5       nU R                  UR                  UR                  UR                  5        U R                  U5        g)a  Replace an rdataset.

It is not an error if there is no rdataset matching *replacement*.

Ownership of the *replacement* object is transferred to the node;
in other words, this method does not store a copy of *replacement*
at the node, it stores *replacement* itself.

*replacement*, a ``dns.rdataset.Rdataset``.

Raises ``ValueError`` if *replacement* is not a
``dns.rdataset.Rdataset``.
zreplacement is not an rdatasetN)
isinstancer   r   r+   
ValueErrorrrsetRRsetto_rdatasetrl   r_   r   r   r]   r4   rn   s     r   replace_rdatasetNode.replace_rdataset	  s     +s||'<'<===>>k399??33 &113K!3!3[5G5G	
 	k*r   c                     U R                    HE  n[        R                  UR                  UR                  5      nU[        R
                  :w  d  MC  Us  $    [        R
                  $ )a  Classify a node.

A node which contains a CNAME or RRSIG(CNAME) is a
``NodeKind.CNAME`` node.

A node which contains only "neutral" types, i.e. types allowed to
co-exist with a CNAME, is a ``NodeKind.NEUTRAL`` node.  The neutral
types are NSEC, NSEC3, KEY, and their associated RRSIGS.  An empty node
is also considered neutral.

A node which contains some rdataset which is not a CNAME, RRSIG(CNAME),
or a neutral type is a a ``NodeKind.REGULAR`` node.  Regular nodes are
also commonly referred to as "other data".
)r0   r   r   r   r   r   )r4   r   r\   s      r   r   Node.classify#  sM     H$$X__hooFDx''' ' r   c                     g)NFr#   r3   s    r   is_immutableNode.is_immutable8  s    r   r2   )$r$   r%   r&   r'   r(   	__slots__r5   r   r7   Namer   rG   r   r@   rI   rN   rQ   rT   rX   r]   r   NONE
rdataclass
RdataClassr*   boolr   r+   re   rh   rl   rv   r   r   r{   r,   r#   r   r   r.   r.   G   s    I!CHHMM !c3h !C !(2
&#$(@ +.--*<*<'**' ''' ''	'
 ' 
		'Z +.--*<*<#**# ''# ''	#
 # 
			%#R +.--*<*<	'**' ''' ''	'
 
',+CLL,A,A +d +4 (  *d r   r.   c                     ^  \ rS rSrU 4S jr\R                  R                  S4S\R                  R                  S\R                  R                  S\R                  R                  S\S\R                  R                  4
U 4S	 jjjr\R                  R                  S4S\R                  R                  S\R                  R                  S\R                  R                  S\S\R                  R                  S
-  4
U 4S jjjr\R                  R                  4S\R                  R                  S\R                  R                  S\R                  R                  SS
4S jjrS\R                  R                  SS
4S jrS\4S jrSrU =r$ )ImmutableNodei<  c                    > [         TU ]  5         [        UR                   Vs/ s H"  n[        R
                  R                  U5      PM$     sn5      U l        g s  snf r   )superr5   tupler0   r   r   ImmutableRdataset)r4   noderC   	__class__s      r   r5   ImmutableNode.__init__>  sB    <@NNKNSS\\++C0NK
Ks   )AFr_   r   r   r`   r   c                 J   > U(       a  [        S5      e[        TU ]	  XUS5      $ N	immutableF)	TypeErrorr   re   r4   r_   r   r   r`   r   s        r   re   ImmutableNode.find_rdatasetD  s'     K((w$WfeDDr   Nc                 J   > U(       a  [        S5      e[        TU ]	  XUS5      $ r   )r   r   rh   r   s        r   rh   ImmutableNode.get_rdatasetO  s'     K((w#GVUCCr   c                     [        S5      eNr   r   )r4   r_   r   r   s       r   rl   ImmutableNode.delete_rdatasetZ  s     $$r   rn   c                     [        S5      er   r   ru   s     r   rv   ImmutableNode.replace_rdatasetb  s    $$r   c                     g)NTr#   r3   s    r   r{   ImmutableNode.is_immutablee  s    r   r2   )r$   r%   r&   r'   r5   r   r   r   r   r   r*   r   r   r+   re   rh   rl   rv   r{   r,   __classcell__)r   s   @r   r   r   <  s   
 +.--*<*<	E**	E ''	E ''		E
 	E 
			E 	E +.--*<*<	D**	D ''	D ''		D
 	D 
			%	D 	D +.--*<*<	%**% ''% ''	%
 
%%CLL,A,A %d %d  r   r   )r(   enumr<   typingr   r   dns.immutabler   dns.namedns.rdataclassdns.rdatasetdns.rdatatype	dns.rrsetr   r   r   NSECNSEC3KEYr   r   uniqueEnumr   r.   r   r   r#   r   r   <module>r      s   $ 0  	        MM MMMMMMV >tyy > >.r rj )D ) )r   