+
    üÐjˆ0  ã                   ó˜   € R t ^ RIHt ^ RIHtHtHt ^ RIHt  ! R R4      t	 ! R R]P                  4      tR t ! R	 R
4      tRR ltR# )zÁ
Resolver implementation for querying successive authoritative servers to
lookup a record, starting from the root nameservers.

@author: Jp Calderone

todo::
    robustify it
    documentation
)Údefer)ÚcommonÚdnsÚerror)ÚFailurec                   ó*   a € ] tR t^t o RtR tRtV tR# )Ú_DummyControllerz¢
A do-nothing DNS controller.  This is useful when all messages received
will be responses to previously issued queries.  Anything else received
will be ignored.
c                ó   € R # ©N© )ÚselfÚargss   &*Ú4/usr/lib/python3/dist-packages/twisted/names/root.pyÚmessageReceivedÚ _DummyController.messageReceived   s   € Ùó    r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      s   ø‡ € ñ÷ð r   r   c                   óL   a € ] tR t^ t o RtR
R ltR tR tR tR t	R t
R	tV tR# )ÚResolveraS  
L{Resolver} implements recursive lookup starting from a specified list of
root servers.

@ivar hints: See C{hints} parameter of L{__init__}
@ivar _maximumQueries: See C{maximumQueries} parameter of L{__init__}
@ivar _reactor: See C{reactor} parameter of L{__init__}
@ivar _resolverFactory: See C{resolverFactory} parameter of L{__init__}
Nc                óˆ   € \         P                  P                  V 4       Wn        W n        W0n        Vf   ^ RIHp W@n        R# )a  
@param hints: A L{list} of L{str} giving the dotted quad
    representation of IP addresses of root servers at which to
    begin resolving names.
@type hints: L{list} of L{str}

@param maximumQueries: An optional L{int} giving the maximum
     number of queries which will be attempted to resolve a
     single name.
@type maximumQueries: L{int}

@param reactor: An optional L{IReactorTime} and L{IReactorUDP}
     provider to use to bind UDP ports and manage timeouts.
@type reactor: L{IReactorTime} and L{IReactorUDP} provider

@param resolverFactory: An optional callable which accepts C{reactor}
     and C{servers} arguments and returns an instance that provides a
     C{queryUDP} method. Defaults to L{twisted.names.client.Resolver}.
@type resolverFactory: callable
N©r   )	r   ÚResolverBaseÚ__init__ÚhintsÚ_maximumQueriesÚ_reactorÚtwisted.names.clientr   Ú_resolverFactory)r   r!   ÚmaximumQueriesÚreactorÚresolverFactorys   &&&&&r   r    ÚResolver.__init__+   s7   € ô* 	×Ñ×$Ñ$ TÔ*ØŒ
Ø-ÔØŒØÒ"ÝHØ /Ör   c                ób   € V P                    Uu. uF  q\        P                  3NK  	  up# u upi )zj
Return a list of two-tuples representing the addresses of the root
servers, as defined by C{self.hints}.
)r!   r   ÚPORT)r   Úips   & r   Ú_rootsÚResolver._rootsH   s&   € ð
 *.¯ªÓ4© 2”S—X‘X“©Ñ4Ð4ùÒ4s   �,c                óª   € V P                  W P                  R7      pVP                  V.V4      pV'       d   VP                  VP                  4       V# )a  
Issue one query and return a L{Deferred} which fires with its response.

@param query: The query to issue.
@type query: L{dns.Query}

@param servers: The servers which might have an answer for this
    query.
@type servers: L{list} of L{tuple} of L{str} and L{int}

@param timeout: A timeout on how long to wait for the response.
@type timeout: L{tuple} of L{int}

