CasperSecurity

Current Path : /lib/python3/dist-packages/twisted/names/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/names/__pycache__/hosts.cpython-310.pyc

o

�b��@szdZddlmZddlmZmZddlmZmZddl	m
Z
ddlmZddl
mZdd	�Zd
d�ZGdd
�d
ej�ZdS)z
hosts(5) support.
�)�defer)�isIPAddress�
isIPv6Address)�common�dns)�failure)�nativeString)�FilePathc	Cs�g}z|����}Wnty|YSw|��}|D]F}|�d�}|dkr-|d|�}|s0q|��}|��dd�|dd�D�vrbzt|d�}Wn	tyTYqwt|�s]t	|�rb|�
|�q|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.
    �#���NcSsg|]}|���qS�)�lower)�.0�srr�5/usr/lib/python3/dist-packages/twisted/names/hosts.py�
<listcomp>/sz$searchFileForAll.<locals>.<listcomp>�r)�
getContent�
splitlines�
BaseExceptionr
�find�splitr�
ValueErrorrr�append)�	hostsFile�name�results�lines�line�idx�parts�maybeIPrrr�searchFileForAlls0�
�
�r"cCstt|�|�}|r
|dSdS)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.
    rN)r"r	)�filer�	addressesrrr�
searchFileFor9sr%c@sJeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
d�Zddd�Z	eZ
dS)�Resolverz9
    A resolver that services hosts(5) format files.
    �
/etc/hosts�cCstj�|�||_||_dS�N)r�ResolverBase�__init__r#�ttl)�selfr#r,rrrr+Ss
zResolver.__init__c�$t��fdd�tt�j���D��S)zv
        Return a tuple of L{dns.RRHeader} instances for all of the IPv4
        addresses in the hosts file.
        c3�:�|]}t|�rt��tjtj�jt�|�j��VqdSr))rr�RRHeader�A�INr,�Record_A�r�addr�rr-rr�	<genexpr>]s�� 
�z%Resolver._aRecords.<locals>.<genexpr>��tupler"r	r#�r-rrr6r�	_aRecordsXs�zResolver._aRecordscr.)zv
        Return a tuple of L{dns.RRHeader} instances for all of the IPv6
        addresses in the hosts file.
        c3r/r))rrr0�AAAAr2r,�Record_AAAAr4r6rrr7hs���
�z(Resolver._aaaaRecords.<locals>.<genexpr>r8r:rr6r�_aaaaRecordscs�zResolver._aaaaRecordscCs*|r
t�|ddf�St�t�t�|���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)r-r�recordsrrr�_respondpszResolver._respondNcC�t�|�}|�||�|��S)zm
        Read any IPv4 addresses from C{self.file} and return them as
        L{Record_A} instances.
        )r�domainStringrDr;�r-r�timeoutrrr�
lookupAddress��
zResolver.lookupAddresscCrE)zp
        Read any IPv6 addresses from C{self.file} and return them as
        L{Record_AAAA} instances.
        )rrFrDr>rGrrr�lookupIPV6Address�rJzResolver.lookupIPV6Address)r'r(r))�__name__�
__module__�__qualname__�__doc__r+r;r>rDrIrK�lookupAllRecordsrrrrr&Ns


r&N)rO�twisted.internetr�twisted.internet.abstractrr�
twisted.namesrr�twisted.pythonr�twisted.python.compatr�twisted.python.filepathr	r"r%r*r&rrrr�<module>s'
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY