
    mg`                        d Z ddlZddlZddlZddlZddlZddl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mZmZ ddlmZmZmZmZmZmZ ddlmZmZmZmZmZmZ dd	l m!Z!m"Z" d
dl#m$Z$ d
dl#m%Z%m&Z& d
dl#m'Z'm(Z( d
dl#m)Z)m*Z* d
dl#m+Z+ d
dl#m,Z,m-Z- d
dl#m.Z. ej^                  dk7  rddl0Z0ddl1Z1ddl2Z2ee3e3f   Z4ee4   Z5ee3e3e3e3f   Z6edee3e3f   e6f   Z7 G d de"      Z8 G d de"      Z9 G d de"      Z: ed      Z;eed   e;f   Z<ee;ee;   f   Z=eee>   e>ef   Z?ee?ed   f   Z@eeAeBf   ZCeeCeCf   ZDeeBe	f   ZEeeBe3f   ZFeej                  ej                  f   ZIeej                  ej                  f   ZLeeeBe3f   eeBe3e3e3f   f   ZM e       ZNeNj                  ZO ej                  d      ZQd
dddd ZRd
d
d!d"d#d$d%ZSdd&eTd'eBd(eBfd)ZUdd*e3d+eBd,eBd(eBfd-ZVd.eeT   d(eWfd/ZX	 dd0eeBe3f   d'eBd1e3d(ee3eBf   fd2ZYd3ZZd4eBd(eBfd5Z[d6eBd(eBfd7Z\d6eBd(eIfd8Z]d6eBd(eLfd9Z^dd:eEd;eBd<e3d(eeA   fd=Z_ed:eEd(eAfd>       Z`ed:eEd;e!d?   d(eAfd@       Z`ed:eEd;e!dA   d(eBfdB       Z`ddCZ`dd:eEdDeAd;eBd(e3fdEZad&eBdFeeBe3f   d+eBd(ebfdGZcd&eBd(e3fdHZdd&eBd(ebfdIZedJeBd(eeB   fdKZf edLedMN      Zg G dO dPeeg         ZhedQeeg   f   ZiedQeheg   f   ZjdReieg   d(ejeg   fdSZkddTZldUedVe3dWe3dXe3dYe3d(dfdZZm G d[ d\      Zn G d] d^eo      Zp G d_ d`epa      Zq G db dcer      Zs G dd dees      Zt G df dget      Zu G dh diet      Zv G dj dket      Zw G dl dmet      Zx G dn doet      Zy G dp dqet      Zz G dr dset      Z{ G dt duet      Z| G dv dwet      Z} G dx dyet      Z~ G dz d{es      Z G d| d}er      Z G d~ der      Z G d der      Z G d der      Z G d der      Z G d der      Ze,e|e)eye*eze%eue.e~e-e}e'ewe&eve+e{e(exi
Zde3deBdeBd(etfdZy)z+Miscellaneous utility classes and functions    N)PathPurePath)SystemRandom)TracebackType)AnyAsyncContextManager	AwaitableCallableDict)	GeneratorGenericIOMappingOptionalSequence)TupleTypeTypeVarUnioncastoverload)LiteralProtocol   )DEFAULT_LANG)DISC_COMPRESSION_ERRORDISC_CONNECTION_LOST)DISC_HOST_KEY_NOT_VERIFIABLEDISC_ILLEGAL_USER_NAME)DISC_KEY_EXCHANGE_FAILEDDISC_MAC_ERROR)#DISC_NO_MORE_AUTH_METHODS_AVAILABLE)DISC_PROTOCOL_ERROR#DISC_PROTOCOL_VERSION_NOT_SUPPORTED)DISC_SERVICE_NOT_AVAILABLEwin32c                   z    e Zd ZdZedefd       Zedefd       Zedefd       Z	de
fdZdefdZde
dd	fd
Zy	)_HashzProtocol for hashing datareturnc                      y)zReturn the hash digest sizeN selfs    -lib/python3.12/site-packages/asyncssh/misc.pydigest_sizez_Hash.digest_size<           c                      y)zReturn the hash block sizeNr+   r,   s    r.   
block_sizez_Hash.block_size@   r0   r1   c                      y)zReturn the hash nameNr+   r,   s    r.   namez
_Hash.nameD   r0   r1   c                      y)z)Return the digest value as a bytes objectNr+   r,   s    r.   digestz_Hash.digestH   r0   r1   c                      y)z9Return the digest value as a string of hexadecimal digitsNr+   r,   s    r.   	hexdigestz_Hash.hexdigestK   r0   r1   _Hash__dataNc                      y)z7Update this hash object's state with the provided bytesNr+   )r-   r:   s     r.   updatez_Hash.updateN   r0   r1   )__name__
__module____qualname____doc__propertyintr/   r3   strr5   bytesr7   r9   r<   r+   r1   r.   r(   r(   9   s    #*S * * )C ) ) #c # #8 8H3 HFU Ft Fr1   r(   c                   "    e Zd ZdZddedefdZy)HashTypez2Protocol for returning the type of a hash function_HashType__datar)   c                      y)zCreate a new hash objectNr+   )r-   rG   s     r.   __call__zHashType.__call__U   r0   r1   N).)r=   r>   r?   r@   rD   r(   rI   r+   r1   r.   rF   rF   R   s    <'u 'u 'r1   rF   c                       e Zd ZdZddZy)_SupportsWaitClosedz'A class that supports async wait_closedNc                    K   yw)zWait for transport to closeNr+   r,   s    r.   wait_closedz_SupportsWaitClosed.wait_closed\   s     s   r)   N)r=   r>   r?   r@   rM   r+   r1   r.   rK   rK   Y   s
    1*r1   rK   _Tr+   )NNNz
([A-Za-z])i   i   i   @) kmg<   i  iQ i:	 )rP   srR   hdwvalueprefixr)   c                 *    t        |       } | r|| z   S dS )z:Return a string with optional prefix if value is non-emptyrP   rC   )rY   rZ   s     r.   
hide_emptyr]   {   s     JE"6E>**r1   lengthlabelsuffixc                 &    d| || dk7  r|fz  S dfz  S )z-Return a label with an optional plural suffixz%d %s%sr   rP   r+   )r^   r_   r`   s      r.   pluralrb      s'     1vEEE"EEEr1   seqc                 &    t        d | D              S )z*Return if a sequence contains all integersc              3   <   K   | ]  }t        |t                y wN)
isinstancerB   ).0is     r.   	<genexpr>zall_ints.<locals>.<genexpr>   s     /3az!S!3s   )all)rc   s    r.   all_intsrl      s     /3///r1   symbolsstrip_leadingc                 ~    | j                         D ci c]  \  }}|j                  |      r|||d  c}}S c c}}w )z8Return a mapping from values to symbol names for loggingN)items
startswith)rm   rZ   rn   r5   rY   s        r.   get_symbol_namesrr      sJ     <C==? (?KD%v& 4''? ( ( (s   !9))@_at_)._dot_)-_r5   c                 F    t         D ]  \  }}| j                  ||      }  | S )z9Map punctuation so a string can be used as a handler name)_HANDLER_PUNCTUATIONreplace)r5   oldnews      r.   map_handler_namer~      s)     )S||C% ) Kr1   addrc                 2   	 t        j                  | dt         j                  t         j                  t         j                        d   }|d   t         j                  k(  r|d   }|d   } | j                  d      }|dk\  r| d| } t        j                  |       }|j                  rWt        t        t        t        t        t        f   |      d   }t        t        j                  t        |      |dz  z              } | S # t         j
                  $ r | cY S w xY w)zNormalize scoped IP address

       The ipaddress module doesn't handle scoped addresses properly,
       so we normalize scoped IP addresses using socket.getaddrinfo
       before we pass them into ip_address/ip_network.

    N)familytypeflagsr      %   `   )socketgetaddrinfo	AF_UNSPECSOCK_STREAMAI_NUMERICHOSTgaierrorAF_INET6find	ipaddress
ip_addressis_link_localr   r   rC   rB   )r   addrinfosaidxipscope_ids         r.   _normalize_scoped_ipr      s    %%dD9I9I+1+=+=,2,A,ACCDF {foo%a[!uiin!8:D!!$'E#sC"45r:1=Hy++CGx2~,FGHDK# ?? s   AC> >DDc                 >    t        j                  t        |             S )z@Wrapper for ipaddress.ip_address which supports scoped addresses)r   r   r   )r   s    r.   r   r      s      4T :;;r1   c                     | j                  d      }|dk\  r| d| | |d }} nd}t        j                  t        |       |z         S )z@Wrapper for ipaddress.ip_network which supports scoped addresses/r   NrP   )r   r   
ip_networkr   )r   r   masks      r.   r   r      sN     ))C.C
ax$3Zcdd 4T :T ABBr1   filenamemode	bufferingc                 L    t        t        |       j                         ||      S )z)Open a file with home directory expansion)r   )openr   
expanduser)r   r   r   s      r.   	open_filer      s      X))+TYGGr1   c                      yz5Read from a binary file with home directory expansionNr+   )r   s    r.   	read_filer      r0   r1   rbc                      yr   r+   r   r   s     r.   r   r      r0   r1   rc                      y)z3Read from a text file with home directory expansionNr+   r   s     r.   r   r      r0   r1   c                 f    t        | |      5 }|j                         cddd       S # 1 sw Y   yxY w)z.Read from a file with home directory expansionN)r   read)r   r   fs      r.   r   r      s%     
8T	"avvx 
#	"	"s   '0datac                 h    t        | |      5 }|j                  |      cddd       S # 1 sw Y   yxY w)z7Write or append to a file with home directory expansionN)r   write)r   r   r   r   s       r.   
write_filer      s'     
8T	"awwt} 
#	"	"s   (1suffixesc           	      
   t         j                  |       d   rj                  d       nj                          	 t	        fdt        dt              d      D              S # t        $ r t        d|z         dw xY w)z4Parse a series of integers followed by unit suffixesrP   c              3   n   K   | ],  }t        |         |d z      j                            z   . yw)r   N)floatlower)rh   ri   matchesr   s     r.   rj   z_parse_units.<locals>.<genexpr>   s=      75q $x!0B0B0D'EE5s   25r      Invalid N)	_unit_patternsplitappendpopsumrangelenKeyError
ValueError)rY   r   r_   r   s    ` @r.   _parse_unitsr      s~     !!%(Gr{r7 7!!S\157 7 	7 7e+,$67s    (A) )Bc                 6    t        t        | t        d            S )z4Parse a byte count with optional k, m, or g suffixesz
byte count)rB   r   _byte_unitsrY   s    r.   parse_byte_countr     s     |E;=>>r1   c                 $    t        | t        d      S )z=Parse a time interval with optional s, m, h, d, or w suffixesztime interval)r   _time_unitsr   s    r.   parse_time_intervalr     s     {O<<r1   commandc                     t        j                   | d      }d|_        t        j                  dk(  rg |_        t        |      S )z/Split a command string into a list of argumentsT)posixr&   )shlexwhitespace_splitsysplatformescapelist)r   lexs     r.   
split_argsr     s9     ++gT
*CC
||w
9r1   _ACMT)bound	covariantc            	       |    e Zd ZdZdee   fdZdeedef   fdZ	defdZ
deee      d	ee   d
ee   dee   fdZy)_ACMWrapperzAsync context manager wrappercoroc                      || _         d | _        y rf   )_coro_coro_result)r-   r   s     r.   __init__z_ACMWrapper.__init__#  s    
,0r1   r)   Nc                 6    | j                   j                         S rf   )r   	__await__r,   s    r.   r   z_ACMWrapper.__await__'  s    zz##%%r1   c                    K   | j                    d {   | _        | j                  j                          d {   S 7 +7 wrf   )r   r   
__aenter__r,   s    r.   r   z_ACMWrapper.__aenter__*  s6     "&**,&&11333 -3s   A>&AA A Aexc_type	exc_value	tracebackc                    K   | j                   J | j                   j                  |||       d {   }d | _         |S 7 wrf   )r   	__aexit__)r-   r   r   r   exit_results        r.   r   z_ACMWrapper.__aexit__/  sQ        ,,, --77i, , !,s   /A?A)r=   r>   r?   r@   r	   r   r   r   r   r   r   r   r   BaseExceptionr   boolr   r+   r1   r.   r   r      st    '1Yt_ 1&9S$_5 &4$ 4

