
    i3                     R   d dl Z d dlm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	d dlZ	 G d de j                  Z G d de	j        j                  Ze	j        j         G d d	e                      Z G d
 de	j        j        e	j        j                           Z G d de	j        j                  Z ed           G d d                      Ze	j        j         G d de	j        j                               Z! G d de	j"        j#                  Z#dS )    N)	dataclass)CallableMutableMappingTuplecastc                       e Zd ZdZdZdZdS )	NodeFlags         N)__name__
__module____qualname__ORIGIN
DELEGATIONGLUE     ]/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/dns/btreezone.pyr	   r	      s        FJDDDr   r	   c                   L     e Zd ZddgZd	dedz  f fdZd Zd Zd Zd Z	 xZ
S )
NodeflagsidNc                     t                                                       |t          d          }|| _        d| _        d S Nr   )super__init__r	   r   r   )selfr   	__class__s     r   r   zNode.__init__&   s=    = aLLE
r   c                 2    | j         t          j        z  dk    S r   )r   r	   r   r   s    r   is_delegationzNode.is_delegation0   s    
Y11a77r   c                 2    | j         t          j        z  dk    S r   )r   r	   r   r!   s    r   is_gluezNode.is_glue3   s    
Y^+11r   c                 2    | j         t          j        z  dk    S r   )r   r	   r   r!   s    r   	is_originzNode.is_origin6   s    
Y--!33r   c                 L    | j         t          j        t          j        z  z  dk    S r   )r   r	   r   r   r!   s    r   is_origin_or_gluezNode.is_origin_or_glue9   s    
i.?@QFFr   N)r   r   r   	__slots__r	   r   r"   r$   r&   r(   __classcell__r   s   @r   r   r   #   s        $I i$.      8 8 82 2 24 4 4G G G G G G Gr   r   c                       e Zd Zdef fdZej        j        dfdej        j	        dej        j
        dej        j
        dedej        j        f
 fd	Zej        j        dfdej        j	        dej        j
        dej        j
        dedej        j        d
z  f
 fdZej        j        fdej        j	        dej        j
        dej        j
        dd
fdZdej        j        dd
fdZdefdZ xZS )ImmutableNodenodec                     t                                                       |j        | _        t          d |j        D                       | _        |j        | _        d S )Nc                 L    g | ]!}t           j                            |          "S r   )dnsrdatasetImmutableRdataset).0rdss     r   
<listcomp>z*ImmutableNode.__init__.<locals>.<listcomp>C   s(    KKKSS\++C00KKKr   )r   r   r   tuple	rdatasetsr   )r   r/   r   s     r   r   zImmutableNode.__init__?   sU    'KKDNKKK
 
 Z


r   Frdclassrdtypecoverscreatereturnc                 n    |rt          d          t                                          |||d          S N	immutableF)	TypeErrorr   find_rdatasetr   r:   r;   r<   r=   r   s        r   rC   zImmutableNode.find_rdatasetG   s9      	)K(((ww$$WffeDDDr   Nc                 n    |rt          d          t                                          |||d          S r@   )rB   r   get_rdatasetrD   s        r   rF   zImmutableNode.get_rdatasetR   s9      	)K(((ww##GVVUCCCr   c                      t          d          NrA   rB   )r   r:   r;   r<   s       r   delete_rdatasetzImmutableNode.delete_rdataset]   s     $$$r   replacementc                      t          d          rH   rI   )r   rK   s     r   replace_rdatasetzImmutableNode.replace_rdatasete   s    $$$r   c                     dS NTr   r!   s    r   is_immutablezImmutableNode.is_immutableh   s    tr   )r   r   r   r   r   r2   	rdatatypeNONE
rdataclass
RdataClass	RdataTypeboolr3   RdatasetrC   rF   rJ   rM   rP   r+   r,   s   @r   r.   r.   =   s        T             +.-*<	E 	E*	E '	E '		E
 	E 
		E 	E 	E 	E 	E 	E +.-*<	D 	D*	D '	D '		D
 	D 
		%	D 	D 	D 	D 	D 	D +.-*<	% %*% '% '	%
 
% % % %%CL,A %d % % % %d        r   r.   c                       e Zd Zdej        j        deej        j        dz  ef         fdZdej        j        defdZ	dS )Delegationsnamer>   Nc                 Z   |                                  }|                    |d           |                                }|dS |                                }|                    |          \  }}}|t
          j        j        j        k    }|s|t
          j        j        j	        k    r||fS dS )aF  Get the delegation applicable to *name*, if it exists.

        If there delegation, then return a tuple consisting of the name of
        the delegation point, and a boolean which is `True` if the name is a proper
        subdomain of the delegation point, and `False` if it is equal to the delegation
        point.
        FbeforeNNF)
