| Server IP : 138.197.176.125 / Your IP : 216.73.217.54 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/twisted/names/__pycache__/ |
Upload File : |
U
��W[� � @ s� d Z ddlmZmZ ddlmZ ddlmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ dd lmZ d
d� Zdd
� ZG dd� dej�ZdS )z
hosts(5) support.
� )�division�absolute_import)�nativeString)�dns)�failure)�FilePath)�defer)�isIPAddress)�commonc C s� g }z| � � �� }W n | Y S X |�� }|D ]`}|�d�}|dkrT|d|� }|sZq2|�� }|�� dd� |dd� D �kr2|�t|d �� q2|S )a�
Search the given file, which is in hosts(5) standard format, for an address
entry 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{str}
@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 S s g | ]}|� � �qS � )�lower)�.0�sr
r
�5/usr/lib/python3/dist-packages/twisted/names/hosts.py�
<listcomp>1 s z$searchFileForAll.<locals>.<listcomp>� r )Z
getContent�
splitlinesr �find�split�appendr )Z hostsFile�nameZresults�lines�line�idx�partsr
r
r �searchFileForAll s
r c C s t t| �|�}|r|d S dS )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.
@param name: The name to search for.
@type name: C{str}
@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.
r N)r r )�filer Z addressesr
r
r �
searchFileFor7 s
r c @ sJ e Zd ZdZddd�Zdd� Zdd � Zd
d� Zdd
d�Zddd�Z eZ
dS )�Resolverz9
A resolver that services hosts(5) format files.
�
/etc/hosts� c C s t j�| � || _|| _d S )N)r
�ResolverBase�__init__r �ttl)�selfr r% r
r
r r$ O s zResolver.__init__c s$ 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.
c s6 g | ].}t |�rt�� tjtj�jt�|�j���qS r
)r r �RRHeader�A�INr% ZRecord_A�r Zaddr�r r&