m1D(E 
#+M#:
#+M#:
?G~
r1   r   .r   c                 ^     t        j                         dt        t           f fd       }|S )a  Decorator for functions returning asynchronous context managers

       This decorator can be used on functions which return objects
       intended to be async context managers. The object returned by
       the function should implement __aenter__ and __aexit__ methods
       to run when the async context is entered and exited.

       This wrapper also allows the use of "await" on the function being
       decorated, to return the context manager without entering it.

    r)   c                  &    t         | i |      S )z:Return an async context manager wrapper for this coroutine)r   )argskwargsr   s     r.   context_wrapperz.async_context_manager.<locals>.context_wrapperL  s     40011r1   )	functoolswrapsr   r   )r   r   s   ` r.   async_context_managerr   ?  s4     __T2K,= 2 2
 r1   c                 `   K   	 | j                          d{    y7 # t        $ r Y yw xY ww)a  Wait for a StreamWriter to close, if Python version supports it

       Python 3.8 triggers a false error report about garbage collecting
       an open stream if a close is in progress when a StreamWriter is
       garbage collected. This can be avoided by calling wait_closed(),
       but that method is not available in Python releases prior to 3.7.
       This function wraps this call, ignoring the error if the method
       is not available.

    N)rM   AttributeError)writers    r.   maybe_wait_closedr   U  s.       """ s(   .  . 	+.+.ttywidthheightpixwidth	pixheightc                 |    t        j                  | t        j                  t	        j
                  d||||             y)zSet the terminal size of a TTYhhhhN)fcntlioctltermios
TIOCSWINSZstructpack)r   r   r   r   r   s        r.   set_terminal_sizer  g  s/     
KKW''FFE8YGIr1   c                   h    e Zd ZU dZeeef   ed<   d	ded    defdZ	deddfdZ
deeef   ddfdZy)
Optionsz#Container for configuration optionsr   Noptionsc                 \   |rlt        |t        |             s7t        dt        |       j                  dt        |      j                        |j                  j                         | _        ni | _        | j                  j                  |        | j                  di | j                   y )Nr   z, got r+   )rg   r   	TypeErrorr=   r   copyr<   prepare)r-   r  r   s      r.   r   zOptions.__init__t  s    gtDz2!%d!4!4d7m6L6L!N O O "..--/DKDK6"#t{{#r1   r)   c                      y)z!Pre-process configuration optionsNr+   r-   r   s     r.   r  zOptions.prepare  r0   r1   c                 r    | j                   j                  |        | j                  di | j                    y)z4Update options based on keyword parameters passed inNr+   )r   r<   r  r  s     r.   r<   zOptions.update  s+     	6"#t{{#r1   rf   )r=   r>   r?   r@   r   rC   object__annotations__r   r   r  r<   r+   r1   r.   r
  r
  o  s[    -f$ 3 $f $0 04 0$T#v+. $4 $r1   r
  c            
       R     e Zd ZdZded    dedeedf   deee	f   dd f
 fdZ
 xZS )	_RecordMetaz)Metaclass for general-purpose record typemcsr5   bases.nsr)   c           	      r   |dk7  rt        t        t        t        f   |j                  di             j	                         }|D ci c]  }||j                  |       }}|j                         D ci c]  \  }}||vs|| }}}||d<   t        t        t        | !  | |||            S c c}w c c}}w )NRecordr  	__slots__)	r   r   rC   getkeysrp   r  super__new__)	r  r5   r  r  fieldsrQ   defaultsv	__class__s	           r.   r   z_RecordMeta.__new__  s    8'#s(+&&!2B799= .45f266!9fH5#%88:A:41a&!Q$:BA&B{OKdE2!FGG 6As   B.4B3B3)r=   r>   r?   r@   r   rC   r   r   r   r  r   __classcell__r$  s   @r.   r  r    sS    3
HT-( 
H 
HE$)<L 
Hf%
H*7
H 
Hr1   r  c                   l    e Zd ZU dZi Zeeef   ed<   dedefdZ	defdZ
defdZd	ed
edee   fdZy)r  zGeneric Record classr  r   r   c                    | j                   j                         D ]  \  }}t        | ||        t        | j                   |      D ]  \  }}t        | ||        |j                         D ]  \  }}t        | ||        y rf   )r  rp   setattrzip)r-   r   r   rQ   r#  s        r.   r   zRecord.__init__  sr    NN((*DAqD!Q + -DAqD!Q . LLNDAqD!Q #r1   r)   c                 ~     t               j                  ddj                   fd j                  D              dS )N(, c              3   @   K   | ]  }|d t        |        yw)=N)getattrrh   rQ   r-   s     r.   rj   z"Record.__repr__.<locals>.<genexpr>  s%      %>.< 12743C%D.<s   ))r   r=   joinr  r,   s   `r.   __repr__zRecord.__repr__  s7    :..99 %>.2nn%> >? 	?r1   c                 ^      fd j                   D        }dj                  d |D              S )Nc           	   3   Z   K   | ]"  }|j                  |t        |            f $ y wrf   )_formatr0  r1  s     r.   rj   z!Record.__str__.<locals>.<genexpr>  s0      +)a dll1gdA&678)s   (+r-  c              3   6   K   | ]  \  }}|	|d|  y w)Nz: r+   )rh   rQ   r#  s      r.   rj   z!Record.__str__.<locals>.<genexpr>  s     Ovtq!Q*vs   
)r  r3  )r-   valuess   ` r.   __str__zRecord.__str__  s-    +>>+ yyOvOOOr1   rQ   r#  c                     t        |      S )zFormat a field as a stringr\   )r-   rQ   r#  s      r.   r7  zRecord._format  s    
 1vr1   N)r=   r>   r?   r@   r  r   rC   r  r  r   r4  r:  r   r7  r+   r1   r.   r  r    sc    &(IwsF{#( f    ?# ?
P P  HSM r1   r  )	metaclassc                   4     e Zd ZdZefdededef fdZ xZS )ErrorzGeneral SSH errorcodereasonlangc                 N    t         |   |       || _        || _        || _        y rf   )r  r   r?  r@  rA  )r-   r?  r@  rA  r$  s       r.   r   zError.__init__  s%     		r1   )	r=   r>   r?   r@   r   rB   rC   r   r%  r&  s   @r.   r>  r>    s(    ;G S # S  r1   r>  c                       e Zd ZdZy)DisconnectErrora  SSH disconnect error

       This exception is raised when a serious error occurs which causes
       the SSH connection to be disconnected. Exception codes should be
       taken from :ref:`disconnect reason codes <DisconnectReasons>`.
       See below for exception subclasses tied to specific disconnect
       reasons if you want to customize your handling by reason.

       :param code:
           Disconnect reason, taken from :ref:`disconnect reason
           codes <DisconnectReasons>`
       :param reason:
           A human-readable reason for the disconnect
       :param lang: (optional)
           The language the reason is in
       :type code: `int`
       :type reason: `str`
       :type lang: `str`

    Nr=   r>   r?   r@   r+   r1   r.   rD  rD    s    r1   rD  c                   0     e Zd ZdZefdedef fdZ xZS )CompressionErrora^  SSH compression error

       This exception is raised when an error occurs while compressing
       or decompressing data sent on the SSH connection.

       :param reason:
           Details about the compression error
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r   r-   r@  rA  r$  s      r.   r   zCompressionError.__init__      />r1   r=   r>   r?   r@   r   rC   r   r%  r&  s   @r.   rG  rG    %     1= ?s ?# ? ?r1   rG  c                   0     e Zd ZdZefdedef fdZ xZS )ConnectionLosta  SSH connection lost

       This exception is raised when the SSH connection to the remote
       system is unexpectedly lost. It can also occur as a result of
       the remote system failing to respond to keepalive messages or
       as a result of a login timeout, when those features are enabled.

       :param reason:
           Details about the connection failure
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r   rI  s      r.   r   zConnectionLost.__init__  s    -vt<r1   rK  r&  s   @r.   rN  rN    s%      1= =s =# = =r1   rN  c                   0     e Zd ZdZefdedef fdZ xZS )HostKeyNotVerifiableaX  SSH host key not verifiable

       This exception is raised when the SSH server's host key or
       certificate is not verifiable.

       :param reason:
           Details about the host key verification failure
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r   rI  s      r.   r   zHostKeyNotVerifiable.__init__  s    5vtDr1   rK  r&  s   @r.   rQ  rQ    s)     1= Es E# E Er1   rQ  c                   0     e Zd ZdZefdedef fdZ xZS )IllegalUserNameaV  SSH illegal user name

       This exception is raised when an error occurs while processing
       the username sent during the SSL handshake.

       :param reason:
           Details about the illegal username
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r   rI  s      r.   r   zIllegalUserName.__init__'  rJ  r1   rK  r&  s   @r.   rT  rT    rL  r1   rT  c                   0     e Zd ZdZefdedef fdZ xZS )KeyExchangeFaileda"  SSH key exchange failed

       This exception is raised when the SSH key exchange fails.

       :param reason:
           Details about the connection failure
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r    rI  s      r.   r   zKeyExchangeFailed.__init__9  s    164@r1   rK  r&  s   @r.   rW  rW  +  s)     1= As A# A Ar1   rW  c                   0     e Zd ZdZefdedef fdZ xZS )MACErroral  SSH MAC error

       This exception is raised when an error occurs while processing
       the message authentication code (MAC) of a message on the SSH
       connection.

       :param reason:
           Details about the MAC error
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r!   rI  s      r.   r   zMACError.__init__M  s    6r1   rK  r&  s   @r.   rZ  rZ  =  s%     1= 7s 7# 7 7r1   rZ  c                   0     e Zd ZdZefdedef fdZ xZS )PermissionDeniedai  SSH permission denied

       This exception is raised when there are no authentication methods
       remaining to complete SSH client authentication.

       :param reason:
           Details about the SSH protocol error detected
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r"   rI  s      r.   r   zPermissionDenied.__init__`  s    <fdKr1   rK  r&  s   @r.   r]  r]  Q  s)     1= Ls L# L Lr1   r]  c                   0     e Zd ZdZefdedef fdZ xZS )ProtocolErroraa  SSH protocol error

       This exception is raised when the SSH connection is disconnected
       due to an SSH protocol error being detected.

       :param reason:
           Details about the SSH protocol error detected
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   r  r   r#   rI  s      r.   r   zProtocolError.__init__s      ,fd;r1   rK  r&  s   @r.   r`  r`  d  %     1= <s <# < <r1   r`  c                   0     e Zd ZdZefdedef fdZ xZS )ProtocolNotSupportedaf  SSH protocol not supported

       This exception is raised when the remote system sends an SSH
       protocol version which is not supported.

       :param reason:
           Details about the unsupported SSH protocol version
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   rb  rI  s      r.   r   zProtocolNotSupported.__init__  rc  r1   rK  r&  s   @r.   rf  rf  w  rd  r1   rf  c                   0     e Zd ZdZefdedef fdZ xZS )ServiceNotAvailableaT  SSH service not available

       This exception is raised when an unexpected service name is
       received during the SSH handshake.

       :param reason:
           Details about the unexpected SSH service
       :param lang: (optional)
           The language the reason is in
       :type reason: `str`
       :type lang: `str`

    r@  rA  c                 0    t         |   t        ||       y rf   )r  r   r%   rI  s      r.   r   zServiceNotAvailable.__init__  s    3VTBr1   rK  r&  s   @r.   ri  ri    s)     1= Cs C# C Cr1   ri  c                       e Zd ZdZy)ChannelOpenErrora  SSH channel open error

       This exception is raised by connection handlers to report
       channel open failures.

       :param code:
           Channel open failure reason, taken from :ref:`channel open
           failure reason codes <ChannelOpenFailureReasons>`
       :param reason:
           A human-readable reason for the channel open failure
       :param lang:
           The language the reason is in
       :type code: `int`
       :type reason: `str`
       :type lang: `str`

    NrE  r+   r1   r.   rl  rl    s    r1   rl  c                       e Zd ZdZy)ChannelListenErrorzSSH channel listen error

       This exception is raised to report failures in setting up
       remote SSH connection listeners.

       :param details:
           Details of the listen failure
       :type details: `str`

    NrE  r+   r1   r.   rn  rn    s    	r1   rn  c                   0     e Zd ZdZefdedef fdZ xZS )PasswordChangeRequireda  SSH password change required

       This exception is raised during password validation on the
       server to indicate that a password change is required. It
       should be raised when the password provided is valid but
       expired, to trigger the client to provide a new password.

       :param prompt:
           The prompt requesting that the user enter a new password
       :param lang:
           The language that the prompt is in
       :type prompt: `str`
       :type lang: `str`

    promptrA  c                 F    t         |   d|z         || _        || _        y )NzPassword change required: %s)r  r   rq  rA  )r-   rq  rA  r$  s      r.   r   zPasswordChangeRequired.__init__  s$    7&@A	r1   rK  r&  s   @r.   rp  rp    s%      1= s #  r1   rp  c                   (     e Zd ZdZdef fdZ xZS )BreakReceivedzSSH break request received

       This exception is raised on an SSH server stdin stream when the
       client sends a break on the channel.

       :param msec:
           The duration of the break in milliseconds
       :type msec: `int`

    msecc                 8    t         |   d|z         || _        y )NzBreak for %s msec)r  r   ru  )r-   ru  r$  s     r.   r   zBreakReceived.__init__  s    ,t34	r1   )r=   r>   r?   r@   rB   r   r%  r&  s   @r.   rt  rt    s    	S  r1   rt  c                   (     e Zd ZdZdef fdZ xZS )SignalReceivedzSSH signal request received

       This exception is raised on an SSH server stdin stream when the
       client sends a signal on the channel.

       :param signal:
           The name of the signal sent by the client
       :type signal: `str`

    signalc                 8    t         |   d|z         || _        y )Nz
Signal: %s)r  r   ry  )r-   ry  r$  s     r.   r   zSignalReceived.__init__  s    ./r1   )r=   r>   r?   r@   rC   r   r%  r&  s   @r.   rx  rx    s    	s  r1   rx  c                   $     e Zd ZdZd fdZ xZS )SoftEOFReceivedzSSH soft EOF request received

       This exception is raised on an SSH server stdin stream when the
       client sends an EOF from within the line editor on the channel.

    c                 $    t         |   d       y )NzSoft EOF)r  r   )r-   r$  s    r.   r   zSoftEOFReceived.__init__  s    $r1   rN   )r=   r>   r?   r@   r   r%  r&  s   @r.   r|  r|    s    % %r1   r|  c                   J     e Zd ZdZdedededef fdZedefd       Z xZ	S )	TerminalSizeChangeda"  SSH terminal size change notification received

       This exception is raised on an SSH server stdin stream when the
       client sends a terminal size change on the channel.

       :param width:
           The new terminal width
       :param height:
           The new terminal height
       :param pixwidth:
           The new terminal width in pixels
       :param pixheight:
           The new terminal height in pixels
       :type width: `int`
       :type height: `int`
       :type pixwidth: `int`
       :type pixheight: `int`

    r   r   r   r   c                 v    t         |   d|d|d|d|d	       || _        || _        || _        || _        y )NzTerminal size change: (r-  r2  )r  r   r   r   r   r   )r-   r   r   r   r   r$  s        r.   r   zTerminalSizeChanged.__init__  s:    9> 	?
 "r1   r)   c                 ^    | j                   | j                  | j                  | j                  fS )z-Return terminal size as a tuple of 4 integers)r   r   r   r   r,   s    r.   	term_sizezTerminalSizeChanged.term_size   s#     zz4;;t~~EEr1   )
r=   r>   r?   r@   rB   r   rA   TermSizer  r%  r&  s   @r.   r  r    sG    (#c #3 ## ## # F8 F Fr1   r  r?  r@  rA  c                 d    	 t        |    ||      S # t        $ r t        | d|| fz  |      cY S w xY w)zBMap disconnect error code to appropriate DisconnectError exceptionz%s (error %d))_disc_error_mapr   rD  )r?  r@  rA  s      r.   construct_disc_errorr  5  sC    Mt$VT22 Mt_~%EtLLMs    //)r-  )rU   )r   )r   )r   )wb)r   rK   r)   N)r@   r   r   rer   r   r   pathlibr   r   randomr   typesr   typingr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   typing_extensionsr   r   	constantsr   r   r   r   r   r    r!   r"   r#   r$   r%   r   r  r  r  rB   	TermModesTermModesArgr  TermSizeArgr(   rF   rK   rO   DefTuple
MaybeAwaitr   ExcInfo
OptExcInforD   rC   
BytesOrStrBytesOrStrDictFilePathHostPortIPv4AddressIPv6Address	IPAddressIPv4NetworkIPv6Network	IPNetworkSockAddr_random	randrangecompiler   r   r   r  r]   rb   r   rl   rr   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   _ACMCoro_ACMWrapperFuncr   r   r  r
  r   r  r  	Exceptionr>  rD  rG  rN  rQ  rT  rW  rZ  r]  r`  rf  ri  rl  rn  rp  rt  rx  r|  r  r  r  r+   r1   r.   <module>r     sI  * 2   	   
 "   F F F F > > / # C K ? : O 1<<7CH		"c3#$D%S/834FH F2'x '*( * T]rB2y}$%

]#]MA
B7E"2334
5#:
j*,-hc?)'')>)>>?	)'')>)>>?	sCx%S#s(:";;<
 .	

=)4inE12E:/+f +c +S +F3 Fs FC F# F0(6" 0t 0 +,(gc3h/ ( ($'(07S0A( C 3 3 s s B<S <Y <	CS 	CY 	CH H H HRY H 
@ @U @ 
@ 
@ @ @% @ 
@ 
> > > > 
>  c S 7 7wsCx'8 7 7 7"?C ?C ?=s =u =	 	 	 v0DA'$- 8 C4()3D 112 ?43H ,$I2 Ic I3 I #I03I8<I$ $8H$ H { BI e .? ?&=_ =*E? E&?o ?&A A$7 7(L L&<O <&<? <&C/ C&u (
 
Y .I "Y "	%i 	%!F) !FJ /H, 3')= "6.')9OMs MC Ms M Mr1   