Ë
    ojÇ  ã                   óŽ   — d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ d„ Zd	„ Z G d
„ dej"                  «      Zy)z
hosts(5) support.
é    )Údefer)ÚisIPAddressÚisIPv6Address)ÚcommonÚdns)Úfailure)ÚnativeString)ÚFilePathc                 óî  — g }	 | j                  «       j                  «       }|j                  «       }|D ]™  }|j	                  d«      }|dk7  r|d| }|sŒ!|j                  «       }|j                  «       |dd D �cg c]  }|j                  «       ‘Œ c}v sŒc	 t        |d   «      }t        |«      st        |«      sŒ‰|j                  |«       Œ› |S # t        $ r |cY S w xY wc c}w # t        $ r Y Œ¿w xY w)a±  
    Search the given file, which is in hosts(5) standard format, for addresses
    associated with a given name.

    @param hostsFile: The name of the hosts(5)-format file to search.
    @type hostsFile: L{FilePath}

    @param name: The name to search for.
    @type name: C{bytes}

    @return: L{None} if the name is not found in the file, otherwise a
        C{str} giving the address in the file associated with the name.
    ó   #éÿÿÿÿNé   r   )Ú
getContentÚ
splitlinesÚBaseExceptionÚlowerÚfindÚsplitr	   Ú
ValueErrorr   r   Úappend)	Ú	hostsFileÚnameÚresultsÚlinesÚlineÚidxÚpartsÚsÚmaybeIPs	            ú5/usr/lib/python3/dist-packages/twisted/names/hosts.pyÚsearchFileForAllr!      sû   € ð €GðØ×$Ñ$Ó&×1Ñ1Ó3ˆð �:‰:‹<€DØò (ˆØ�i‰i˜‹oˆØ�"Š9Ø˜˜�:ˆDÙØØ—
‘
“ˆà�:‰:‹<¨u°Q°R¨yÖ9¨!˜AŸG™G�IÒ9Ò9ðÜ& u¨Q¡xÓ0�ô ˜7Ô#¤}°WÕ'=Ø—‘˜wÕ'ð(ð €Nøô' ò ØŠðüò :øô ò Ùðús)   „C Á;C#ÂC(ÃC ÃC Ã(	C4Ã3C4c                 ó<   — t        t        | «      |«      }|r|d   S y)a²  
    Grep given file, which is in hosts(5) standard format, for an address
    entry with a given name.

    @param file: The name of the hosts(5)-format file to search.
    @type file: C{str} or C{bytes}

    @param name: The name to search for.
    @type name: C{bytes}

    @return: L{None} if the name is not found in the file, otherwise a
        C{str} giving the first address in the file associated with
        the name.
    r   N)r!   r
   )Úfiler   Ú	addressess      r    ÚsearchFileForr%   9   s$   € ô !¤¨$£°Ó6€IÙØ˜‰|ÐØó    c                   ó>   — e Zd ZdZd	d„Zd„ Zd„ Zd„ Zd
d„Zd
d„Z	eZ
y)ÚResolverz9
    A resolver that services hosts(5) format files.
    c                 ó^   — t         j                  j                  | «       || _        || _        y ©N)r   ÚResolverBaseÚ__init__r#   Úttl)Úselfr#   r-   s      r    r,   zResolver.__init__S   s$   € Ü×Ñ×$Ñ$ TÔ*ØˆŒ	Øˆ�r&   c                 ój   ‡ ‡— t        ˆˆ fd„t        t        ‰ j                  «      ‰«      D «       «      S )zv
        Return a tuple of L{dns.RRHeader} instances for all of the IPv4
        addresses in the hosts file.
        c              3   óî   •K  — | ]l  }t        |«      r_t        j                  ‰t        j                  t        j                  ‰j
                  t        j                  |‰j
                  «      «      –— Œn y ­wr*   )r   r   ÚRRHeaderÚAÚINr-   ÚRecord_A©Ú.0Úaddrr   r.   s     €€r    ú	<genexpr>z%Resolver._aRecords.<locals>.<genexpr>]   sM   øè ø€ ò 