@param filter: A flag indicating whether to filter the results.  If
    C{True}, the returned L{Deferred} will fire with a three-tuple of
    lists of L{twisted.names.dns.RRHeader} (like the return value of
    the I{lookup*} methods of L{IResolver}.  IF C{False}, the result
    will be a L{Message} instance.
@type filter: L{bool}

@return: A L{Deferred} which fires with the response or a timeout
    error.
@rtype: L{Deferred}
)Úserversr'   )r%   r#   ÚqueryUDPÚaddCallbackÚfilterAnswers)r   Úqueryr0   ÚtimeoutÚfilterÚrÚds   &&&&&  r   Ú_queryÚResolver._queryO   sE   € ð2 ×!Ñ!¨'¿=¹=Ð!ÓIˆØ�J‰J˜�w Ó(ˆßØ�M‰M˜!Ÿ/™/Ô*Øˆr   c                óŽ   € Vf   RpV P                  \        P                  ! WV4      V P                  4       W@P                  4      # )z�
Implement name lookup by recursively discovering the authoritative
server for the name and then asking it, starting at one of the servers
in C{self.hints}.
)é   é   é   é-   )Ú_discoverAuthorityr   ÚQueryr-   r"   )r   ÚnameÚclsÚtyper5   s   &&&&&r   Ú_lookupÚResolver._lookupn   sA   € ð Š?ð %ˆGØ×&Ñ&Ü�IŠI�d #Ó&¨¯©«°w×@TÑ@Tó
ð 	
r   c                óÀ   € V^ 8:  d    \        \        P                  ! R4      4      # V P                  WVR4      pVP	                  V P
                  WV^,
          4       V# )a«  
Issue a query to a server and follow a delegation if necessary.

@param query: The query to issue.
@type query: L{dns.Query}

@param servers: The servers which might have an answer for this
    query.
@type servers: L{list} of L{tuple} of L{str} and L{int}

@param timeout: A C{tuple} of C{int} giving the timeout to use for this
    query.

@param queriesLeft: A C{int} giving the number of queries which may
    yet be attempted to answer this query before the attempt will be
    abandoned.

@return: A L{Deferred} which fires with a three-tuple of lists of
    L{twisted.names.dns.RRHeader} giving the response, or with a
    L{Failure} if there is a timeout or response error.
z"Query limit reached without resultF)r   r   ÚResolverErrorr9   r2   Ú_discoveredAuthority)r   r4   r0   r5   ÚqueriesLeftr8   s   &&&&& r   r@   ÚResolver._discoverAuthority|   sT   € ð. ˜!ÔÜœ5×.Ò.Ð/SÓTÓUÐUà�K‰K˜¨°Ó7ˆØ	�‰�d×/Ñ/°ÀÈqÅÔQØˆr   c                óì  a aaaaa€ VP                   \        P                  8w  d+   \        S P	                  VP                   4      ! V4      4      # / oVP
                   F.  pSP                  VP                  . 4      P                  V4       K0  	  V3R lp\        4       pSP                  pRp	 VP                  V4       V	oV! VSP                  SP                  4      p	V	f�   VSP                  8X  d   MöS P                  \        P                  ! \        V4      SP                  SP                  4      S P!                  4       SS4      p
V3R lpV
P#                  V4       V
# V	P                  SP                  8X  d$   VP
                  VP$                  VP&                  3# V	P(                  P                  V9   d   \*        P,                  ! R4      hV	P(                  P                  pEK>  / pVP&                   FT  pVP                  \        P.                  8X  g   K$  VP(                  P1                  4       WÍP                  P                  &   KV  	  . p. pVP$                   F†  pVP                  \        P2                  8X  g   K$  VP(                  P                  P                  pVV9   d+   VP                  VV,          \        P4                  34       Ku  VP                  V4       Kˆ  	  V'       d   S P                  SVSS4      # V'       dH   S P7                  V^ ,          S4      p
R pV
P#                  V4       V
P#                  VVV V3R l4       V
# \        \*        P,                  ! R4      4      # )aó  
Interpret the response to a query, checking for error codes and
following delegations if necessary.

@param response: The L{Message} received in response to issuing C{query}.
@type response: L{Message}

@param query: The L{dns.Query} which was issued.
@type query: L{dns.Query}.

@param timeout: The timeout to use if another query is indicated by
    this response.
@type timeout: L{tuple} of L{int}

@param queriesLeft: A C{int} giving the number of queries which may
    yet be attempted to answer this query before the attempt will be
    abandoned.

@return: A L{Failure} indicating a response error, a three-tuple of
    lists of L{twisted.names.dns.RRHeader} giving the response to
    C{query} or a L{Deferred} which will fire with one of those.
