
    ,hm                        d Z ddlZddlZddlmZmZmZ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ddlZddlZddlZ G d dej0                  j2                        Z G d dej0                  j2                        Zd Ze	ej:                  j<                  eej>                  j@                     eej>                  j@                     ee   e!e"e!e"f   Z#d	 Z$ G d
 d      Z% G d dejL                  jN                        Z( G d dejL                  jR                        Z*ddejV                  jX                  ejV                  jX                  dddej>                  jZ                  df	dedee
ej>                  j@                  e.f      dee!   dee
ejV                  j^                  e.f      de
ejV                  j^                  e.f   dee
ej`                  jb                  e.f      dee
e!e.f      deej>                  jd                     dee
ej>                  j@                  e.f      de"deejf                  jh                     fdZ5y)z
DNS Zones.    N)AnyIterableListOptionalSetTupleUnionc                       e Zd ZdZy)UnknownOriginzUnknown originN__name__
__module____qualname____doc__     N/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/dns/zonefile.pyr   r   &   s    r   r   c                       e Zd ZdZy)CNAMEAndOtherDataz!A node has a CNAME and other dataNr   r   r   r   r   r   *   s    +r   r   c                    t         j                  j                  j                  |      }| j	                  |      }|y |j                         }|t         j                  j                  j                  k(  r2|t         j                  j                  j                  k(  rt        d      |t         j                  j                  j                  k(  r3|t         j                  j                  j                  k(  rt        d      y y )Nz1rdataset type is not compatible with a CNAME nodez9CNAME rdataset is not compatible with a regular data node)	dnsnodeNodeKindclassify_rdatasetget_nodeclassifyCNAMEREGULARr   )txnnamerdatasetrdataset_kindr   	node_kinds         r   _check_cname_and_other_datar$   .   s    HH%%77AM<<D|ISXX&&,,,SXX..666 STTSXX&&...SXX..444G
 	
 5 	/r   c                 R    | j                         } | j                  d      sd| z   } | S )N$)upper
startswith)ss    r   _upper_dollarizer*   Q   s'    		A<<!GHr   c                      e Zd ZdZ	 	 	 	 	 	 	 ddej
                  j                  dej                  j                  dej                  j                  dedeeee   f   deej                   j"                     d	ee   d
eej                  j                     deej&                  j(                     dee   fdZd Zd Zd Zdedeeeeeef   fdZd ZddZy)Readerz(Read a DNS zone file into a transaction.Ntokrdclassr   allow_includeallow_directives
force_name	force_ttlforce_rdclassforce_rdtypedefault_ttlc                 f   || _         |j                  j                         \  | _        | _        }| j                  | _        d| _        d| _        ||}
|
d| _        d| _	        n|
| _        d| _	        | j
                  | _
        || _        || _        g | _        d | _        |  |du r'h d| _        |rG| j                  j!                  d       n+|du rt#               | _        nt#        d |D              | _        || _        || _        || _        |	| _        | j                  j-                  t.               y )Nr   FT>   $TTL$ORIGIN	$GENERATE$INCLUDEc              3   2   K   | ]  }t        |        y wN)r*   ).0ds     r   	<genexpr>z"Reader.__init__.<locals>.<genexpr>   s     )X!*:1*=)Xs   )r-   managerorigin_informationzone_origin
relativizecurrent_originlast_ttllast_ttl_knownr5   default_ttl_known	last_namezone_rdclassr   saved_statecurrent_fileallowed_directivesaddsetr1   r2   r3   r4   check_put_rdatasetr$   )selfr-   r.   r   r/   r0   r1   r2   r3   r4   r5   _s               r   __init__zReader.__init__[   s(    141O1O1Q.	4?A"..# #K D%*D"*D%)D",,#13+/t#&FD#''++J7& '*eD# '*)XGW)X&XD#$"*(##$?@r   c                 \    	 | j                   j                         }|j                         ry ,r<   )r-   getis_eol_or_eofrP   tokens     r   	_eat_linezReader._eat_line   s(    HHLLNE""$ r   c                     | j                   j                         }|j                         st        j                  j
                  |S r<   )r-   rT   is_identifierr   	exceptionSyntaxErrorrV   s     r   _get_identifierzReader._get_identifier   s2    ""$--+++r   c           	      
   d}| j                   | j                   }n| j                  t        | j                  j	                  d      }|j                         s,| j                  j                  || j                        | _        nF| j                  j	                         }|j                         ry| j                  j                  |       | j                  }|j                  | j                        s| j                          y| j                  r|j                  | j                        }| j                  | j                  }|| _        d| _        nL| j#                         }d}	 t$        j&                  j)                  |j*                        }|| _        d| _        d}| j.                  | j.                  }nh| j#                         }	 t$        j0                  j)                  |j*                        }|| j8                  k7  rt$        j2                  j5                  d      |L| j#                         }d}	 t$        j&                  j)                  |j*                        }|| _        d| _        d}| j>                  | j>                  }n:| j#                         }	 t$        j@                  j)                  |j*                        }	 t$        jB                  j)                  ||| j                  | j                  | j                  | j                        }| j:                  sC|t$        j@                  jJ                  k(  r&|jL                  | _        d| _        ||jL                  }|t$        j2                  j5                  d
      | jN                  jQ                  |||       y# t$        j&                  j,                  $ r | j                  j                  |       Y 8w xY w# t$        j2                  j4                  $ r  t6        $ r+ | j8                  }| j                  j                  |       Y 9w xY w# t$        j&                  j,                  $ rP | j:                  r| j<                  }n| j                   r| j                  }| j                  j                  |       Y -w xY w# t6        $ r. t$        j2                  j5                  d|j*                   d      w xY w# t$        j2                  j4                  $ r  t6        $ rR tE        jF                         dd \  }}t$        j2                  j5                  dtI        |       d	tI        |             w xY w)z&Process one line from a DNS zone file.NT)want_leadingRR class is not zone's classunknown rdatatype ''   caught exception : Missing default TTL value))r1   rD   r   r-   rT   is_whitespaceas_namerH   rU   ungetis_subdomainrB   rX   rC   r2   rE   rF   r]   r   ttl	from_textvalueBadTTLr3   
rdataclassr[   r\   	ExceptionrI   rG   r5   r4   	rdatatyperdatasysexc_infostrSOAminimumr   rM   )	rP   rW   r    rk   r.   rdtyperdtyvas	            r   _rr_linezReader._rr_line   sF   ??&??D""*##HHLLdL3E&&(!%!1!1%9L9L!M&&(u%>>D$$T%5%56 t'7'78 >>%..CDM"&D((*EC&gg''4 #&*#
 )((G((*E&..225;;? $+++mm//0NOO;((*EC
&gg''4 #&*# (&&F((*EV00=	V$$##  B( %%&CMM4E4E*E  "zzD%)D"{jj ;--++,GHHT3#a 77>> &u%& ==,,  &++u%& 77>> &))**C((--Cu%&  Vmm//2Eekk]RS0TUUV }}(( 	 	V ||~bq)HR--++.?By3r7),TUU	VsR   &9N 	)O 59P/ )R AS 8OOAP,+P,/A)RR7SA8Usidereturnc                    t        j                  d      }t        j                  d      }t        j                  d      }d}d}d}d}d}	|j                  |      }
|
r|
j                         \  }}}}}	|dk(  rgd}nd|j                  |      }|r |j                         \  }}}|dk(  rd}d}d}	n1|j                  |      }|r|j                         \  }}}}|dk(  rd}d}	t	        |      }t	        |      }|dvr"t
        j                  j                  d	|       |	d
vr"t
        j                  j                  d|	       |||||	fS )Nz"^.*\$({(\+|-?)(\d+),(\d+),(.)}).*$z^.*\$({(\+|-?)(\d+)}).*$z^.*\$({(\+|-?)(\d+),(\d+)}).*$ +0r>   )r   -zinvalid offset sign )r>   oxXnNzinvalid type )recompilematchgroupsintr   r[   r\   )rP   r}   is_generate1is_generate2is_generate3modsignoffsetwidthbaseg1g2g3ioffsetiwidths                  r   _parse_modifyzReader._parse_modify  sa    zz"GHzz"=>zz"CD %-/YY[*Cvudrz##D)B$&IIK!T62:D!''-/1yy{,Cvurz"Df+Uz!--++.B4&,IJJ55--++mD6,BCCD'64//r   c           
      ~   | j                   t        | j                  j                         }	 t        j
                  j                  |j                        \  }}}| j                  j                         }|j                         st        j                  j                  	 	 |j                  }| j                  j                         }|j                         st        j                  j                  	 	 t        j                  j                  |j                        }|| _        d| _        | j                  j                         }|j                         st        j                  j                  	 	 t        j$                  j                  |j                        }| j                  j                         }|j                         st        j                  j                  	 || j&                  k7  rt        j                  j                  d      	 t        j(                  j                  |j                        }| j                  j                         }|j                         st        j                  j                  	 |j                  }	dt*        dt,        d	t*        d
t*        fd}
dt*        dt,        dt*        d
t,        ffd| j/                  |      \  }}}}}| j/                  |	      \  }}}}}t1        ||dz   |      D ]Y  } |
|||      } |
|||      } |||      } |||      }|j3                  d| |      }|	j3                  d| |      }t        j4                  j                  || j                   | j                  j6                        | _        | j8                  }|j;                  | j<                        s| j?                           y| j@                  r|jA                  | j<                        }	 t        jB                  j                  |||| j                   | j@                  | j<                        }| jH                  jK                  ||       \ y# t        $ r t        j                  j                  w xY w# t        $ r t        j                  j                  w xY w# t        j                  j                  $ rl | j                  s+| j                   st        j                  j                  d      | j                   r| j"                  }n| j                  r| j                  }Y w xY w# t        j                  j                  $ r t        j                  j                  t        $ r | j&                  }Y w xY w# t        $ r. t        j                  j                  d|j                   d      w xY w# t        j                  j                  $ r  t        $ rR tE        jF                         dd \  }}t        j                  j                  dt-        |       dt-        |             w xY w)zPProcess one line containing the GENERATE statement from a DNS
        zone file.NTrf   r`   ra   rb   counteroffset_signr   r~   c                      |dk(  r|dz  }| |z   S )z0Calculate the index from the counter and offset.r   r   )r   r   r   s      r   _calculate_indexz/Reader._generate_line.<locals>._calculate_index  s    c!"V##r   indexr   r   c                     |dv rt        | |      j                  |      S  | d|      }dj                  |ddd         d| }|dk(  r|j                         }|S )zVFormat the index with the given base, and zero-fill it
            to the given width.)r>   r   r   r   r   .Nr   r   )formatzfilljoinr'   )r   r   r   hexanibbles_format_indexs        r   r   z,Reader._generate_line.<locals>._format_index  sj     ++eT*0077 !U3DhhtDbDz*6E2Gs{!--/Nr      r&   rc   rd   re   )&rD   r   r-   rT   r   grangerl   rm   rZ   r[   r\   rp   rk   rE   rF   rn   rG   r5   ro   rI   rq   r   ru   r   rangereplacer    
