§
    Ètºf…  ã                   ó˜   — d Z ddlZddlmZ ddlmZmZmZmZ ddl	m
Z
 ddlmZmZmZmZ ddlmZ ddlmZ  G d	„ d
ej        ¦  «        ZdS )z‚
A Factory for SSH servers.

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

Maintainer: Paul Swartz
é    N)Úchain)ÚDictÚListÚOptionalÚTuple)Úerror)Ú_kexÚ
connectionÚ	transportÚuserauth)Úprotocol)ÚLoggerc                   ó  — e Zd ZU dZeeeeeeef                  f                  e	d<    e
¦   «         Zej        Zej        ej        dœZdd„Zd„ Zd„ Zd	„ Zdeeeeeeef                  f                  fd
„Zdedeeef         fd„Zd„ ZdS )Ú
SSHFactoryz$
    A Factory for SSH servers.
    Úprimes)ó   ssh-userauths   ssh-connectionÚreturnNc                 óD  — t          | d¦  «        s|                      ¦   «         | _        t          | d¦  «        s|                      ¦   «         | _        | j        r| j        st          j        d¦  «        ‚t          | d¦  «        s|                      ¦   «         | _        dS dS )z4
        Check for public and private keys.
        Ú
publicKeysÚprivateKeyszno host keys, failingr   N)	ÚhasattrÚgetPublicKeysr   ÚgetPrivateKeysr   r   Ú
ConchErrorÚ	getPrimesr   ©Úselfs    úX/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/conch/ssh/factory.pyÚstartFactoryzSSHFactory.startFactory&   s¦   € õ �t˜\Ñ*Ô*ð 	3Ø"×0Ò0Ñ2Ô2ˆDŒOÝ�t˜]Ñ+Ô+ð 	5Ø#×2Ò2Ñ4Ô4ˆDÔØŒð 	< dÔ&6ð 	<ÝÔ"Ð#:Ñ;Ô;Ð;Ý�t˜XÑ&Ô&ð 	+ØŸ.š.Ñ*Ô*ˆDŒKˆKˆKð	+ð 	+ó    c                 óB  — t           j                             | |¦  «        }t          t	          j        d„ | j                             ¦   «         D ¦   «         ¦  «        ¦  «        |_        | j	        s0| j
                             d¦  «         d„ |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.
        c              3   ó>   K  — | ]}|                      ¦   «         V — Œd S ©N)ÚsupportedSignatureAlgorithms)Ú.0Úkeys     r   ú	<genexpr>z+SSHFactory.buildProtocol.<locals>.<genexpr>?   s?   è è € ð  ð  Ø7:�×0Ò0Ñ2Ô2ð ð  ð  ð  ð  ð  r    zTdisabling non-fixed-group key exchange algorithms because we cannot find moduli filec                 ób   — g | ],}t          j        |¦  «        st          j        |¦  «        ¯*|‘Œ-S © )r	   ÚisFixedGroupÚisEllipticCurve)r%   ÚkexAlgorithms     r   ú
<listcomp>z,SSHFactory.buildProtocol.<locals>.<listcomp>H   sN   € ð 'ð 'ð 'à ÝÔ$ \Ñ2Ô2ð'õ 7;Ô6JÈ<Ñ6XÔ6Xð'Øð'ð 'ð 'r    )r   ÚFactoryÚbuildProtocolÚlistr   Úfrom_iterabler   ÚvaluesÚsupportedPublicKeysr   Ú_logÚinfoÚsupportedKeyExchanges)r   ÚaddrÚts      r   r/   zSSHFactory.buildProtocol3   s½   € õ Ô×*Ò*¨4°Ñ6Ô6ˆÝ $ÝÔð  ð  Ø>BÔ>N×>UÒ>UÑ>WÔ>Wð ñ  ô  ñ ô ñ!
ô !
ˆÔð
 Œ{ð 		ØŒI�NŠNð5ñô ð ð'ð 'à$%Ô$;ð'ñ 'ô 'ˆAÔ#ð
 ˆr    c                 ó    — t          d¦  «        ‚)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}
        zgetPublicKeys unimplemented©ÚNotImplementedErrorr   s    r   r   zSSHFactory.getPublicKeysO   s   € õ "Ð"?Ñ@Ô@Ð@r    c                 ó    — t          d¦  «        ‚)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}
        zgetPrivateKeys unimplementedr:   r   s    r   r   zSSHFactory.getPrivateKeysY   s   € õ "Ð"@ÑAÔAÐAr    c                 ó   — dS )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).
        Nr)   r   s    r   r   zSSHFactory.getPrimesc   s   € € € r    Úbitsc                 óì   ‡— dt           dt           fˆfd„}| j        €
J d¦   «         ‚t          | j                             ¦   «         |¬¦  «        }|d         }t	          j        | j        |         ¦  «        S )z‚
        Return a tuple of (g, p) for a Diffe-Hellman process, with p being as
        close to C{bits} bits as possible.
        Úir   c                 ó(   •— t          | ‰z
  ¦  «        S r#   )Úabs)r@   r>   s    €r   Úkeyfuncz&SSHFactory.getDHPrime.<locals>.keyfuncp   s   ø€ Ý�q˜4‘x‘=”=Ð r    Nz(Factory should have been started by now.)r&   r   )Úintr   ÚsortedÚkeysÚrandomÚchoice)r   r>   rC   Ú
primesKeysÚrealBitss    `   r   Ú
getDHPrimezSSHFactory.getDHPrimej   sˆ   ø€ ð	!•sð 	!�sð 	!ð 	!ð 	!ð 	!ð 	!ð 	!ð Œ{Ð&Ð&Ð(RÑ&Ô&Ð&Ý˜DœK×,Ò,Ñ.Ô.°GÐ<Ñ<Ô<ˆ
Ø˜a”=ˆÝŒ}˜Tœ[¨Ô2Ñ3Ô3Ð3r    c                 óL   — |dk    st          |d¦  «        r| j        |         S dS )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   ÚavatarN)r   Úservices)r   r   Úservices      r   Ú
getServicezSSHFactory.getServicex   s3   € ð �oÒ%Ð%­°¸HÑ)EÔ)EÐ%Ø”= Ô)Ð)ð &Ð%r    )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   rD   r   r   Ú__annotations__r   r4   r   ÚSSHServerTransportr   r   ÚSSHUserAuthServerr
   ÚSSHConnectionrN   r   r/   r   r   r   rK   rP   r)   r    r   r   r      s.  € € € € € € ðð ð �T˜#˜t E¨#¨s¨(¤OÔ4Ð4Ô5Ô6Ð6Ð6Ñ6àˆ6‰8Œ8€DØÔ+€Hð "Ô3Ø%Ô3ðð €Hð
+ð +ð +ð +ðð ð ð8Að Að AðBð Bð Bð˜8 D¨¨d°5¸¸c¸´?Ô.CÐ)CÔ$DÔEð ð ð ð ð4˜sð 4 u¨S°#¨X¤ð 4ð 4ð 4ð 4ð	*ð 	*ð 	*ð 	*ð 	*r    r   )rT   rG   Ú	itertoolsr   Útypingr   r   r   r   Útwisted.conchr   Útwisted.conch.sshr	   r
   r   r   Útwisted.internetr   Útwisted.loggerr   r.   r   r)   r    r   ú<module>r_      së   ððð ð €€€Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à Ð Ð Ð Ð Ð Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ %Ð %Ð %Ð %Ð %Ð %Ø !Ð !Ð !Ð !Ð !Ð !ðj*ð j*ð j*ð j*ð j*�Ô!ñ j*ô j*ð j*ð j*ð j*r    