HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/twisted/conch/ssh/__pycache__/factory.cpython-38.pyc
U


W[��@sndZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZddlZGdd	�d	ej�ZdS)
z�
A Factory for SSH servers.

See also L{twisted.conch.openssh_compat.factory} for OpenSSH compatibility.

Maintainer: Paul Swartz
�)�division�absolute_import)�protocol)�log)�error)�_kex�	transport�userauth�
connectionNc@s\eZdZdZejZeje	j
d�Zdd�Zdd�Z
dd�Zd	d
�Zdd�Zd
d�Zdd�ZdS)�
SSHFactoryz$
    A Factory for SSH servers.
    )�ssh-userauthsssh-connectioncCsVt|d�s|��|_t|d�s(|��|_|jr4|js>t�d��t|d�sR|��|_dS)z4
        Check for public and private keys.
        �
publicKeys�privateKeyszno host keys, failing�primesN)	�hasattr�
getPublicKeysr
�getPrivateKeysrrZ
ConchError�	getPrimesr��self�r�;/usr/lib/python3/dist-packages/twisted/conch/ssh/factory.py�startFactory!s





zSSHFactory.startFactorycCs@tj�||�}|j��|_|js<t�d�dd�|j	D�|_	|S)a=
        Create an instance of the server side of the SSH protocol.

        @type addr: L{twisted.internet.interfaces.IAddress} provider
        @param addr: The address at which the server will listen.

        @rtype: L{twisted.conch.ssh.transport.SSHServerTransport}
        @return: The built transport.
        zTdisabling non-fixed-group key exchange algorithms because we cannot find moduli filecSs$g|]}t�|�st�|�r|�qSr)rZisFixedGroupZisEllipticCurve)�.0ZkexAlgorithmrrr�
<listcomp>>s

�z,SSHFactory.buildProtocol.<locals>.<listcomp>)
r�Factory�
buildProtocolr�keysZsupportedPublicKeysrr�msgZsupportedKeyExchanges)rZaddr�trrrr/s

�zSSHFactory.buildProtocolcCstd��dS)z�
        Called when the factory is started to get the public portions of the
        servers host keys.  Returns a dictionary mapping SSH key types to
        public key strings.

        @rtype: L{dict}
        zgetPublicKeys unimplementedN��NotImplementedErrorrrrrrEszSSHFactory.getPublicKeyscCstd��dS)z�
        Called when the factory is started to get the  private portions of the
        servers host keys.  Returns a dictionary mapping SSH key types to
        L{twisted.conch.ssh.keys.Key} objects.

        @rtype: L{dict}
        zgetPrivateKeys unimplementedNr rrrrrPszSSHFactory.getPrivateKeyscCsdS)z�
        Called when the factory is started to get Diffie-Hellman generators and
        primes to use.  Returns a dictionary mapping number of bits to lists
        of tuple of (generator, prime).

        @rtype: L{dict}
        Nrrrrrr[szSSHFactory.getPrimescs2t|j���fdd�d�}|d}t�|j|�S)z�
        Return a tuple of (g, p) for a Diffe-Hellman process, with p being as
        close to bits bits as possible.

        @type bits: L{int}
        @rtype:     L{tuple}
        cst|��S)N)�abs)�i��bitsrr�<lambda>m�z'SSHFactory.getDHPrime.<locals>.<lambda>)�keyr)�sortedrr�randomZchoice)rr%Z
primesKeysZrealBitsrr$r�
getDHPrimeeszSSHFactory.getDHPrimecCs |dkst|d�r|j|SdS)z�
        Return a class to use as a service for the given transport.

        @type transport:    L{transport.SSHServerTransport}
        @type service:      L{bytes}
        @rtype:             subclass of L{service.SSHService}
        rZavatarN)r�services)rr�servicerrr�
getServicerszSSHFactory.getServiceN)�__name__�
__module__�__qualname__�__doc__rZSSHServerTransportrr	ZSSHUserAuthServerr
Z
SSHConnectionr,rrrrrr+r.rrrrrs�

r)r2Z
__future__rrZtwisted.internetrZtwisted.pythonrZ
twisted.conchrZtwisted.conch.sshrrr	r
r*rrrrrr�<module>s