idna_codecrH   rj   rB   rX   rC   rr   rs   rt   r   rM   ) rP   rW   startstopsteplhsrk   r.   rx   rhsr   lmodlsignloffsetlwidthlbasermodrsignroffsetrwidthrbaseilindexrindexlzfindexrzfindexr    rr   ry   rz   r{   r   s                                   @r   _generate_linezReader._generate_line>  s)    &	, #

 4 4U[[ AE4HHLLNE&&(mm/// )	,++CHHLLNE&&(mm/// )	$''##EKK0CDM"&DHHLLNE&&(mm/// )	(nn..u{{;GHHLLNE&&(mm/// ) d'''--++,JKK	R]],,U[[9FHHLLNE&&(mm/// ) kk	$c 	$ 	$S 	$S 	$	 	C 	 	 	 /3.@.@.E+eWfe.2.@.@.E+eWfeudQh- -	(A &a8F%a8F$VUF;H$VUF;H;;4&z84DKK!D6
H5E XX//d))488+>+>DN >>D$$T%5%56 t'7'78YY((''OO$$, HHLLsB'[-	(Q  	,--+++	,  	,--+++	, ww~~ 	$''4+A+Amm//0KLL%%&&$$mm	$ }}(( 	,--+++ 	(''G	(  	R--++.A%++a,PQQ	Rt ==,,  	 <<>"1-Rmm//'By3r7)< 	s\   A1Q "AR 4A;R, 1A-T8 A-V
 ;AW$R$R),BT54T58AVV
7WA8X<c           
      t
   	 	 | j                   j                  dd      }|j                         r| j                  | j                  j	                          t        | j                        dkD  rM| j                  j                  d      \  | _         | _        | _	        | _        | _
        | _        | _        | _        y|j                         r|j                         r| j                   j!                          |j"                  d   dk(  rot        | j$                        dkD  rV|j"                  j'                         }|| j$                  vr#t(        j*                  j-                  d| d      |dk(  r| j                   j                         }|j/                         st(        j*                  j-                  d	      t(        j0                  j3                  |j"                        | _        d| _        | j                   j!                          nj|d
k(  r}| j                   j5                         | _        | j                   j!                          | j6                  | j                  | _        | j8                  j;                  | j                         n|dk(  r| j                   j                         }|j"                  }| j                   j                         }|j/                         rdt(        j<                  j3                  |j"                  | j                  | j                   j>                        }| j                   j!                          n;|jA                         st(        j*                  j-                  d      | j                  }| j                  jC                  | j                   | j                  | j                  | j                  | j                  | j                  | j                  | j                  f       tE        |      | _        t(        jF                  jI                  | j                  |      | _         || _        n9|dk(  r| jK                          n#t(        j*                  j-                  d| d      w| j                   jM                  |       | jO                          # t(        j*                  j,                  $ rt}| j                   jQ                         \  }}|d}t(        j*                  j-                  d|||fz        }tS        jT                         d   }|jW                  |      dd}~ww xY w)zRead a DNS zone file and build a zone object.

        @raises dns.zone.NoSOA: No SOA RR was found at the zone origin
        @raises dns.zone.NoNS: No NS RRset was found at the zone origin
        TNr   r   r&   zzone file directive 'z' is not allowedr7   zbad $TTLr8   r:   zbad origin in $INCLUDEr9   zUnknown zone file directive 'rb   zsyntax errorz	%s:%d: %src   ),r-   rT   is_eofrK   closelenrJ   poprD   rH   rE   rF   r5   rG   is_eol
is_commentget_eolrm   rL   r'   r   r[   r\   rZ   rk   rl   get_namerB   r   _set_originr    r   rU   appendopen	tokenizer	Tokenizerr   ri   r|   wherers   rt   with_traceback)	rP   rW   cfilename
new_origindetailline_numberextbs	            r   readzReader.read  s   [	2T40<<>((4))//14++,q0 !,,004	 H / N - M / , 2 \\^%%'HH$$&[[^s*s43J3J/Ka/O ))+A 7 77!mm773A36FG  F{ $$224"%--";";J"GG+.77+<+<U[[+I(15.((*i.2hh.?.?.A+((*++3/3/B/BD,,,T-@-@Aj $#(;; $ ..0),);); %T-@-@$((BUBU*J !HH,,.!&!4!4!6"%--";";<T"UU)-)<)<J((// $ $ 3 3 $ $ 1 1 $ $ 3 3 $ 0 0 $ 6 6	 -1N)#&==#:#:4;L;Lh#W.8+k)++-!mm77;A3a@  u%c d }}(( 	2&*hhnn&6#X{~'**xf==B "B##B'T1	2s    B8R& ;O+R& &T7A/T22T7)FTNNNNN)r~   N)r   r   r   r   r   r   r   ro   
RdataClasstransactionTransactionboolr	   r   ru   r   r    Namer   rq   	RdataTyperR   rX   r]   r|   r   r   r   r   r   r   r   r,   r,   X   s0   2 $7;.2#'=A:>%)0A]]$$0A **0A __((	0A
 0A  hsm 340A SXX]]+0A C=0A   9 9:0A s}}6670A c]0Adv$p+0# +0%S#sC0G*H +0ZC(Jb2r   r,   c                   `     e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Z xZS )RRsetsReaderTransactionc                 >    |rJ t         |   |||       i | _        y r<   )superrR   	rdatasets)rP   r@   replacement	read_only	__class__s       r   rR   z RRsetsReaderTransaction.__init__)  s!    +y9r   c                 >    | j                   j                  |||f      S r<   )r   rT   rP   r    rx   coverss       r   _get_rdatasetz%RRsetsReaderTransaction._get_rdataset.  s    ~~!!4"899r   c                     g }| j                   j                         D ]   \  \  }}}}||k(  s|j                  |       " t        |      dk(  ry t        j
                  j                         }||_         |S Nr   )r   itemsr   r   r   r   Node)rP   r    r   rdataset_namerQ   r!   r   s          r   	_get_nodez!RRsetsReaderTransaction._get_node1  sq    	/3~~/C/C/E 	++!]Aq8}$  *	+ y>Qxx}}"r   c                 P    || j                   ||j                  |j                  f<   y r<   )r   rx   r   )rP   r    r!   s      r   _put_rdatasetz%RRsetsReaderTransaction._put_rdataset<  s    CKhoox?@r   c                     g }| j                   D ]  }|d   |k(  s|j                  |        t        |      dkD  r|D ]  }| j                   |=  y y r   )r   r   r   )rP   r    removekeys       r   _delete_namez$RRsetsReaderTransaction._delete_name?  s^    >> 	#C1v~c"	# v;? (NN3'( r   c                 D    	 | j                   |||f= y # t        $ r Y y w xY wr<   )r   KeyErrorr   s       r   _delete_rdatasetz(RRsetsReaderTransaction._delete_rdatasetI  s,    	ff56 		s    	c                 <    | j                   D ]  \  }}}||k(  s y yNTF)r   )rP   r    r   rQ   s       r   _name_existsz$RRsetsReaderTransaction._name_existsO  s*    ~~ 	GAq!Dy	 r   c                 2    t        | j                        dkD  S r   )r   r   rP   s    r   _changedz RRsetsReaderTransaction._changedU  s    4>>"Q&&r   c                 v   |r| j                         rg }| j                  j                         D ]k  \  \  }}}}t        j                  j                  ||j                  |j                  |j                        }|j                  |       |j                  |       m | j                  j                  |       y y y r<   )r  r   r   r   rrsetRRsetr.   rx   r   updater   r@   