àÜ˜4Ô ô �L‰L˜œsŸu™u¤c§f¡f¨d¯h©h¼¿¹ÀTÈ4Ï8É8Ó8T×Uñ
ùó   ƒA2A5©Útupler!   r
   r#   ©r.   r   s   ``r    Ú	_aRecordszResolver._aRecordsX   s/   ù€ ô
 ô 
ä(¬°$·)±)Ó)<¸dÓCô
ó 
ð 	
r&   c                 ój   ‡ ‡— t        ˆˆ fd„t        t        ‰ j                  «      ‰«      D «       «      S )zv
        Return a tuple of L{dns.RRHeader} instances for all of the IPv6
        addresses in the hosts file.
        c              3   óî   •K  — | ]l  }t        |«      r_t        j                  ‰t        j                  t        j                  ‰j
                  t        j                  |‰j
                  «      «      –— Œn y ­wr*   )r   r   r1   ÚAAAAr3   r-   ÚRecord_AAAAr5   s     €€r    r8   z(Resolver._aaaaRecords.<locals>.<genexpr>h   sR   øè ø€ ò 
ð Ü˜TÔ"ô	 �L‰LØ”c—h‘h¤§¡¨¯©´#·/±/À$ÈÏÉÓ2Q÷ñ
ùr9   r:   r<   s   ``r    Ú_aaaaRecordszResolver._aaaaRecordsc   s1   ù€ ô
 ô 
ô )¬°$·)±)Ó)<¸dÓCô	
ó 
ð 	
r&   c                 ó¬   — |rt        j                  |ddf«      S t        j                  t        j                  t        j                  |«      «      «      S )aF  
        Generate a response for the given name containing the given result
        records, or a failure if there are no result records.

        @param name: The DNS name the response is for.
        @type name: C{str}

        @param records: A tuple of L{dns.RRHeader} instances giving the results
            that will go into the response.

        @return: A L{Deferred} which will fire with a three-tuple of result
            records, authority records, and additional records, or which will
            fail with L{dns.DomainError} if there are no result records.
        © )r   ÚsucceedÚfailr   ÚFailurer   ÚDomainError)r.   r   Úrecordss      r    Ú_respondzResolver._respondp   s>   € ñ Ü—=‘= '¨2¨rÐ!2Ó3Ð3Ü�z‰zœ'Ÿ/™/¬#¯/©/¸$Ó*?Ó@ÓAÐAr&   Nc                 ón   — t        j                  |«      }| j                  || j                  |«      «      S )zm
        Read any IPv4 addresses from C{self.file} and return them as
        L{Record_A} instances.
        )r   ÚdomainStringrJ   r=   ©r.   r   Útimeouts      r    ÚlookupAddresszResolver.lookupAddressƒ   s.   € ô
 ×Ñ Ó%ˆØ�}‰}˜T 4§>¡>°$Ó#7Ó8Ð8r&   c                 ón   — t        j                  |«      }| j                  || j                  |«      «      S )zp
        Read any IPv6 addresses from C{self.file} and return them as
        L{Record_AAAA} instances.
        )r   rL   rJ   rB   rM   s      r    ÚlookupIPV6AddresszResolver.lookupIPV6Address‹   s0   € ô
 ×Ñ Ó%ˆØ�}‰}˜T 4×#4Ñ#4°TÓ#:Ó;Ð;r&   )s
   /etc/hostsi  r*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r,   r=   rB   rJ   rO   rQ   ÚlookupAllRecordsrD   r&   r    r(   r(   N   s.   „ ñóò
	
ò
òBó&9ó<ð %Ñr&   r(   N)rU   Útwisted.internetr   Útwisted.internet.abstractr   r   Útwisted.namesr   r   Útwisted.pythonr   Útwisted.python.compatr	   Útwisted.python.filepathr
   r!   r%   r+   r(   rD   r&   r    ú<module>r]      s=   ðñ
õ
 #ß @ß %Ý "Ý .Ý ,ò$òNô*I%ˆv×"Ñ"õ I%r&   