c                 óÔ   <€ R pSP                  V . 4       FN  pVP                  V8X  g   K  VP                  V8X  d   Vu # VP                  \        P                  8X  g   KL  TpKP  	  V# r
   )ÚgetrC   rD   r   ÚCNAME)rB   rD   rC   ÚcnameÚrecordÚrecordss   &&&  €r   ÚfindAnswerOrCNameÚ8Resolver._discoveredAuthority.<locals>.findAnswerOrCName¹   sV   ø€ ØˆEØ!Ÿ+™+ d¨BÖ/�Ø—:‘: Ö$Ø—{‘{ dÔ*Ø%šØŸ™¬¯	©	Ö1Ø &šñ 0ð ˆLr   Nc                 ó:   <€ V w  rpVP                  ^ S4       WV3# ©é    )Úinsert)ÚresultsÚanswersÚ	authorityÚ
additionalÚpreviouss   &   €r   Ú
cbResolvedÚ1Resolver._discoveredAuthority.<locals>.cbResolvedÜ   s&   ø€ Ø9@Ñ6˜¨JØŸ™ q¨(Ô3Ø '°JÐ?Ð?r   zCycle in CNAME processingc                 óN   € V w  rpV^ ,          P                   P                  4       # rV   )ÚpayloadÚ
dottedQuad)rY   rZ   r[   r\   s   &   r   ÚgetOneAddressÚ4Resolver._discoveredAuthority.<locals>.getOneAddress   s%   € Ø18Ñ.� JØ˜q•z×)Ñ)×4Ñ4Ó6Ð6r   c                 ó\   <€ SP                  SV \        P                  3.SS^,
          4      # )r<   )r@   r   r+   )ÚhintrJ   r4   r   r5   s   &€€€€r   Ú<lambda>Ú/Resolver._discoveredAuthority.<locals>.<lambda>  s)   ø€ ˜T×4Ñ4Ø˜T¤3§8¡8Ð,Ð-¨w¸Àa½ôr   z/Stuck at response without answers or delegation)ÚrCoder   ÚOKr   ÚexceptionForCoderZ   Ú
setdefaultrB   ÚappendÚsetÚaddrD   rC   r@   rA   Ústrr-   r2   r[   r\   ra   r   rH   ÚArb   ÚNSr+   ÚlookupAddress)r   Úresponser4   r5   rJ   ÚanswerrS   ÚseenrB   rQ   r8   r^   Ú	addressesÚrrr!   ÚtrapsÚnsrc   r]   rR   s   f&fff             @@r   rI   ÚResolver._discoveredAuthorityš   sª  ý€ ð. �>‰>œSŸV™VÔ#Ü˜4×0Ñ0°·±Ô@ÀÓJÓKÐKð ˆØ×&Ô&ˆFØ×Ñ˜vŸ{™{¨BÓ/×6Ñ6°vÖ>ñ 'õ
	ô ‹uˆØ�z‰zˆØˆØØ�H‰H�TŒNØˆHÙ& t¨U¯Z©Z¸¿¹ÓCˆFØŠ~Ø˜5Ÿ:™:Ô%ð ð ×/Ñ/ÜŸ	š	¤# d£)¨U¯Z©Z¸¿¹ÓCØŸ™›ØØ#ó	�Aõ@ð
 —M‘M *Ô-Ø�HØ—‘ §
¡
Ô*Ø ×(Ñ(¨(×*<Ñ*<¸h×>QÑ>QÐRÐRð —>‘>×&Ñ&¨$Ô.Ü×-Ò-Ð.IÓJÐJØ—~‘~×*Ñ*“ð ˆ	Ø×%Ô%ˆBØ�w‰wœ#Ÿ%™%ÖØ*,¯*©*×*?Ñ*?Ó*A�	Ÿ'™'Ÿ,™,Ó'ñ &ð ˆØˆØ×$Ô$ˆBØ�w‰wœ#Ÿ&™&Ö Ø—Z‘Z—_‘_×)Ñ)�Ø˜”?Ø—L‘L )¨B¥-´·±Ð!:Ö;à—L‘L Ö$ñ %÷ Ø×*Ñ*¨5°%¸À+ÓNÐNßØ×"Ñ" 5¨¥8¨WÓ5ˆAò7ð �M‰M˜-Ô(Ø�M‰M÷ôð
 ˆHäÜ×#Ò#Ð$UÓVóð r   )r"   r#   r%   r!   )é
   NN)r   r   r   r   r   r    r-   r9   rE   r@   rI   r   r   r   s   @r   r   r       s/   ø‡ € ñô0ò:5òò>
ò÷<tð tr   r   c                 ó   a a€ V V3R  lpV# )c                  ó:   <a a€ SP                  V VV3R  l4       S# )c                 ó(   <€ \        V S4      ! S/ SB # r
   )Úgetattr)r7   r   ÚkwrB   s   &€€€r   rg   Ú6makePlaceholder.<locals>.placeholder.<locals>.<lambda>  s   ø€ ¤w¨q°$Ô'7¸Ð'DÀÒ'Dr   )r2   )r   r�   ÚdeferredrB   s   jl€€r   ÚplaceholderÚ$makePlaceholder.<locals>.placeholder  s   ú€ Ø×ÑÖDÔEØˆr   r   )rƒ   rB   r„   s   ff r   ÚmakePlaceholderr†     s   ù€ öð Ðr   c                   ó2   a € ] tR tRt o R tR tR tRtV tR# )ÚDeferredResolveri  c                óJ   € . V n         VP                  V P                  4       R # r
   )Úwaitingr2   ÚgotRealResolver)r   ÚresolverDeferreds   &&r   r    ÚDeferredResolver.__init__  s   € ØˆŒØ×$Ñ$ T×%9Ñ%9Ö:r   c                ó–   € V P                   pVP                  V n        VP                  V n        V F  pVP                  V4       K  	  R # r
   )rŠ   Ú__dict__Ú	__class__Úcallback)r   ÚresolverÚwr8   s   &&  r   r‹   Ú DeferredResolver.gotRealResolver  s;   € Ø�L‰LˆØ ×)Ñ)ˆŒØ!×+Ñ+ˆŒÛˆAØ�J‰J�xÖ ó r   c                óê   € VP                  R 4      '       g   VR9   dL   V P                  P                  \        P                  ! 4       4       \        V P                  R,          V4      # \        V4      h)Úlookup)ÚgetHostByNamer4   éÿÿÿÿ)Ú