set_rrsets)rP   commitrrsetsr    rQ   r!   r  s          r   _end_transactionz(RRsetsReaderTransaction._end_transactionX  s    dmmoF*...*>*>*@ %&q!h		(**HOOX__ X&e$% LL##F+ &6r   c                      y r<   r   )rP   origins     r   r   z#RRsetsReaderTransaction._set_originc  s    r   c                     t         r<   NotImplementedErrorr  s    r   _iterate_rdatasetsz*RRsetsReaderTransaction._iterate_rdatasetsf      !!r   c                     t         r<   r  r  s    r   _iterate_namesz&RRsetsReaderTransaction._iterate_namesi  r  r   )r   r   r   rR   r   r   r   r   r   r   r  r  r   r  r  __classcell__)r   s   @r   r   r   (  s@    
:	L('	,""r   r   c                       e Zd Zej                  j
                  dej                  j                  fdZd Z	d	dZ
d Zd Zd Zy)
RRSetsReaderManagerFc                 <    || _         || _        || _        g | _        y r<   )r  rC   r.   r
  )rP   r  rC   r.   s       r   rR   zRRSetsReaderManager.__init__n  s      $r   c                     t         r<   r  r  s    r   readerzRRSetsReaderManager.readerv  r  r   c                 (    |du sJ t        | dd      S r   )r   )rP   r   s     r   writerzRRSetsReaderManager.writery  s    d""&tT599r   c                     | j                   S r<   )r.   r  s    r   	get_classzRRSetsReaderManager.get_class}  s    ||r   c                     | j                   rt        j                  j                  }n| j                  }| j                  | j                   |fS r<   )rC   r   r    emptyr  )rP   	effectives     r   rA   z&RRSetsReaderManager.origin_information  s4    ??IIT__i88r   c                     || _         y r<   )r
  )rP   r
  s     r   r  zRRSetsReaderManager.set_rrsets  s	    r   N)F)r   r   r   r   r    rootro   INrR   r  r  r  rA   r  r   r   r   r  r  m  s9    XX]]ucnn>O>O":9r   r  Ftextr    rk   r.   default_rdclassrx   r5   r   r  rC   r~   c
                    t        |t              r9t        j                  j	                  |t        j                  j
                  |      }t        |t              r!t        j                  j	                  |||      }t        |t              rt        j                  j	                  |      }t        |t              rt        j                  j	                  |      }|*t        j                  j                  j                  |      }nd}t        j                  j                  j                  |      }|*t        j                  j                  j                  |      }nd}t        ||	|      }