cursorseekprevkeyfullcomparer2   rZ   NameRelation	SUBDOMAINEQUAL)r   rZ   r_   ra   cutreln_is_subdomains           r   get_delegationzDelegations.get_delegationm   s     D'''{{}}<;hhjj%%c**
asx4>> 	438#8#>>>$$;r   c                     |                                  }|                    |d           |                     |          \  }}|dS |S )z0Is *name* glue, i.e. is it beneath a delegation?Fr\   )r_   r`   rk   )r   rZ   r_   rg   rj   s        r   r$   zDelegations.is_glue   sM    D''' //55\;5r   )
r   r   r   r2   rZ   Namer   rV   rk   r$   r   r   r   rY   rY   l   st        38= U38=4;OQU;U5V    *CHM d      r   rY   c                       e Zd Zddej        j        def fdZdej        j	        defdZ
dej        j	        deej        j        ej        j	        f         f fdZdej        j	        d	edd
fdZdej        j	        dd
fdZdej        j	        dej        j        dd
fdZdej        j	        dej        j        dej        j        dd
fdZ xZS )WritableVersionFzonerK   c                 ^   t                                          |d           |stt          |t          j        j                  sJ |j        d         }t          j                            |j	                  | _	        t          |j                  | _        d S t                      | _        d S )NT)original)r   r   
isinstancer2   	versionedZone	_versionsbtree	BTreeDictnodesrY   delegations)r   rp   rK   versionr   s       r   r   zWritableVersion.__init__   s    t$$$ 	-dCM$677777nR(GCF9CVCV  DW D DDJ  +G4GHHHD*}}Dr   rZ   r>   c                 d    | j         j        r|t          j        j        k    S || j         j        k    S r)   )rp   
relativizer2   rZ   emptyorigin)r   rZ   s     r   
_is_originzWritableVersion._is_origin   s0     9 	,38>))49+++r   c                 F   t                                          |          \  }}t          t          |          }|                     |          r|xj        t          j        z  c_        n4| j        	                    |          r|xj        t          j
        z  c_        ||fS r)   )r   _maybe_cow_with_namer   r   r   r   r	   r   r{   r$   r   )r   rZ   r/   r   s      r   r   z$WritableVersion._maybe_cow_with_name   s     ww33D99tD$??4   	)JJ)**JJJ%%d++ 	)JJ).(JJd|r   r$   Nc                    | j                                         }|                    |d           g }	 |                                }|n-|                                }|                    |          snt          t          j        j	        |
                                          }|| j        vr`| j                                        }| j        |_        |j                            |j                   | j                            |           |}t%          |t                    sJ |r|xj        t(          j        z  c_        n|xj        t(          j         z  c_        |                    ||f           E|D ]\  }}|| j         |<   d S r^   )rz   r_   r`   nextrb   rj   r   r2   r/   r   valuechangedrp   node_factoryr   r9   extendaddrt   r   r	   r   append)	r   rZ   r$   r_   updateseltenamer/   new_nodes	            r   update_glue_flagz WritableVersion.update_glue_flag   sw   ""$$D%   	*++--C{GGIIE%%d++ syy{{33DDL((91133"g"))$.999  '''dD))))) .

in,




y~o-


 NNE4=)))/	*0 # 	% 	%KE4 $DJu	% 	%r   c                 8   |                      |          }| j                            |          }|h|                                r0| j                            |           |                     |d           | j        |= | j                            |           d S d S r^   )	_validate_namerz   getr"   r{   discardr   r   r   )r   rZ   r/   s      r   delete_nodezWritableVersion.delete_node   s    ""4((z~~d##!!## 3 ((...%%dE222
4 LT""""" r   r3   c                 b   |                      |          \  }}|j        t          j        j        k    rg|                                sS|xj        t          j        z  c_        || j	        vr0| j	        
                    |           |                     |d           |                    |           d S rO   )r   r;   r2   rQ   NSr(   r   r	   r   r{   r   r   rM   )r   rZ   r3   r/   s       r   put_rdatasetzWritableVersion.put_rdataset   s     0066tOs}///8N8N8P8P/JJ)..JJ4+++ $$T***%%dD111h'''''r   r;   r<   c                    |                      |          \  }}|t          j        j        k    rT|| j        v rK|xj        t          j         z  c_        | j                            |           | 	                    |d           |
                    | j        j        ||           t          |          dk    r
| j        |= d S d S )NFr   )r   r2   rQ   r   r{   r   r	   r   r   r   rJ   rp   r:   lenrz   )r   rZ   r;   r<   r/   s        r   rJ   zWritableVersion.delete_rdataset   s     0066tS]%%%$$2B*B*BJJ9///JJ$$T***!!$...TY.???t99>>
4    >r   )F)r   r   r   r2   rp   rv   rV   r   rZ   rm   r   r   r/   r   r   r   r   r3   rW   r   rQ   rU   rJ   r+   r,   s   @r   ro   ro      s       
- 
-SX] 
- 
- 
- 
- 
- 
- 
-,sx} , , , , ,	HM		sx}chm+	,	 	 	 	 	 	%SX] %T %d % % % %># #$ # # # #(HM(-0\-B(	( ( ( (!hm! '! '	!
 