startswithrŠ   rm   r   ÚDeferredr†   ÚAttributeError)r   rB   s   &&r   Ú__getattr__ÚDeferredResolver.__getattr__%  sS   € Ø�?‰?˜8×$Ò$¨Ð0JÔ(JØ�L‰L×Ñ¤§¢Ó 0Ô1Ü" 4§<¡<°Õ#3°TÓ:Ð:Ü˜TÓ"Ð"r   )r�   r�   rŠ   N)	r   r   r   r   r    r‹   rœ   r   r   r   s   @r   rˆ   rˆ     s   ø‡ € ò;ò!÷#ð #r   rˆ   Nc                ó>  a€ \        ^4       Uu. uF  p\        \        R4      V,           4      NK   	  ppV Uu. uF  q@P                  RV,          4      NK  	  pp\        P
                  ! VRR7      pV3R lpVP                  V4       \        V4      # u upi u upi )aÇ  
Lookup the root nameserver addresses using the given resolver

Return a Resolver which will eventually become a C{root.Resolver}
instance that has references to all the root servers that we were able
to look up.

@param resolver: The resolver instance which will be used to
    lookup the root nameserver addresses.
@type resolver: L{twisted.internet.interfaces.IResolverSimple}

@param resolverFactory: An optional callable which returns a
    resolver instance. It will passed as the C{resolverFactory}
    argument to L{Resolver.__init__}.
@type resolverFactory: callable

@return: A L{DeferredResolver} which will be dynamically replaced
    with L{Resolver} when the root nameservers have been looked up.
Úaz%s.root-servers.netT)ÚconsumeErrorsc                 óv   <€ \        V  Uu. uF  q^ ,          '       g   K  V^,          NK  	  upSR7      # u upi )rW   )r!   r(   r   )ÚresÚer(   s   & €r   ÚbuildResolverÚ bootstrap.<locals>.buildResolverD  s5   ø€ ÜÙ!$Ó-¡˜A¨!¯©”4�1�Q—4�4¡Ñ-¸ô
ð 	
ùÚ-s   ‹6 6)ÚrangeÚchrÚordr—   r   ÚDeferredListr2   rˆ   )r’   r(   ÚiÚdomainsr8   ÚLr¤   s   &f     r   Ú	bootstrapr­   ,  s…   ø€ ô( +0°¬)Ó4©) QŒs”3�s“8˜a•<Ö ©)€GÐ4ÙDKÓLÁG¸q×	Ñ	Ð 5¸Õ 9Ö	:ÁG€AÐLÜ×Ò˜1¨DÔ1€Aõ
ð
 ‡M�M�-Ô ä˜AÓÐùò 5ùÚLs
   �$B¹ Br
   )r   Útwisted.internetr   Útwisted.namesr   r   r   Útwisted.python.failurer   r   r   r   r†   rˆ   r­   r   r   r   Ú<module>r±      sK   ðñ
	õ #ß ,Ñ ,Ý *÷ñ ônˆv×"Ñ"ô nòb÷#ñ #ö&r   