fP UdZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZmZmZddlmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl$ZejJdk(rddl&ZGddejNjPZ)Gdd ejNjPZ*ee e+e,e-ee.e+fe ej^j`fZ1d e e1d e e+fd Z2Gd dejNjfZ4e4Z3GddejNjPZ5GddejNjPZ6GddejNjPZ7GddejNjPZ8GddejNjPZ9GddejNjPZ:GddZ;Gdde<Z=Gdd e=Z>Gd!d"Z?Gd#d$Z@eejjejjejjfZGGd%d&e@ZHGd'd(ZIGd)d*e@ZJGd+d,ZKGd-d.ZLGd/d0eLZMdaNe eMeOd1<d eMfd2ZPdYd3ZQejjejjd4dd5dddfd6eejje+fd7eejje+fd8eejje+fd9e,d:e e+d;e,de e,d e;fd?ZUejjejjd4dd5ddfd6eejje+fd7eejje+fd8eejje+fd9e,d:e e+d;e,dfdGZYdEeejje+fd ejjfdHZZdZd=eTd dfdIZ[ejjd4ddfdEeejje+fd8ejjd9e,dJe eMd=e eTd ejjf dKZ\dLejdfdMeejje+fdNe-dFe-dJe eMd eMf dOZ]ejjejjd4dd5ddddLejdf dMeejje+fd6eejje+fd7eejje+fd8eejje+fd9e,d:e e+d;e,de e,dNe-dFe-dJe eMd e;fdPZ^ejejgejejgiZcdadejZfejZhejZjejZlejZnejZpddejdddfdQZqd[dRZrd\dSZsdTZtdUZudVZvd\dJe eMd dfdWZwdYdXZxy)]DNS stub resolver.N)AnyDictIteratorListOptionalSequenceTupleUnion)urlparsewin32cneZdZdZddhZdZfdZddZdeffd Z e d Z d Z d Z d Zd ZxZS)NXDOMAINz"The DNS query name does not exist.qnames responsesNc$t||i|yNsuper__init__selfargskwargs __class__s U/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dns/resolver.pyrzNXDOMAIN.__init__> $)&)ct|tttfs t dt |dk(r t d|i}nt|t s t dt ||}|S)Nz#qnames must be a list, tuple or setrz(qnames must contain at least one elementz(responses must be a dict(qname=response)rr) isinstancelisttuplesetAttributeErrorlendict)rrrrs r _check_kwargszNXDOMAIN._check_kwargsAsi&4"45 !FG G v;!  !KL L  IIt, !KL LVy9 rreturncd|jvrt| S|jd}t|dkDrd}nd}dj t t |}dj||S)NrzNone of DNS query names existz!The DNS query name does not existz, z{}: {})rr__str__r&joinmapstrformat)rrmsgrs rr,zNXDOMAIN.__str__Mse 4;; &7?$ $X& v;?1C5C3sF+,sF++rcd|jvr td|jdD].}|jd|} |j}||k7r|cS0|jddS#t$rYNwxYw)z%Return the unresolved canonical name.rzparametrized exception requiredrr)r TypeErrorcanonical_name Exception)rqnameresponsecnames rr4zNXDOMAIN.canonical_nameXs 4;; &=> >[[*E{{;/6H  //1E> L" +{{8$Q''   sA,, A87A8cnt|jjdg}t|jjdi}|jjdi}|jjdgD]$}||vr|j |||vs||||<&t ||S)z3Augment by results from another NXDOMAIN exception.rrr )r"rgetr'appendr)re_nxqnames0 responses0 responses1qname1s r__add__zNXDOMAIN.__add__ist{{x45$++//+r:; [[__["5 kkooh3FW$v&#%/%7 6" 4 w*==rc |jdS)zXAll of the names that were tried. Returns a list of ``dns.name.Name``. rrrs rrzNXDOMAIN.qnamesus {{8$$rc |jdS)zA map from queried names to their NXDOMAIN responses. Returns a dict mapping a ``dns.name.Name`` to a ``dns.message.Message``. rrCrDs rrzNXDOMAIN.responses|s {{;''rc&|jd|S)zTThe response for query *qname*. Returns a ``dns.message.Message``. rrC)rr6s rr7zNXDOMAIN.responses {{;'..rr)__name__ __module__ __qualname____doc__ supp_kwargsfmtrr(r/r,propertyr4rArrr7 __classcell__rs@rrr4sS,[)K C *  , ,(( >%(/rrceZdZdZy)YXDOMAINz8The DNS query name is too long after DNAME substitution.NrGrHrIrJrrrQrQsBrrQerrorsr)cfg}|D])}|jdj|d|d+|S)z3Turn a resolution errors trace into a list of text.zServer {} answered {}r)r;r0)rTtextserrs r_errors_to_textrYs8 E ,33CFCFCD LrcHeZdZdZdZdeddzZddhZfdZfdZxZ S) LifetimeTimeoutz The resolution lifetime expired.z(%s after {timeout:.3f} seconds: {errors}NtimeoutrTc$t||i|yrrrs rrzLifetimeTimeout.__init__rrc ft|d}t| |ddj|S)NrTr]; r]rT)rYr _fmt_kwargsr-rrsrv_msgsrs rrbzLifetimeTimeout._fmt_kwargss<"6(#34w"9%dii.A#  r rGrHrIrJr1rLrKrrbrNrOs@rr[r[s4* ,C 4s3Bx ?Ch'K*  rr[c<eZdZdZdZdhZfdZfdZdZxZ S)NoAnswerzt||djS)Nr7)query)rrbquestion)rrrs rrbzNoAnswer._fmt_kwargss!w" );)D)D"EErc |jdS)Nr7rCrDs rr7zNoAnswer.responses{{:&&r) rGrHrIrJrLrKrrbr7rNrOs@rrgrgs"F PC,K*F'rrgcHeZdZdZdZdeddzZddhZfdZfd ZxZ S) NoNameserverszAll nameservers failed to answer the query. errors: list of servers and respective errors The type of errors is [(server IP address, any object convertible to string)]. Non-empty errors list will add explanatory message () z+All nameservers failed to answer the query.z%s {query}: {errors}Nr\requestrTc$t||i|yrrrs rrzNoNameservers.__init__rrc zt|d}t| |djdj |S)NrTror`)rjrT)rYrrbrkr-rcs rrbzNoNameservers._fmt_kwargssB"6(#34w"#,,TYYx5H#  rrerOs@rrnrns8 8C 3s8 +Ch'K*  rrnceZdZdZy) NotAbsolutezEAn absolute domain name is required but a relative name was provided.NrRrSrrrsrsOrrsceZdZdZy) NoRootSOAzBThere is no SOA RR at the DNS root name. This should never happen!NrRrSrrrvrvsLrrvceZdZdZy) NoMetaqueriesz DNS metaqueries are not allowed.NrRrSrrrxrxs*rrxceZdZdZy)NoResolverConfigurationzEResolver configuration could not be read or specified no nameservers.NrRrSrrrzrzrtrrzc eZdZdZ ddej j dejjdejjdejjde ede ed dfd Zd Zd efd Zd ZdZdZy)Answera&DNS stub resolver answer. Instances of this class bundle up the result of a successful DNS resolution. For convenience, the answer object implements much of the sequence protocol, forwarding to its ``rrset`` attribute. E.g. ``for a in answer`` is equivalent to ``for a in answer.rrset``. ``answer[i]`` is equivalent to ``answer.rrset[i]``, and ``answer[i:j]`` is equivalent to ``answer.rrset[i:j]``. Note that CNAMEs or DNAMEs in the response may mean that answer RRset's name might not be the query name. Nr6rdtyperdclassr7 nameserverportr)cN||_||_||_||_||_||_|j |_|jj|_|jj|_ tj|jjz|_ yr)r6r}r~r7rrresolve_chainingchaining_resultr4answerrrsettime minimum_ttl expiration)rr6r}r~r7rrs rrzAnswer.__init__s     $ '88:#22AA))00 ))+(<(<(H(HHrc&|dk(r|jjS|dk(r|jjS|dk(r|jjS|dk(r|jjS|dk(r|jj St |)Nnamettlcoversr~r})rrrrr~r}r%)rattrs r __getattr__zAnswer.__getattr__s 6>::?? " U]::>> ! X ::$$ $ Y ::%% % X ::$$ $ & &rcP|jxrt|jxsdSNr)rr&rDs r__len__zAnswer.__len__)szz-c$**o22rcr|jxrt|jxsttSr)riterr#rDs r__iter__zAnswer.__iter__,s%zz.d4::.?$uw-?rcD|jt|j|Srr IndexErrorris r __getitem__zAnswer.__getitem__/s ::  zz!}rcB|jt|j|=yrrrs r __delitem__zAnswer.__delitem__4s ::   JJqMrNN)rGrHrIrJdnsrName rdatatype RdataType rdataclass RdataClassmessage QueryMessagerr/intrrrrrrrSrrr|r|s *%)"Ixx}}I ''I** I ++** I SM IsmI I, '33@ rr|ceZdZdZy)Answersz5A dict of DNS stub resolver answers, indexed by type.NrRrSrrrr:s?rrc eZdZdZe d deedeededdfdZe jfde de e ee ffd Ze jfde de efd Zdej$j&fd Zy) HostAnswerszTA dict of DNS stub resolver answers to a host name lookup, indexed by type. Nv6v4 add_emptyr)ct}|+|s |jr||tjj<|+|s |jr||tjj <|Sr)rrrrAAAAA)clsrrranswerss rmakezHostAnswers.makeCsP- >yBHH*,GCMM&& ' >yBHH')GCMMOO $rfamilyc#K|tjk(rO|jtjEd{|jtjEd{y|tjk(r*|j t jj}nK|tjk(r*|j t jj}ntd||r|D]}|j|fyy77w)Nunknown address family ) socket AF_UNSPECaddresses_and_familiesAF_INET6AF_INETr:rrrrNotImplementedErroraddress)rrrrdatas rrz"HostAnswers.addresses_and_familiesSs V%% %226??C C C226>>B B B  v &XXcmm001F v~~ %XXcmmoo.F%(?x&HI I }}f--   D Bs"6D D&D D  B)D  D c2d|j|DS)Nc3&K|] }|d yw)rNrS).0pairs r z(HostAnswers.addresses..gsHDQHs)r)rrs r addresseszHostAnswers.addressesfsHD$?$?$GHHrc|jtjj|jtjj}|j Sr)r:rrrrr4)rrs rr4zHostAnswers.canonical_namejs9#--,,dhhs}}.GH$$$r)NNT)rGrHrIrJ classmethodrr|boolrrrrrr r/rrrrrr4rSrrrr>s $#  V   V       #,,.. %S/ ".&'-&6&6II8C=I% %rrc6eZdZdZd dededdfdZd dZd dZy) CacheStatisticszCache Statisticshitsmissesr)Nc ||_||_yrrr)rrrs rrzCacheStatistics.__init__rs  rc d|_d|_yrrrDs rresetzCacheStatistics.resetvs  rcBt|j|jSr)rrrrDs rclonezCacheStatistics.clonezstyy$++66r)rrr)N)r)r)rGrHrIrJrrrrrSrrrros)Sc$7rrc@eZdZddZddZdefdZdefdZdefdZ y) CacheBaser)NcTtj|_t|_yr) threadingLocklockr statisticsrDs rrzCacheBase.__init__sNN$ )+rcz|j5|jjdddy#1swYyxYw)zReset all statistics to zero.N)rrrrDs rreset_statisticszCacheBase.reset_statisticss. YY $ OO ! ! # $ $ $s1:cr|j5|jjcdddS#1swYyxYw)z How many hits has the cache had?N)rrrrDs rrzCacheBase.hitss+ YY (??'' ( ( (-6cr|j5|jjcdddS#1swYyxYw)z"How many misses has the cache had?N)rrrrDs rrzCacheBase.missess+ YY *??)) * * *rcz|j5|jjcdddS#1swYyxYw)zReturn a consistent snapshot of all the statistics. If running with multiple threads, it's better to take a snapshot than to call statistics methods such as hits() and misses() individually. N)rrrrDs rget_statistics_snapshotz!CacheBase.get_statistics_snapshots0YY +??((* + + +s1:r) rGrHrIrrrrrrrrSrrrr~s0,$ (c( ** ++rrcxeZdZdZd deddffd Zd dZdedee fdZ ded e ddfd Z ddeeddfd Z xZ S)Cachez$Simple thread-safe DNS answer cache.cleaning_intervalr)Nct|i|_||_t j|jz|_y)zf*cleaning_interval*, a ``float`` is the number of seconds between periodic cleanings. N)rrdatarr next_cleaning)rrrs rrzCache.__init__s8 ,. !2$(IIK$2H2H$HrcNtj}|j|krg}|jjD]&\}}|j|ks|j |(|D]}|j|=tj}||j z|_yy)z&Clean the cache if it's time to do so.N)rrritemsrr;r)rnowkeys_to_deletekvs r _maybe_cleanzCache._maybe_cleansiik    $N )1<<3&"))!,*$IIaL$))+C!$t'='=!=D  %rkeycv|j5|j|jj|}|!|jt j kr)|j xjdz c_ dddy|j xjdz c_|cdddS#1swYyxYwaKGet the answer associated with *key*. Returns None if no answer is cached for the key. *key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)`` tuple whose values are the query name, rdtype, and rdclass respectively. Returns a ``dns.resolver.Answer`` or ``None``. Nr+) rrrr:rrrrr)rrrs rr:z Cache.getsYY      c"AyALLDIIK7&&!+&    OO A %    sA/B/ B//B8valuec|j5|j||j|<dddy#1swYyxYwaAssociate key and value in the cache. *key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)`` tuple whose values are the query name, rdtype, and rdclass respectively. *value*, a ``dns.resolver.Answer``, the answer. N)rrrrrrs rputz Cache.puts9YY #    "DIIcN # # #s 6?c|j5|||jvr;|j|=n-i|_tj|jz|_dddy#1swYyxYwa2Flush the cache. If *key* is not ``None``, only that item is flushed. Otherwise the entire cache is flushed. *key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)`` tuple whose values are the query name, rdtype, and rdclass respectively. N)rrrrr)rrs rflushz Cache.flushs`YY J$))# # %)YY[43I3I%I"  J J Js A A""A+)gr@rr)rGrHrIrJfloatrrCacheKeyrr|r:rrrNrOs@rrrsn.I%IDI >xHV$4( #x # #4 #J(+JtJrrc&eZdZdZdZddZddZy) LRUCacheNodezLRUCache node.cJ||_||_d|_||_||_yr)rrrprevnextrs rrzLRUCacheNode.__init__s%    rNcd||_|j|_||j_||_yrrr)rnodes r link_afterzLRUCacheNode.link_afters& II   rcp|j|j_|j|j_yrrrDs runlinkzLRUCacheNode.unlinks   r)rrr)Nr)rGrHrIrJrrrrSrrrrs #rrceZdZdZd deddffd ZdeddfdZdedee fdZ dedefd Z ded e ddfd Z ddeeddfd Z xZS)LRUCachea`Thread-safe, bounded, least-recently-used DNS answer cache. This cache is better than the simple cache (above) if you're running a web crawler or other process that does a lot of resolutions. The LRUCache has a maximum number of nodes, and when it is full, the least-recently used node is removed to make space for a new one. max_sizer)Nct|i|_|j|t dd|_|j |j _|j |j _y)zl*max_size*, an ``int``, is the maximum number of nodes to cache; it must be greater than 0. N)rrr set_max_sizersentinelrr)rrrs rrzLRUCache.__init__sS 24  (#&24&> !]] !]] rc |dkrd}||_y)Nr+)r)rrs rr zLRUCache.set_max_sizes a<H  rrc~|j5|jj|}|)|jxjdz c_ dddy|j |j jtjkr@|j|j=|jxjdz c_ dddy|j|j|jxjdz c_ |xjdz c_ |j cdddS#1swYyxYwr) rrr:rrrrrrrrr rrrrs rr:z LRUCache.getsYY 99==%D|&&!+&    KKMzz$$ 3IIdhh'&&!+&   OODMM * OO A % IINI::   s>D3A2D3AD33D<c|j5|jj|}|+|jjt j kr dddy|j cdddS#1swYyxYw)zBReturn the number of cache hits associated with the specified key.Nr)rrr:rrrrrs rget_hits_for_keyzLRUCache.get_hits_for_key;sb YY !99==%D|tzz44 C ! ! yy  ! ! !sA A5 A55A>rc>|j5|jj|}|'|j|j|j=t |j|j k\r`|jj}|j|j|j=t |j|j k\r`t||}|j|j||j|<dddy#1swYyxYwr) rrr:rrr&rr rrr)rrrrgnodes rrz LRUCache.putDsYY "99==%D IIdhh'dii.DMM1 ** IIeii(dii.DMM1 U+D OODMM *!DIIcN " " "sCD6DDc|j5|E|jj|}||j|j|j=nZ|j j }||j k7r.|j }|j|}||j k7r.i|_dddy#1swYyxYwr)rrr:rrr r)rrrrrs rrzLRUCache.flushZsYY yy}}S)#KKM $((+ **t}}, ::DLLN Et}},    sBB8(B88C)ir)rGrHrIrJrrr rrr|r:rrrrNrOs@rrrs + +$ +!S!T! xHV$48!H!!"x""4",(+trrceZdZdZdddeej jefdeejjefdeejjefde de d ee d d fd Zd eeej"j$eeffd Zd eej*j,e effdZdeej"j2deed eeee ffdZy ) _ResolutionaHelper class for dns.resolver.Resolver.resolve(). All of the "business logic" of resolution is encapsulated in this class, allowing us to have multiple resolve() implementations using different I/O schemes without copying all of the complicated logic. This class is a "friend" to dns.resolver.Resolver and manipulates resolver data structures directly. resolver BaseResolverr6r}r~tcpraise_on_no_answersearchr)Nct|tr tjj |d}tj j j|}tj j|rttjjj|}tjj|rt||_ |j|||_|jdd|_||_||_||_||_i|_tjj,|_g|_g|_g|_d|_d|_d|_d|_d|_y)NF) r!r/rr from_textrrr is_metatyperxrr is_metaclassr_get_qnames_to_try qnames_to_tryrr}r~rrnxdomain_responsesemptyr6 nameserverscurrent_nameserversrTr tcp_attemptretry_with_tcprobackoff)rrr6r}r~rrrs rrz_Resolution.__init__s& eS !HH&&ud3E((--f5 == $ $V , ..++009 >> & &w /   %88G((+   "4QSXX^^ <>DF (* ?C #;?  rcXt|jdkDrq|jjd|_|jj r*|jj j |j|j|jf}|2|j"|jrt|jd|fS|jj j |jtjj|jf}|Z|jj!tj j"k(r%|j|j$|j<ztj&j)|j|j|j}|jj*P|j-|jj.|jj*|jj0|j3|jj4|jj6|jj8|jj:|jj<|jj<|_|jj?|jj@|jjB|jjD|_#|jjHrtKjL|jF|jFdd|_'g|_(d|_)d|_*d|_+||_,d|_-|dfSt#|j\|j$) zGet the next request to send, and check the cache. Returns a (request, answer) tuple. At most one of request or answer will not be None. rNr7) algorithm)optionsFg?r )/r&rpopr6rcacher:r}r~rrrgr7rrANYrcoderr"r make_querykeynameuse_tsigkeyring keyalgorithmuse_ednsedns ednsflagspayload ednsoptionsflags_enrich_nameservers _nameserversnameserver_portsrr$rotaterandomshuffler%rTrr&r'ror(r!)rrros r next_requestz_Resolution.next_requests$++"+DJ}}"",,00ZZdll;%||+0G0G&@@ $f~-,,00ZZ!2!2DLLA%&//*?*?*ASYYEWEW*W;A//D++DJJ7kk,,TZZdllSG}}$$0  MM))MM))"mm88!    "" '' %% 11   }}"". $ 3 3 #}}@@ ** .. "" D  }}##t//0'+'7'7':D $DK"DO$D "'D "DLDLT? "d00DrtA|jB|dfS|tj&jDk(r t+|j,tjFjHtjJjL|}||jN|j,<|j6j8rU|j6j8j;|j,tjFjH|j0f|y|tj&jPk(ratQ}|jjt|j|j|jj ||f||tj&jRk7s|j6jTs%|jj|j|jjt|j|j|jj tj&jW||fy#t4$r}|jjt|j|j|jj ||f|jj|jYd}~yd}~wwxYw#t4$r}|jjt|j|j|jj ||f|jj|jYd}~yd}~wwxYw)NT)NFr*)NT),rrTr;r/r& answer_portr!r exception FormErrorEOFErrorOSErrorrr$remover Truncatedr'rr0NOERRORr|r6r}r~answer_nameserverr5rr.rrrrgr7rrr/rINr"rQSERVFAILretry_servfailto_text)rr7rHr0reyexs r query_resultz_Resolution.query_resultsg *** # ## KK  ($$OO//1  2s}}667b(+b'*b"56  ''8! B 5 56##$$++DOO<!+/D' ###(CKK$<$<===  CII%% % %JJKKLLOO557OO//1 *}}"" ##''T[[$,,(OQWX||#(?(?88D> ! cii(( ( %JJ 1 13>>3D3Dh 3;D # #DJJ /}}"" ##''ZZ!2!2DLLA6  cii(( (*C KK  ($$OO//1  I  ***$--2N2N  ''8 KK  ($$OO//1II%%e,  !U % ""DOO,((335   ''8$ %2 % ""DOO,((335   ''8$ %s4AR<&AU < U A:UU  WA:WW)rGrHrIrJr rrrr/rrrrrrrr rrr|rBr NameserverrrGMessager5rYrSrrrrss/ # #SXX]]C'(#cmm--s23 # s~~00#56 #  #!## #JIU x 0018F3CC DIUV<s~~'@'@$'M!N<*z! !4!45z!;CI;Nz! x% &z!rrc eZdZUdZej j ed<ee e fed<e ed<e ej j ed<e ed<e ed<e ed<eeed <eeej j e fed <eej j e fed <e ed <e ed <ee ej"j$ed<e ed<eed<ee ed<e ed<e ed<ee ed<eee ej(j*fed< d/de de ddfdZd0dZdeddfdZd0dZ d1de dee d ee ede fd!Zd"ej j dee de ej j fd#Zdej:j<fd ed eeej j e fd$eej j e fddfd%Zd&d&ej@jBdfd eee e fd e de d'ee ej"j$ddf d(Z"de ddfd)Z#e$d*eee ej(j*fdee e fd+e de ej(j*fd,Z%e&deee ej(j*ffd-Z'e'jPd*eee ej(j*fddfd.Z'y)2rrdomainr>rruse_search_by_defaultr]lifetimer4r2r5r7r8r:r9r.r;rUr?ndotsr=filename configurer)Nc|j|r9tjdk(r|jy|r|j |yyy)a*filename*, a ``str`` or file object, specifying a file in standard /etc/resolv.conf format. This parameter is meaningful only when *configure* is true and the platform is POSIX. *configure*, a ``bool``. If True (the default), the resolver instance is configured in the normal fashion for the operating system the resolver is running on. (I.e. by reading a /etc/resolv.conf file on POSIX systems and from the registry on Windows systems.) r N)rsysplatform read_registryread_resolv_conf)rrarbs rrzBaseResolver.__init__sC ||w&""$%%h/ rcXtjjtjjt j dd|_t|j dk(rtjj|_g|_ i|_ d|_ g|_ d|_ d|_d|_d|_d|_tj$j&|_d|_d|_d|_d|_d|_d|_d|_d|_d|_y) z1Reset all resolver configuration to the defaults.r+Nr5Fg@@r\)rrrrr gethostnamer]r&rootr=r>rrr^r]r_r4r2tsigdefault_algorithmr5r7r8r:r9r.r;rUr?r`rDs rrzBaseResolver.resetshhmmCHH$6$6v7I7I7K$LQR$PQ t{{ q ((--DK "  %*"    HH66    #  rfcLg}t|tr t|}nt j |}|5}|D]m}t|dk(s|ddk(s|ddk(r#|j}t|dkrB|ddk(r|j|d_|ddk(r/tjj|d|_ g|_|dd k(rJg|_|dd D]:}|jjtjj|<|dd k(s|dd D]u}|d k(rd |_|dk(r|j!&d|vr$ t#|jdd|_Nd|vsS t#|jdd|_wp d d d t|dk(r t d||_y #t$rt d|wxYw#t&t(f$rYwxYw#t&t(f$rYwxYw#1swYoxYw)aProcess *f* as a file in the /etc/resolv.conf format. If f is a ``str``, it is used as the name of the file to open; otherwise it is treated as the file itself. Interprets the following items: - nameserver - name server IP address - domain - local domain name - search - search list for host-name lookup - options - supported options are rotate, timeout, edns0, and ndots z cannot open r#;rDrr+r]rNr,r?Tedns0r]:r`zno nameservers)r!r/openrNrz contextlib nullcontextr&splitr;rrrr]rr?r6rr] ValueErrorrr`r$)rror$cmltokenssuffixopts rrgzBaseResolver.read_resolv_confs+" a  B8!3D/E %^%-031B-C  */& %N { q )*:; ;'a B- QC.@AA BJ%/ #;% $% %/ #;% $%K& %& %se GC3H+/H"G0=H"H&HG-0H ?HH HH HH HH#c tjj}|j|j|_|j|_|j |_y#t $rtwxYw)z9Extract resolver configuration from the Windows registry.N)r win32util get_dns_infor]r$rr%r)rinfos rrfzBaseResolver.read_registrys\ &==--/D{{&"kk #//D ++DK &% % &s AA A0startrTc| |jn|}tj}||z }|g}|dkr|dkr t||d}||k\r t||t||z |jS)Nrr\ra)r_rr[rFr])rrr_rTrdurations r_compute_timeoutzBaseResolver._compute_timeouts %-$44==(iik; >F a<"}%hvFF  x !(6B B8h& 55rr6c| |j}g}|jr|j||S|jtj j }|rt|jdkDr|jdd}nC|jtj j k7r|j|jg}ng}|jd}n |j}|D]}|j||zt||kDr|jd||S|j||S|j||S)Nrr+) r^ is_absoluter; concatenaterrrlr&rr]r`insert)rr6rr! abs_qname search_listr`r}s rr zBaseResolver._get_qnames_to_try6s- >//F       '<9))#((--8It{{#a'"&++a.K[[CHHMM1dkk6M$(;;-K"$K::%E JJE)F!((8*u:%"((I6"((3$$Y/rr+c.||_||_||_y)zAdd a TSIG signature to each query. The parameters are passed to ``dns.message.Message.use_tsig()``; see its documentation for details. N)r4r2r5)rr4r2r+s rr3zBaseResolver.use_tsig_s  %rrr,cZ||durd}n|durd}||_||_||_||_y)aConfigure EDNS behavior. *edns*, an ``int``, is the EDNS level to use. Specifying ``None``, ``False``, or ``-1`` means "do not use EDNS", and in this case the other parameters are ignored. Specifying ``True`` is equivalent to specifying 0, i.e. "use EDNS0". *ednsflags*, an ``int``, the EDNS flag values. *payload*, an ``int``, is the EDNS sender's payload field, which is the maximum size of UDP datagram the sender can handle. I.e. how big a response to this message can be. *options*, a list of ``dns.edns.Option`` objects or ``None``, the EDNS options. NFr\Tr)r7r8r9r:)rr7r8r9r,s rr6zBaseResolver.use_ednsos=0 <45=D T\D " "rc||_y)zkOverrides the default flags with your own. *flags*, an ``int``, the message flags to use. N)r;)rr;s r set_flagszBaseResolver.set_flagss  rr$ default_portcHg}t|tr|D]}t|tjjr|}ntj j |r3|j||}tjj||}n? t|jdk7rt tjj|}|j||Stdj!t#|#t$rtd|dwxYw)Nhttpsz nameserver z\ is not a dns.nameserver.Nameserver instance or text form, IP address, nor a valid https URLz.nameservers must be a list or tuple (not a {}))r!r"rrrZinet is_addressr:Do53Nameserverr schemerr5ry DoHNameserverr;r0type)rr$r>renriched_nameserversrenriched_nameserverrs rr<z BaseResolver._enrich_nameserverss " k4 () j#..*C*CD*4'XX((4+// LID*-..*G*G"D+'#J/66'A"55B+...*F*Fz*R'$++,?@)*6$# @GG% %()*6@@s DD!c|jSr)r=rDs rr$zBaseResolver.nameserverss   rc`|j||j|j||_y)a  *nameservers*, a ``list`` of nameservers, where a nameserver is either a string interpretable as a nameserver, or a ``dns.nameserver.Nameserver`` instance. Raises ``ValueError`` if *nameservers* is not a list of nameservers. N)r<r>rr=)rr$s rr$zBaseResolver.nameserverss(   d.C.CTYYO'r)z/etc/resolv.confTrr))rGrHrIrJrrr__annotations__rr/rrrrrrr r7Optionr rrZrrrgrf ErrorTuplerr rmrnr3rDEFAULT_EDNS_PAYLOADr6rrr<rMr$setterrSrrrrs{ HHMM38n$ I   NO c] eCHHMM3./ 00 s*++ IN$sxx/00 L J C= L C=5cnn&?&?!?@AAEI00=A0 0*4E'#E'$E'N &%)-1 665/6j)* 6  60'XX]]',4TN' chhmm 'X8t ttJtS)z7Get the default resolver, initializing it if necessary.)rreset_default_resolverrSrrget_default_resolverrs   '' ' rctay)zRe-initialize default resolver. Note that the resolver configuration (i.e. /etc/resolv.conf on UNIX systems) will be re-read immediately. N)rrrSrrrrs  zrFTr6r}r~rrrrr_rc Dtj||||||||| S)zQuery nameservers to find the answer to the question. This is a convenience function that uses the default resolver object to make the query. See ``dns.resolver.Resolver.resolve`` for more information on the parameters. )rr) r6r}r~rrrrr_rs rrr s5( ! ) )    rc `tjdtdt||||||||d S)aQuery nameservers to find the answer to the question. This method calls resolve() with ``search=True``, and is provided for backwards compatibility with prior versions of dnspython. See the documentation for the resolve() method for further details. z)please use dns.resolver.resolve() insteadrDrTr)r6r}r~rrrrr_s rrjrj*sC" MM35GTU      rrrrc>tj|g|i|S)zUse a resolver to run a reverse query for PTR records. See ``dns.resolver.Resolver.resolve_address`` for more information on the parameters. )rr)rrrs rrrKs% 2  ! 1 1& J4 J6 JJrrrc :tj||fi|S)zUse a resolver to query for address records. See ``dns.resolver.Resolver.resolve_name`` for more information on the parameters. )rr)rrrs rrrUs" /  ! . .tV Fv FFrc4tj|S)zDetermine the canonical name of *name*. See ``dns.resolver.Resolver.canonical_name`` for more information on the parameters and possible exceptions. )rr4rs rr4r4as ! 0 0 66rc4tj|S)aTry to update the default resolver's nameservers using Discovery of Designated Resolvers (DDR). If successful, the resolver will subsequently use DNS-over-HTTPS or DNS-over-TLS for future queries. See :py:func:`dns.resolver.Resolver.try_ddr` for more information. )rrrs rrrks ! ) )( 33rrct|tr8tjj |tjj }| t }|js t|tj}|||z}nd} ||tjz }|dkrd}nd}|j|tjj|||}|jJ|jj|k(r|S |j3}#tjjtjj f$r} t| tjjr | j#j%|} n| j'} | r| j(D]} | j*tjjk(s+| j,|k(s;| jj/|\} } } | tjj0k(sx| jccYd} ~ SYd} ~ =d} ~ wwxYw#tjj4$rt6wxYw)aFind the name of the zone which contains the specified name. *name*, an absolute ``dns.name.Name`` or ``str``, the query name. *rdclass*, an ``int``, the query class. *tcp*, a ``bool``. If ``True``, use TCP to make the query. *resolver*, a ``dns.resolver.Resolver`` or ``None``, the resolver to use. If ``None``, the default, then the default resolver is used. *lifetime*, a ``float``, the total time to allow for the queries needed to determine the zone. If ``None``, the default, then only the individual query limits of the resolver apply. Raises ``dns.resolver.NoRootSOA`` if there is no SOA RR at the DNS root. (This is only likely to happen if you're using non-default root servers in your network and they are misconfigured.) Raises ``dns.resolver.LifetimeTimeout`` if the answer could not be found in the allotted lifetime. Returns a ``dns.name.Name``. Nrr)r!r/rrrrlrrrsrrrSOArrrrgrr:r7 authorityr}r~ fullcompareNAMERELN_SUPERDOMAINparentNoParentrv)rr~rrr_rr rlifetimerrWr7rrsnrrs r zone_for_namerus@$xx!!$ 6')    $ IIKEX%   ,%&4 > !I %%cmm''# &F<<+ ++||  D( ), ;;=DI  %%s||'<'<= ,!S\\223;;=,,T2::<#--CzzS]]%6%663;;';Q%(XX%9%9$%? Q!>!>>$'88O.  ,*xx   O sDA9D I7I B I!I1>88EF,,UF;EEGG   s~~<E99BG?>G?cr|tj} t|\}}}|S#t$rY|SwxYwr)rrk_gethostbyaddrr5)rrs r_getfqdnrsJ |!!# %d+ q! K   K s ) 66c$t|ddS)NrDr)_gethostbyname_exrs r_gethostbynamers T "1 %a ((rcg}g}t|dtjtjtjtj }|dd}|D]}|j |dd|||fS)NrrVr)rrrrrrr;)raliasesrr canonicalitems rrrsuGI  a!3!3V^^VEXEXFq ! Ia$ w **rc tjj||dddf}tj}t|tj\}}g}g}t|d|tjtjtj}|dd}tj j#||} |D]A} | dd} tj j#|| } | | k(s1|j%| C|||fS#t $rj tj j|n1#t $r%tjtjdwxYw|df}tj}Y@wxYw)NPrrrVr)ripv6 inet_atonrrr5ipv4rrrrr rrrrr inet_ptonr;) iprrrrrrrrbin_iprrbin_addrs rrrsU   2Aq>Xv'9'9:IT1GI  a++V^^V=P=PFq ! IXX   +FAwqz88%%fd3 X    T "  w **1   R HH  r " R//&"3"35PQ Q R8  s)5D E8D/.E8/.EE87E8c| t}|att_t t_tt_tt_ tt_ tt_y)aOverride the system resolver routines in the socket module with versions which use dnspython's resolver. This can be useful in testing situations where you want to control the resolution behavior of python code without having to change the system's resolver settings (e.g. /etc/resolv.conf). The resolver to use may be specified; if it's not, the default resolver will be used. resolver, a ``dns.resolver.Resolver`` or ``None``, the resolver to use. N)rrrr getaddrinfor getnameinforgetfqdnr gethostbynamergethostbyname_exr gethostbyaddr)rs roverride_system_resolverr/sF')I%F%FFN)F/F)Frcdatt_tt_t t_tt_ tt_ tt_ y)z5Undo the effects of prior override_system_resolver().N)rrrr)_original_getnameinfor*_original_getfqdnr+_original_gethostbynamer,_original_gethostbyname_exr-_original_gethostbyaddrr.rSrrrestore_system_resolverr6s8I.F.F&FN2F8F2Frrr)rr)yrJrvr@rrdrrrtypingrrrrrr r r urllib.parser dns._ddrrdns.edns dns.exception dns.flagsdns.inetdns.ipv4dns.ipv6 dns.messagedns.namedns.nameserver dns.query dns.rcodedns.rdataclass dns.rdatatypedns.rdtypes.svcbbasedns.reversenamedns.tsigre dns.win32utilrK DNSExceptionrrQr/rrr5rr[rrYTimeoutr[rgrnrsrvrxrzr|r'rrrrrrrrrrrrrrrrrrrrrrrSrrrjrrrr4rrrrrSOL_UDPrrrrr)rr*r1r+r2r,r3r-r4r.r5rrrrrrr/r6rSrrrNs$  NNN!<<7U/s}}))U/pCs}}))C SM )S. S[[ ! # D,c cmm++ , 's}}))'$ CMM.. 2P#--,,PM **M+CMM..+Pcmm88PBBJ@d@.%'.%b 7 7++>  7 79R9RR SLJILJ^##*lyl^K!K!\P(P(f [|[~(,(8$+h"36--//58^^5F5F # $! # $ #--))3. /3>>,,c1 2   SM   uo TN F36--//58^^5F5F # $ # $ #--))3. /3>>,,c1 2   SM   uo BKCKKsKvK4:3C3C G  s" # G-0 GOR G G7sxx}}c127sxx}}74e4d4*-):):#' $ R  s" #R ^^ & &R Rx R uo R  XX]] Rn""#' ! # $! ! !x !  !N36--//58^^5F5F # $!""#'& # $& # $& #--))3. /&3>>,,c1 2 &  & SM &&&uo& TN& & &x & &^ ' (  ****NN ..#44 .. tF$4$4qQRQh$N ) ++@*x'9*T*4 3r