
    \d                         d dl mZ d dlmZ d dlmZmZmZ  G d dej                  Z	 G d dej
                  Z
d Zd	S )
    )error)	transport)deferprotocolreactorc                   &    e Zd Zd Zd Zd Zd ZdS )SSHClientFactoryc                 >    || _         || _        || _        || _        d S N)doptionsverifyHostKeyuserAuthObject)selfr   r   r   r   s        ;lib/python3.11/site-packages/twisted/conch/client/direct.py__init__zSSHClientFactory.__init__   s&    *,    c                 L    | j         d         r|                                 d S d S )N	reconnect)r   connect)r   	connectorreasons      r   clientConnectionLostz%SSHClientFactory.clientConnectionLost   s3    <$ 	 	  	 r   c                 `    | j         d S | j         d c}| _         |                    |           d S r   )r   errback)r   r   r   r   s       r   clientConnectionFailedz'SSHClientFactory.clientConnectionFailed   s5    6>FFD	46			&r   c                    t          |           }| j        d         r| j        d         |_        | j        d         r| j        d         |_        | j        d         rdg|j        dd<   | j        d         r| j        d         |_        |S )Nciphersmacscompresszlibr      zhost-key-algorithms)SSHClientTransportr   supportedCipherssupportedMACssupportedCompressionssupportedPublicKeys)r   addrtranss      r   buildProtocolzSSHClientFactory.buildProtocol   s    "4((<	" 	=%)\)%<E"< 	7"&,v"6E<
# 	806xE'!,<-. 	L(,5J(KE%r   N)__name__
__module____qualname__r   r   r   r*    r   r   r	   r	   
   sP        - - -       
 
 
 
 
r   r	   c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
r#   c                 "    || _         d | _        d S r   )factory
unixServer)r   r1   s     r   r   zSSHClientTransport.__init__)   s    r   c                       j         r! j                                         }d  _         nt          j        d           }|                     fd           d S )Nc                 D    t           j                                      S r   )r   r#   connectionLost)xr   r   s    r   <lambda>z3SSHClientTransport.connectionLost.<locals>.<lambda>4   s    i2AA$OO r   )r2   stopListeningr   succeedaddCallback)r   r   r   s   `` r   r5   z!SSHClientTransport.connectionLost-   sh    ? 	$--//A"DOOd##A	OOOOO	
 	
 	
 	
 	
r   c                     | j         j        d S | j         j        d c}| j         _        |                    t          j        ||                     d S r   )r1   r   r   r   
ConchError)r   codedescr   s       r   receiveErrorzSSHClientTransport.receiveError7   sJ    <>!F LND4<>			%"4../////r   c                     | j         j        d S | j         j        d c}| j         _        t          j                            | ||           |                    t          j        ||                     d S r   )r1   r   r   r#   sendDisconnectr   r   r<   )r   r=   r   r   s       r   rA   z!SSHClientTransport.sendDisconnect=   se    <>!F LND4<>$33D$GGG			%"640011111r   c                 h    | j                             d|||           |rt          |           d S d S )Nz!Received Debug Message: {message})messagealwaysDisplaylang)_logdebugprint)r   rD   rC   rE   s       r   receiveDebugzSSHClientTransport.receiveDebugD   sN    	/'	 	 	
 	
 	
  	'NNNNN	 	r   c                 t    | j                             | | j                                        j        ||          S r   )r1   r   r   getPeerhost)r   pubKeyfingerprints      r   r   z SSHClientTransport.verifyHostKeyN   s6    |))$.((**/
 
 	
r   c                    | j                             d|           t          j                            | |           |j        dk    r<| j        j        2| j        j        d c}| j        _        |                    d            d S d S d S )Nz"setting client server to {service})servicezssh-userauth)	rF   infor   r#   
setServicenamer1   r   callback)r   rP   r   s      r   rR   zSSHClientTransport.setServiceS   s    	;WMMM$//g>>><>))dln.H $At|~JJt *).H.Hr   c                 D    |                      | j        j                   d S r   )requestServicer1   r   )r   s    r   connectionSecurez#SSHClientTransport.connectionSecureZ   s!    DL788888r   N)r+   r,   r-   r   r5   r?   rA   rI   r   rR   rW   r.   r   r   r#   r#   (   s          
 
 
0 0 02 2 2  
 
 

  9 9 9 9 9r   r#   c                 |    t          j                    }t          ||||          }t          j        | ||           |S r   )r   Deferredr	   r   
connectTCP)rL   portr   r   r   r   r1   s          r   r   r   ^   s<    Aq'=.IIGtT7+++Hr   N)twisted.conchr   twisted.conch.sshr   twisted.internetr   r   r   ClientFactoryr	   r#   r   r.   r   r   <module>r`      s   
        ' ' ' ' ' ' 5 5 5 5 5 5 5 5 5 5    x-   <39 39 39 39 395 39 39 39l    r   