! ! ! ! ! ! ! !r   ro   T)frozenc                       e Zd ZU ej        j        ed<   ej        j        ed<   ej        j        dz  ed<   ej        j        ed<   eed<   eed<   d ZdS )	BoundsrZ   leftNrightclosest_encloseris_equalr"   c           
      ~    | j         rd}nd}| j        rd}nd}| j         d| d| j         d| j         | d| j         
S )N=<z zonecut  z < z; )r   r"   r   rZ   r   r   )r   opzonecuts      r   __str__zBounds.__str__   s    = 	BBB 	 GGGy ' '2 ' '	 ' 'dj '' ' '$' '	
r   )	r   r   r   r2   rZ   rm   __annotations__rV   r   r   r   r   r   r      s         
(-
(-8=4hm###NNN
 
 
 
 
r   r   c                   b     e Zd Zdej        j        f fdZdej        j        e	z  de
fdZ xZS )ImmutableVersionr|   c                 N   t          |t                    st          d          t                                          |j        d           |j        | _        |j        | _        |j        D ]5}|j	        
                    |          }|rt          |          |j	        |<   6t          t          t          j        j        t          j        j        f         |j	                  | _	        | j	                                         |j        | _        | j                                         d S )NzIa dns.btreezone.ImmutableVersion requires a dns.btreezone.WritableVersionT)rt   ro   
ValueErrorr   r   rp   r   r   r   rz   r   r.   r   r   r2   rZ   rm   r/   r   make_immutabler{   )r   r|   rZ   r/   r   s       r   r   zImmutableVersion.__init__  s    '?33 	0   	t,,,*nO 	: 	:D=$$T**D :&3D&9&9d#.)EFVV