|
j                  d      5 }t        j                  j                  | d|      }t!        |||d|||||	      }|j#                          ddd       |
j$                  S # 1 sw Y   |
j$                  S xY w)a	  Read one or more rrsets from the specified text, possibly subject
    to restrictions.

    *text*, a file object or a string, is the input to process.

    *name*, a string, ``dns.name.Name``, or ``None``, is the owner name of
    the rrset.  If not ``None``, then the owner name is "forced", and the
    input must not specify an owner name.  If ``None``, then any owner names
    are allowed and must be present in the input.

    *ttl*, an ``int``, string, or None.  If not ``None``, the the TTL is
    forced to be the specified value and the input must not specify a TTL.
    If ``None``, then a TTL may be specified in the input.  If it is not
    specified, then the *default_ttl* will be used.

    *rdclass*, a ``dns.rdataclass.RdataClass``, string, or ``None``.  If
    not ``None``, then the class is forced to the specified value, and the
    input must not specify a class.  If ``None``, then the input may specify
    a class that matches *default_rdclass*.  Note that it is not possible to
    return rrsets with differing classes; specifying ``None`` for the class
    simply allows the user to optionally type a class as that may be convenient
    when cutting and pasting.

    *default_rdclass*, a ``dns.rdataclass.RdataClass`` or string.  The class
    of the returned rrsets.

    *rdtype*, a ``dns.rdatatype.RdataType``, string, or ``None``.  If not
    ``None``, then the type is forced to the specified value, and the
    input must not specify a type.  If ``None``, then a type must be present
    for each RR.

    *default_ttl*, an ``int``, string, or ``None``.  If not ``None``, then if
    the TTL is not forced and is not specified, then this value will be used.
    if ``None``, then if the TTL is not forced an error will occur if the TTL
    is not specified.

    *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA
    encoder/decoder.  If ``None``, the default IDNA 2003 encoder/decoder
    is used.  Note that codecs only apply to the owner name; dnspython does
    not do IDNA for names in rdata, as there is no IDNA zonefile format.

    *origin*, a string, ``dns.name.Name``, or ``None``, is the origin for any
    relative names in the input, and also the origin to relativize to if
    *relativize* is ``True``.

    *relativize*, a bool.  If ``True``, names are relativized to the *origin*;
    if ``False`` then any relative names in the input are made absolute by
    appending the *origin*.
    NTz<input>)r   F)r0   r1   r2   r3   r4   r5   )
