
    Vh                    <   d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
mZmZ d dlmZmZ d dlmZmZ d dlmZmZmZmZ d d	lmZ erd d
lmZ d dlmZ  G d dej<                        Z G d dej@                        Z ee e!e!e"gee#   f   Z$	 	 	 	 	 	 	 	 	 	 	 	 ddZ%y)    )annotations)TYPE_CHECKINGCallable)error)	transport)deferprotocolreactor)IPv4AddressIPv6Address)DeferredmaybeDeferred)IAddress
IConnectorIListeningPortIReactorTCP)Failure)ConchOptions)SSHUserAuthClientc                  @    e Zd Z	 	 	 	 	 	 	 	 	 	 ddZddZddZddZy)	SSHClientFactoryc                <    || _         || _        || _        || _        y N)doptionsverifyHostKeyuserAuthObject)selfr   r   r   r   s        K/home/dcms/DCMS/lib/python3.12/site-packages/twisted/conch/client/direct.py__init__zSSHClientFactory.__init__   s"     )**,    c                D    | j                   d   r|j                          y y )N	reconnect)r   connect)r   	connectorreasons      r   clientConnectionLostz%SSHClientFactory.clientConnectionLost'   s    <<$ %r!   c                h    | j                   y | j                   d c}| _         |j                  |       y r   )r   errback)r   r%   r&   r   s       r   clientConnectionFailedz'SSHClientFactory.clientConnectionFailed+   s+    66>FFD	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compresss   zlibr      zhost-key-algorithms)SSHClientTransportr   supportedCipherssupportedMACssupportedCompressionssupportedPublicKeys)r   addrtranss      r   buildProtocolzSSHClientFactory.buildProtocol1   s    "4(<<	"%)\\)%<E"<<"&,,v"6E<<
#07yE''!,<<-.(,5J(KE%r!   N)
r   Deferred[None]r   r   r   _VHKr   r   returnNone)r%   r   r&   r   r:   r;   )r5   r   r:   r0   )__name__
__module____qualname__r    r'   r*   r7    r!   r   r   r      sF    
-
- 
- 	
-
 *
- 

- 
r!   r   c                  P    e Zd ZU ded<   ddZdddZd Zd Zd Zdd	Z	d
 Z
d Zy)r0   r   factoryc                     || _         d | _        y r   )rA   
unixServer)r   rA   s     r   r    zSSHClientTransport.__init__B   s    15r!   Nc                      j                   r't         j                   j                        }d  _         nt        j                  d       }|j                   fd       y )Nc                D    t         j                  j                        S r   )r   r0   connectionLost)xr&   r   s    r   <lambda>z3SSHClientTransport.connectionLost.<locals>.<lambda>T   s    i22AA$O r!   )rC   r   stopListeningr   succeedaddCallback)r   r&   r   s   `` r   rF   z!SSHClientTransport.connectionLostF   sD    ?? doo;;<A"DOd#A	O	
r!   c                    | j                   j                  y | j                   j                  d c}| j                   _        |j                  t        j                  ||             y r   )rA   r   r)   r   
ConchError)r   codedescr   s       r   receiveErrorzSSHClientTransport.receiveErrorW   sF    <<>>! LLNND4<<>			%""4./r!   c                   | j                   j                  y | j                   j                  d c}| j                   _        t        j                  j	                  | ||       |j                  t        j                  ||             y r   )rA   r   r   r0   sendDisconnectr)   r   rM   )r   rN   r&   r   s       r   rR   z!SSHClientTransport.sendDisconnect]   s^    <<>>! LLNND4<<>$$33D$G			%""6401r!   c                ^    | j                   j                  d|||       |rt        |       y y )Nz!Received Debug Message: {message})messagealwaysDisplaylang)_logdebugprint)r   rU   rT   rV   s       r   receiveDebugzSSHClientTransport.receiveDebugd   s4    		/'	 	 	
 'N r!   c                    | j                   }|J  |j                         }t        |t        t        f      sJ d       | j
                  j                  | |j                  j                  d      ||      S )Nz+Address must have a host to verify against.zutf-8)	r   getPeer
isinstancer   r   rA   r   hostencode)r   pubKeyfingerprintr   peers        r   r   z SSHClientTransport.verifyHostKeyn   s|    NN	$$$ y  ";,
 	98	9 
 ||))$))""7+V[
 	
r!   c                >   | j                   j                  d|       t        j                  j	                  | |       |j
                  dk7  rQ| j                  j                  :| j                  j                  d c}| j                  _        |j                  d        y y y )Nz"setting client server to {service})servicezssh-userauth)	rW   infor   r0   
setServicenamerA   r   callback)r   rd   r   s      r   rf   zSSHClientTransport.setServicey   su    		;WM$$//g><<>)dllnn.H $At||~JJt /I)r!   c                N    | j                  | j                  j                         y r   )requestServicerA   r   )r   s    r   connectionSecurez#SSHClientTransport.connectionSecure   s    DLL778r!   )rA   r   r:   r;   r   )r&   zFailure | Noner:   r;   )r`   bytesra   strr:   zDeferred[bool])r<   r=   r>   __annotations__r    rF   rP   rR   rZ   r   rf   rk   r?   r!   r   r0   r0   >   s0    6
"02	
9r!   r0   c                    t        j                         }t        ||||      }t        t              j                  | ||       |S r   )r   r   r   r   r
   
connectTCP)r^   portr   r   r   r   rA   s          r   r$   r$      s<     (Aq'=.IG##D$8Hr!   N)r^   rm   rq   intr   r   r   r9   r   r   r:   r8   )&
__future__r   typingr   r   twisted.conchr   twisted.conch.sshr   twisted.internetr   r	   r
   twisted.internet.addressr   r   twisted.internet.deferr   r   twisted.internet.interfacesr   r   r   r   twisted.python.failurer   twisted.conch.client.optionsr   twisted.conch.ssh.userauthr   ClientFactoryr   r0   rl   rm   boolr9   r$   r?   r!   r   <module>r      s    # *  ' 5 5 = :  +9<!x-- !HC955 C9L #UE37$GH




 
 	

 &
 
r!   