!!###".'')))))r   rZ   r>   c                 <   | j         J | j                            | j                   }| j                            |          }| j                            |          \  }}||}d}n|}d}t          t          j        j        | j	                  
                                }|                    |d           |                                }|J |                                 	 |                                }	|	&|	                                                                sn>|                                                    |          }
|	*|	                                }|                    |          }n#t          j        j        dt)          |          f}d}t          j                            |t-          |
d         |d                    d                   }t/          ||                                |||
d         t          j        j        j        k    |          S )aT  Return the 'bounds' of *name* in its zone.

        The bounds information is useful when making an authoritative response, as
        it can be used to determine whether the query name is at or beneath a delegation
        point.  The other data in the ``Bounds`` object is useful for making on-the-fly
        DNSSEC signatures.

        The left bound of *name* is *name* itself if it is in the zone, or the greatest
        predecessor which is in the zone.

        The right bound of *name* is the least successor of *name*, or ``None`` if
        no name in the zone is greater than *name*.

        The closest encloser of *name* is *name* itself, if *name* is in the zone;
        otherwise it is the name with the largest number of labels in common with
        *name* that is in the zone, either explicitly or by the implied existence
        of empty non-terminals.

        The bounds *is_equal* field is ``True`` if and only if *name* is equal to
        its left bound.

        The bounds *is_delegation* field is ``True`` if and only if the left bound is a
        delegation point.
        NTFrr   r   r   )r   rp   r   r{   rk   r   r2   rx   ry   rz   r_   r`   ra   r   r   r$   rb   rc   rZ   NAMERELN_COMMONANCESTORr   rm   maxr   rd   rf   )r   rZ   r   rg   ri   targetr"   cr   r   left_comparison	right_keyright_comparisonr   s                 r   boundszImmutableVersion.bounds  s   2 {&&&))$+66y''--!0066Q?F MMF!M$dj1188::	vuvvxx		FFHHE}EKKMM$9$9$;$;}	 ((**0066		I(44T:: 0F 
 I8==#oa(*:1*=>>>@@A
 
 HHJJA#("7"==
 
 	
r   )r   r   r   r2   rp   Versionr   rZ   rm   strr   r   r+   r,   s   @r   r   r   
  s~        * 0 * * * * * *&B
38=3. B
6 B
 B
 B
 B
 B
 B
 B
 B
r   r   c                      e Zd ZU eZeg ej        j        f         ed<    e	eg e
ej        j        ej        j        f         f         ej        j        ej        j        ef                   Zeg e
ej        j        ej        j        f         f         ed<   eZeej        j        egej        j        f         dz  ed<   eZeej        j        gej        j        f         dz  ed<   dS )rv   r   map_factoryNwritable_version_factoryimmutable_version_factory)r   r   r   r   r   r   r2   r/   r   r   r   rZ   rm   rx   ry   r   ro   r   rp   rv   rV   r   r   r   r   r   r   rv   rv   d  s        04L(2sx},-444NRd^CHM38=$@AAB	CHM4/0O OK"nSX]CHM-IJJK    	 #(-&(889D@   	 x)9(:CH<L(LMPTT     r   rv   )$enumdataclassesr   typingr   r   r   r   	dns.btreer2   dns.immutabledns.namedns.nodedns.rdataclassdns.rdatasetdns.rdatatypedns.versioneddns.zoneIntFlagr	   r/   r   rA   r.   rx   BTreeSetrZ   rm   rY   rp   ro   r   r   r   ru   rv   r   r   r   <module>r      s~    ! ! ! ! ! ! 8 8 8 8 8 8 8 8 8 8 8 8                                  G G G G G38= G G G4 + + + + +D + + +\    #)$SX]3   @c! c! c! c! c!ch. c! c! c!L $
 
 
 
 
 
 
 
. V
 V
 V
 V
 V
sx' V
 V
 V
r    3=     r   