isinstanceru   r   r    rl   r#  rk   ro   r   makerq   r   r  r  r   r   r,   r   r
  )r%  r    rk   r.   r&  rx   r5   r   r  rC   r@   r   r-   r  s                 r   read_rrsetsr*    s   z &###FCHHMM:F$xx!!$
;#sgg$+s#gg''4..++009nn//44_EO((--f5!&*oFG		 mm%%dI*%M"!#

 	 >> >>s   <AGG+)6r   r   rs   typingr   r   r   r   r   r   r	   dns.exceptionr   
dns.grangedns.namedns.node	dns.rdatadns.rdataclassdns.rdatatypedns.rdtypes.ANY.SOA	dns.rrsetdns.tokenizerdns.transactiondns.ttlr[   DNSExceptionr   r   r$   r   r   r    r   r   r   SavedStateTyper*   r,   r   r   r   TransactionManagerr  ro   r$  r#  ru   r   rq   r   	IDNACodecr  r  r*  r   r   r   <module>r<     sV  $  	 
 C C C            CMM.. ,22 ,
. MMSXX]]SXX]]SM
	M2 M2`B"coo99 B"J#//<< @ 15?B~~?P?P=@^^=N=N<@-1/325((--]
]
5+,
-] 
#] eCNN55s:;<	]
 3>>44c9:] U3==22C789] %S/*] ++,] U388==#-./] ] 
#))//]r   