§
    ÈtºfÇ  ã                   óŒ   — 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dS )z
hosts(5) support.
é    )Údefer)ÚisIPAddressÚisIPv6Address)ÚcommonÚdns)Úfailure)ÚnativeString)ÚFilePathc                 ó,  — g }	 |                       ¦   «                              ¦   «         }n# t          $ r |cY S w xY w|                     ¦   «         }|D ]À}|                     d¦  «        }|dk    r
|d|…         }|sŒ*|                     ¦   «         }|                     ¦   «         d„ |dd…         D ¦   «         v rZ	 t          |d         ¦  «        }n# t          $ r Y Œ‰w xY wt          |¦  «        st          |¦  «        r| 
                    |¦  «         ŒÁ|S )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.
    ó   #éÿÿÿÿNc                 ó6   — g | ]}|                      ¦   «         ‘ŒS © )Úlower)Ú.0Úss     úR/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/names/hosts.pyú
<listcomp>z$searchFileForAll.<locals>.<listcomp>/   s    € Ð9Ð9Ð9¨!˜AŸGšG™IœIÐ9Ð9Ð9ó    é   r   )Ú
getContentÚ
splitlinesÚBaseExceptionr   ÚfindÚsplitr	   Ú
ValueErrorr   r   Úappend)Ú	hostsFileÚnameÚresultsÚlinesÚlineÚidxÚpartsÚmaybeIPs           r   ÚsearchFileForAllr&      sE  € ð €GðØ×$Ò$Ñ&Ô&×1Ò1Ñ3Ô3ˆˆøÝð ð ð Øˆˆˆðøøøð �:Š:‰<Œ<€DØð (ð (ˆØ�iŠi˜‰oŒoˆØ�"Š9ˆ9Ø˜˜˜”:ˆDØð 	ØØ—
’
‘”ˆà�:Š:‰<Œ<Ð9Ð9¨u°Q°R°R¬yÐ9Ñ9Ô9Ð9Ð9ðÝ& u¨Q¤xÑ0Ô0��øÝð ð ð Ø�ðøøøå˜7Ñ#Ô#ð (¥}°WÑ'=Ô'=ð (Ø—’˜wÑ'Ô'Ð'øØ€Ns   „&+ «:¹:Â:CÃ
CÃCc                 óT   — t          t          | ¦  «        |¦  «        }|r|d         S dS )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   s0   € õ !¥¨$¡¤°Ñ6Ô6€IØð Ø˜Œ|ÐØˆ4r   c                   ó@   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zdd	„Zdd
„Z	eZ
dS )ÚResolverz9
    A resolver that services hosts(5) format files.
    ó
   /etc/hostsé  c                 ó`   — t           j                             | ¦  «         || _        || _        d S ©N)r   ÚResolverBaseÚ__init__r(   Úttl)Úselfr(   r3   s      r   r2   zResolver.__init__S   s+   € ÝÔ×$Ò$ TÑ*Ô*Ð*ØˆŒ	ØˆŒˆˆr   c                 ó~   ‡ ‡— 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  — | ]\}t          |¦  «        ¯t          j        ‰t          j        t          j        ‰j        t          j        |‰j        ¦  «        ¦  «        V — Œ]d S r0   )r   r   ÚRRHeaderÚAÚINr3   ÚRecord_A©r   Úaddrr   r4   s     €€r   ú	<genexpr>z%Resolver._aRecords.<locals>.<genexpr>]   sk   øè è € ð 
ð 
àÝ˜4Ñ Ô ð
ÝŒL˜�sœu¥c¤f¨d¬h½¼ÀTÈ4Ì8Ñ8TÔ8TÑUÔUð
ð 
ð 
ð 
ð 
ð 
r   ©Útupler&   r
   r(   ©r4   r   s   ``r   Ú	_aRecordszResolver._aRecordsX   sW   øø€ õ
 ð 
ð 
ð 
ð 
ð 
å(­°$´)Ñ)<Ô)<¸dÑCÔCð
ñ 
ô 
ñ 
ô 
ð 	
r   c                 ó~   ‡ ‡— 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  — | ]\}t          |¦  «        ¯t          j        ‰t          j        t          j        ‰j        t          j        |‰j        ¦  «        ¦  «        V — Œ]d S r0   )r   r   r7   ÚAAAAr9   r3   ÚRecord_AAAAr;   s     €€r   r=   z(Resolver._aaaaRecords.<locals>.<genexpr>h   sr   øè è € ð 
ð 
ð Ý˜TÑ"Ô"ð
ÝŒLØ•c”h¥¤¨¬µ#´/À$ÈÌÑ2QÔ2Qñô ð
ð 
ð 
ð 
ð 
ð 
r   r>   r@   s   ``r   Ú_aaaaRecordszResolver._aaaaRecordsc   sY   øø€ õ
 ð 
ð 
ð 
ð 
ð 
õ )­°$´)Ñ)<Ô)<¸dÑCÔ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   )r   ÚsucceedÚfailr   ÚFailurer   ÚDomainError)r4   r   Úrecordss      r   Ú_respondzResolver._respondp   sG   € ð ð 	4Ý”= '¨2¨rÐ!2Ñ3Ô3Ð3ÝŒz�'œ/­#¬/¸$Ñ*?Ô*?Ñ@Ô@ÑAÔAÐAr   Nc                 ó|   — t          j        |¦  «        }|                      ||                      |¦  «        ¦  «        S )zm
        Read any IPv4 addresses from C{self.file} and return them as
        L{Record_A} instances.
        )r   ÚdomainStringrM   rA   ©r4   r   Útimeouts      r   ÚlookupAddresszResolver.lookupAddressƒ   s4   € õ
 Ô Ñ%Ô%ˆØ�}Š}˜T 4§>¢>°$Ñ#7Ô#7Ñ8Ô8Ð8r   c                 ó|   — t          j        |¦  «        }|                      ||                      |¦  «        ¦  «        S )zp
        Read any IPv6 addresses from C{self.file} and return them as
        L{Record_AAAA} instances.
        )r   rO   rM   rF   rP   s      r   ÚlookupIPV6AddresszResolver.lookupIPV6Address‹   s6   € õ
 Ô Ñ%Ô%ˆØ�}Š}˜T 4×#4Ò#4°TÑ#:Ô#:Ñ;Ô;Ð;r   )r-   r.   r0   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   rA   rF   rM   rR   rT   ÚlookupAllRecordsr   r   r   r,   r,   N   sŽ   € € € € € ðð ðð ð ð ð
	
ð 	
ð 	
ð
ð 
ð 
ðBð Bð Bð&9ð 9ð 9ð 9ð<ð <ð <ð <ð %ÐÐÐr   r,   N)rX   Útwisted.internetr   Útwisted.internet.abstractr   r   Útwisted.namesr   r   Útwisted.pythonr   Útwisted.python.compatr	   Útwisted.python.filepathr
   r&   r*   r1   r,   r   r   r   ú<module>r`      sé   ðð
ð ð
 #Ð "Ð "Ð "Ð "Ð "Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ø "Ð "Ð "Ð "Ð "Ð "Ø .Ð .Ð .Ð .Ð .Ð .Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,ð$ð $ð $ðNð ð ð*I%ð I%ð I%ð I%ð I%ˆvÔ"ñ I%ô I%ð I%ð I%ð I%r   