Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/names/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/names/__pycache__/srvconnect.cpython-310.pyc
o

�b�#�@svddlZddlmZddlmZmZddlmZmZddl	m
Z
ddlmZGdd�d�Z
eej�Gd	d
�d
��ZdS)�N)�implementer)�error�
interfaces)�client�dns)�DNSNameError)�nativeStringc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�"_SRVConnector_ClientFactoryWrappercCs||_||_dS�N)�-_SRVConnector_ClientFactoryWrapper__connector�2_SRVConnector_ClientFactoryWrapper__wrappedFactory)�self�	connector�wrappedFactory�r�:/usr/lib/python3/dist-packages/twisted/names/srvconnect.py�__init__s
z+_SRVConnector_ClientFactoryWrapper.__init__cCs|j�|j�dSr
)r�startedConnectingr)r
rrrrrsz4_SRVConnector_ClientFactoryWrapper.startedConnectingcC�|j�|�dSr
)r�connectionFailed�r
r�reasonrrr�clientConnectionFailed�z9_SRVConnector_ClientFactoryWrapper.clientConnectionFailedcCrr
)r�connectionLostrrrr�clientConnectionLostrz7_SRVConnector_ClientFactoryWrapper.clientConnectionLostcCst|j|�Sr
)�getattrr)r
�keyrrr�__getattr__sz._SRVConnector_ClientFactoryWrapper.__getattr__N)�__name__�
__module__�__qualname__rrrrrrrrrr	sr	c@s�eZdZdZdZdddidfdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�SRVConnectoraD
    A connector that looks up DNS SRV records.

    RFC 2782 details how SRV records should be interpreted and selected
    for subsequent connection attempts. The algorithm for using the records'
    priority and weight is implemented in L{pickServer}.

    @ivar servers: List of candidate server records for future connection
        attempts.
    @type servers: L{list} of L{dns.Record_SRV}

    @ivar orderedServers: List of server records that have already been tried
        in this round of connection attempts.
    @type orderedServers: L{list} of L{dns.Record_SRV}
    r�tcp�
connectTCPrNc

Cs^||_||_|durdnt�|�|_||_||_||_||_||_	|	|_
d|_d|_d|_
dS)a�
        @param domain: The domain to connect to.  If passed as a text
            string, it will be encoded using C{idna} encoding.
        @type domain: L{bytes} or L{str}

        @param defaultPort: Optional default port number to be used when SRV
            lookup fails and the service name is unknown. This should be the
            port number associated with the service name as defined by the IANA
            registry.
        @type defaultPort: L{int}
        N)�reactor�servicer�domainString�domain�factory�protocol�connectFuncName�connectFuncArgs�connectFuncKwArgs�_defaultPortr�servers�orderedServers)
r
r%r&r(r)r*r+r,r-�defaultPortrrrr6s
zSRVConnector.__init__cCs�|j��|j�|�|jsR|jdur|�t�d��dSt�	dt
|j�t
|j�t
|j�f�}|�
|j|j�|�|fdd��|jrJ|�|j�|�|j�dS|jdur]|��dS|j��dS)z"Start connection to remote server.NzDomain is not defined.z
_%s._%s.%scSs|��Sr
)�_reallyConnect)�xr
rrr�<lambda>qsz&SRVConnector.connect.<locals>.<lambda>)r)�doStartrr/r(rr�DNSLookupErrorr�
lookupServicerr&r*�addCallbacks�
_cbGotServers�
_ebGotServers�addCallbackr.�
addErrback�_ebServiceUnknownrr2�connect)r
�drrrr>]s0

����
zSRVConnector.connectcCs|�t�g|_g|_dSr
)�traprr/r0�r
�failurerrrr:zs

zSRVConnector._ebGotServerscCs�|\}}}t|�dkr2|djtjkr2|djr2|djjt�d�kr2t�dt	|j
�t	|j�f��g|_g|_
|D]}|jtjksE|jsFq:|j
�|j�q:dS)N�r�.z'Service %s not available for domain %s.)�len�typer�SRV�payload�target�Namerr6�reprr&r(r/r0�append)r
�result�answers�auth�add�arrrr9�s$
����zSRVConnector._cbGotServerscCs6|�tj�t�dd|j|j�g|_g|_|�	�dS)a.
        Connect to the default port when the service name is unknown.

        If no SRV records were found, the service name will be passed as the
        port. If resolving the name fails with
        L{error.ServiceNameUnknownError}, a final attempt is done using the
        default port.
        rN)
r@r�ServiceNameUnknownErrorr�
Record_SRVr.r(r/r0r>rArrrr=�s	zSRVConnector._ebServiceUnknownc	Cs$|jdusJ�|jdusJ�|js|jst|j�|jfS|js)|jr)|j|_g|_|js.J�|jjdd�d�|jdj}d}d}g}|jD]}|j|kr]||j7}|�||f�|d7}qFt	�
d|�}|D]!\}}||kr�|j|}|j|=|j�|�t|j�|j
fSqftd|jj�d���)	a;
        Pick the next server.

        This selects the next server from the list of SRV records according
        to their priority and weight values, as set out by the default
        algorithm specified in RFC 2782.

        At the beginning of a round, L{servers} is populated with
        L{orderedServers}, and the latter is made empty. L{servers}
        is the list of candidates, and L{orderedServers} is the list of servers
        that have already been tried.

        First, all records are ordered by priority and weight in ascending
        order. Then for each priority level, a running sum is calculated
        over the sorted list of records for that priority. Then a random value
        between 0 and the final sum is compared to each record in order. The
        first record that is greater than or equal to that random value is
        chosen and removed from the list of candidates for this round.

        @return: A tuple of target hostname and port from the chosen DNS SRV
            record.
        @rtype: L{tuple} of native L{str} and L{int}
        NcSs|j|jfSr
)�priority�weight)�recordrrrr4�sz)SRVConnector.pickServer.<locals>.<lambda>)rrrCzImpossible z pickServer result.)r/r0rr(r&�sortrTrUrL�random�randint�strrI�port�RuntimeError�	__class__r)	r
�minPriority�index�	weightSum�weightIndexr3�randrU�chosenrrr�
pickServer�s8



�
�zSRVConnector.pickServercCs�|jrd|_dS|��\|_|_|jdusJd��|jdus"Jd��t|j|j�}||j|jt||j�g|j	�Ri|j
��|_dS)NrzMust have a host to connect to.zMust have a port to connect to.)�stopAfterDNSrd�hostr[rr%r+r	r)r,r-r)r
�connectFuncrrrr2�s 
���zSRVConnector._reallyConnectcCs|jr
|j��dSd|_dS)zStop attempting to connect.rCN)r�stopConnectingre�r
rrrrh�s
zSRVConnector.stopConnectingcCs$|jdur|j��dS|��dS)z%Disconnect whatever our are state is.N)r�
disconnectrhrirrrrj�s
zSRVConnector.disconnectcCs|jsJ�|j��Sr
)r�getDestinationrirrrrks

zSRVConnector.getDestinationcC�|j�||�|j��dSr
)r)r�doStop�r
rrrrr	�zSRVConnector.connectionFailedcCrlr
)r)rrmrnrrrr
rozSRVConnector.connectionLost)rr r!�__doc__rerr>r:r9r=rdr2rhrjrkrrrrrrr""s(
�'
=r")rX�zope.interfacer�twisted.internetrr�
twisted.namesrr�twisted.names.errorr�twisted.python.compatrr	�
IConnectorr"rrrr�<module>s

Spamworldpro Mini