HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asyncssh/__pycache__/scp.cpython-310.pyc
o

�h��@shdZddlZddlZddlZddlmZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZmZddlmZmZmZmZmZddlmZmZdd	lmZdd
lmZmZddlmZddl m!Z!m"Z"m#Z#m$Z$dd
l m%Z%m&Z&ddl'm(Z(m)Z)m*Z*m+Z+m,Z,ddl'm-Z-m.Z.m/Z/m0Z0ddl'm1Z1m2Z2m3Z3e
r�ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:ede;e<e#dfZ=ee;e"fZ>eee=e>fe=e>fZ?dZ@Gdd�de�ZAGdd�de�ZBdddefdeeCde!dee;deDdeDd e<d!eCfd"d#�ZEd$e;d!eeFeFe;ffd%d&�ZGd$e;d!eeFeFffd'd(�ZHde?d!eede>eDffd)d*�ZId+dd,eDd-eDd.eDd/eDde>d!ed0fd1d2�ZJGd3d4�d4ejK�ZLGd5d6�d6ejM�ZNGd7d8�d8�ZOGd9d:�d:eO�ZPGd;d<�d<eO�ZQGd=d>�d>�ZR	dTdde@ddd?�d@ee?ee?fdAe?d.eDd/eDdBeFdCe2dDe1d!dfdEdF�ZSdGe$e+d$eLdHdIdJdKd!df
dLdM�ZTdGe$e+dNe<dOdIdPdKdQdKd!e$dfdRdS�ZUdS)UzSCP handlers�N)�PurePath)�
TracebackType)�
TYPE_CHECKING�
AsyncIterator�List�NoReturn�Optional)�Sequence�Tuple�Type�Union�cast)�Protocol�Self�)�DEFAULT_LANG)�FILEXFER_TYPE_REGULAR�FILEXFER_TYPE_DIRECTORY)�	SSHLogger)�
BytesOrStr�FilePath�HostPort�
MaybeAwait)�async_context_manager�plural)�	SFTPAttrs�SFTPGlob�SFTPName�
SFTPServer�SFTPServerFS)�	SFTPError�SFTPFailure�SFTPBadMessage�SFTPConnectionLost)�SFTPErrorHandler�SFTPProgressHandler�local_fs)�SSHServerChannel)�SSHClientConnection)�	SSHReader�	SSHWriterr(ic@s~eZdZdZdefdd�Zdeeedeedee	de
fdd	�Zd
edede
fdd
�Zde
dedefdd�Zddd�ZdS)�_SCPFileProtocolz0Protocol for accessing a file during an SCP copy�returnc���dS)z=Allow _SCPFileProtocol to be used as an async context managerN���selfr.r.�B/usr/local/CyberPanel/lib/python3.10/site-packages/asyncssh/scp.py�
__aenter__B�z_SCPFileProtocol.__aenter__�	_exc_type�
_exc_value�
_tracebackc�r-)�9Wait for file close when used as an async context managerNr.�r0r4r5r6r.r.r1�	__aexit__Er3z_SCPFileProtocol.__aexit__�size�offsetc�r-)zRead data from the local fileNr.)r0r:r;r.r.r1�readJr3z_SCPFileProtocol.read�datac�r-)zWrite data to the local fileNr.)r0r=r;r.r.r1�writeMr3z_SCPFileProtocol.writeNc�r-)zClose the local fileNr.r/r.r.r1�closePr3z_SCPFileProtocol.close�r,N)�__name__�
__module__�__qualname__�__doc__rr2rr�
BaseExceptionr�boolr9�int�bytesr<r>r?r.r.r.r1r+?s��
�r+c@s�eZdZdZededefdd��Zdeddfdd�Zded	ddd
fdd�Zdede	fd
d�Z
dede	fdd�Zdedee
fdd�Zdedd
fdd�Zedededefdd��Zd
S)�_SCPFSProtocolz6Protocol for accessing a filesystem during an SCP copy�pathr,cC�dS)z0Return the final component of a POSIX-style pathNr.)rJr.r.r1�basenameW�z_SCPFSProtocol.basenamerc�r-)z9Get attributes of a file or directory, following symlinksNr.�r0rJr.r.r1�stat[r3z_SCPFSProtocol.stat�attrsNc�r-)z%Set attributes of a file or directoryNr.)r0rJrPr.r.r1�setstat^r3z_SCPFSProtocol.setstatc�r-)zReturn if a path existsNr.rNr.r.r1�existsar3z_SCPFSProtocol.existsc�r-)z(Return if the path refers to a directoryNr.rNr.r.r1�isdirdr3z_SCPFSProtocol.isdircCrK)z5Read the names and attributes of files in a directoryNr.rNr.r.r1�scandirgrMz_SCPFSProtocol.scandirc�r-)zCreate a directoryNr.rNr.r.r1�mkdirjr3z_SCPFSProtocol.mkdir�modec�r-)zOpen a fileNr.)r0rJrVr.r.r1�openmr3z_SCPFSProtocol.open)rArBrCrD�staticmethodrHrLrOrQrFrRrSrrrTrUr�strr+rWr.r.r.r1rITsrIF�	exc_class�reasonrJ�fatal�
suppress_send�langr,cCsXt|t�r|jddd�}|r|d|jddd�}|||�}t|d|�t|d|�|S)z,Construct SCP version of SFTPError exception�utf-8�replace)�errorsz: r\r])�
isinstancerH�decode�setattr)rZr[rJr\r]r^�excr.r.r1�
_scp_errorrs

rf�argscCsDz|�dd�\}}}t|d�t|�|fWSty!ttd�d�w)z-Parse arguments to an SCP copy or dir requestN��zInvalid copy or dir request��splitrG�
ValueErrorrfr")rg�permissionsr:�namer.r.r1�_parse_cd_args�s���rocCs>z|��\}}}}t|�t|�fWStyttd�d�w)z%Parse argument to an SCP time requestzInvalid time requestNrj)rg�mtime�_�atimer.r.r1�
_parse_t_args�s�rsc�sD�ddlm}t|t�rttttf|�\}}nVt|t�r6t	j
dkr6|dd�tjvr6|dd�dkr6d}n8t|t�rHd|vrH|�
dd�\}}n&t|t�r_d|vr_|�
dd�\}}|�d�}nt|tttf�rjd}n|}d	}t|t�r�d
}||fi|��IdH}nt|t�r�d
}||i|��IdH}nd}ttd|�tt|�|fS)
z8Convert an SCP path into an SSHClientConnection and pathr)�connect�win32Nrh�:�:r_�.TFr()�rtrb�tupler
r
�_SCPConn�_SCPPathrY�sys�platform�string�
ascii_lettersrkrHrcrr)rJ�kwargsrt�conn�
close_connr.r.r1�_parse_path�s6�



�r�r��source�must_be_dir�preserve�recurse)�SSHReader[bytes]�SSHWriter[bytes]c
�s��t|t�r
t|�}t|t�r|�d�}d|rdnd|rdnd|r%dnd|r+dnd|}|j�d	��d
|dd��|j|dd
�IdH\}}}	||fS)zStart remote SCP serverr_sscp s-f s-t s-d �s-p s-r �sftpzStarting remote SCP, args: %s�N)�encoding)rbrrY�encode�logger�	get_child�info�open_session)
r�r�r�r�r�rJ�command�writer�readerrqr.r.r1�
_start_remote�s&�



�
�
��
�r�c@s:eZdZUdZeed<eed<eed<eed<eed<dS)�_SCPArgszSCP command line argumentsrJr�r�r�r�N)rArBrCrDrY�__annotations__rFr.r.r.r1r��s
r�csFeZdZdZd�fdd�Zdedefdd�Zd	edefd
d�Z	�Z
S)
�
_SCPArgParserzA parser for SCP argumentsr,Ncs�t�jdd�|jdd�}|jdddd�|jd	dd
d�|jdddd�|jd
ddd�|jdddd�|jdddd�|�d�dS)NF)�add_helpT)�requiredz-fr��
store_true)�dest�actionz-t�store_falsez-dr�z-pr�z-rr�z-v�verboserJ)�super�__init__�add_mutually_exclusive_group�add_argument)r0�group��	__class__r.r1r��sz_SCPArgParser.__init__�messagecCst|���N)rl)r0r�r.r.r1�error�sz_SCPArgParser.errorr�cCs|jt�|�dd�t�d�S)zParse an SCP commandrN)�	namespace)�
parse_args�shlexrkr�)r0r�r.r.r1�parse�sz_SCPArgParser.parser@)rArBrCrDr�rYrr�r�r��
__classcell__r.r.r�r1r��s
r�c	@s2eZdZdZ	d/ddddded	efd
d�Zdefd
d�Zde	e
ede	ede	edefdd�Z
edefdd��Zde	efdd�Zdeddfdd�Zdeddfdd�Zdeddfdd�Zd0d d!�Zd"eddfd#d$�Zdee	ee	effd%d&�Zd'edefd(d)�Zd"eddfd*d+�Zd1d,eddfd-d.�ZdS)2�_SCPHandlerzSCP handlerNFr�r�r�r��
error_handler�servercCs*||_||_||_||_|j�d�|_dS)Nr�)�_reader�_writer�_error_handler�_serverr�r��_logger)r0r�r�r�r�r.r.r1r�s
z_SCPHandler.__init__r,c�s�|S)z8Allow _SCPHandler to be used as an async context managerr.r/r.r.r1r2s�z_SCPHandler.__aenter__r4r5r6c�s�|��IdHdS)r7NF)r?r8r.r.r1r9s�z_SCPHandler.__aexit__cC�|jS�z)A logger associated with this SCP handler�r�r/r.r.r1r��z_SCPHandler.loggerc�s��|j�d�IdH}|dkr;|j��IdH}|r|�d�s%ttdddd��|dvr-||}tt|dd	�|d
kdd�S|j�d�dS)zWait for an SCP responserN��
�Connection lostT�r\r]�����zReceived SCP OK)	r�r<�readline�endswithrfr#r!r��debug1)r0�resultr[r.r.r1�await_responses���z_SCPHandler.await_responsergcGs,d�|�}|j�d|�|j�|d�dS)zSend an SCP requestr�zSending SCP request: %sr�N)�joinr�r�r�r>)r0rg�requestr.r.r1�send_request5s
z_SCPHandler.send_requestc�s&�|j|�|��IdH}|r|�dS)z+Send an SCP request and wait for a responseN)r�r�)r0rgrer.r.r1�make_request>s�
�z_SCPHandler.make_requestr=c�sJ�|j�dtt|�d��|j�|�|j��IdHt�d�IdHdS)zSend SCP file dataz
Sending %s�
SCP data byteNr)	r�r�r�lenr�r>�drain�asyncio�sleep)r0r=r.r.r1�	send_dataHs
�z_SCPHandler.send_datacCs|j�d�|j�d�dS)zSend an SCP OK responsezSending SCP OKr�N)r�r�r�r>r/r.r.r1�send_okQsz_SCPHandler.send_okrecCs�t|t�r|j�d�}n+t|t�r0|j�d�}tt|j�}|r/t|t	�r)|�d�}|d|7}nt	|��d�}tt
t|dd��}|j�
d|rHdnd|�|j�|rSdnd	d
|d�dS)
zSend an SCP error responser_s: r\FzSending SCP %serror: %s�fatal ry�r��scp: r�N)rbr r[r��OSError�strerrorr
r�filenamerYrF�getattrr�r�r�r>)r0rer[r�r\r.r.r1�
send_errorXs,



����
�z_SCPHandler.send_errorc�sx�|j��IdH}|s
dS|dd�|dd�}}|dvr*|j�d||�||fS|j�d|dkr4d	nd
|�||fS)zReceive SCP requestN)NNrr�r�zReceived SCP request: %s%szReceived SCP %serror: %sr�r�ry)r�r�r�r�)r0r�r�rgr.r.r1�recv_requestrs���z_SCPHandler.recv_request�nc�s0�|j�|�IdH}|j�dtt|�d��|S)zReceive SCP file dataNzReceived %sr�)r�r<r�r�rr�)r0r�r=r.r.r1�	recv_data�s�z_SCPHandler.recv_datacCspt|t�r
ttdddd�}t|dd�s|�|�|j�dt|��|j	r1t|dd�s1|�	|�dS|j
s6|�dS)	�Handle an SCP errorr�Tr�r]F�Handling SCP error: %sr\N)rb�BrokenPipeErrorrfr#r�r�r�r�rYr�r��r0rer.r.r1�handle_error�s
�
�z_SCPHandler.handle_error�	cancelledc�s\�|j�d�|r|jj��dS|jrtd|jj��d�n|j��|j�	�IdHdS)zClose an SCP sessionzStopping remote SCPr'rN)
r�r�r��channel�abortr�r
�exitr?�wait_closed)r0r�r.r.r1r?�s�
z_SCPHandler.close)NFr@)F)rArBrCrDr$rFr�rr2rrrErr9�propertyrr��	Exceptionr�rHr�r�r�r�r�r
r�rGr�r�r?r.r.r.r1r��s8��
�	��
�		

		r�cs�eZdZdZedddfdeddddd	ed
ededed
e	def�fdd�
Z
dededededdf
dd�Z
deddfdd�Zdedededdfdd�Zdedededdfdd�Zdedededdfd d!�Zdeddfd"d#�Z�ZS)$�
_SCPSourcezSCP handler for sending filesNF�fsr�r�r�r�r�r��
block_size�progress_handlerr�r�c

s4t��||||	�||_||_||_||_||_dSr�)r�r��_fs�	_preserve�_recurse�_block_size�_progress_handler)
r0r�r�r�r�r�r�r�r�r�r�r.r1r��s
z_SCPSource.__init__r�rPr:rJr,c�sN�|jdusJ�|jd@d�d|�d�}|�||�d�|j�|��IdHdS)zMake an SCP copy or dir requestNi��04o� �ascii)rmr�r�r�rL)r0r�rPr:rJrgr.r.r1�_make_cd_request�s�
�z_SCPSource._make_cd_requestc�sh�|j�dt|j|jd��|jdusJ�|jdusJ�|j�d|j�d�}|�d|�d��IdHdS)zMake an SCP time request�    Preserving attrs: %s)rrrpNz 0 z 0�Tr�)r�r�rrrrpr�r�)r0rPrgr.r.r1�_make_t_request�s��z_SCPSource._make_t_request�srcpath�dstpathc

�s��|jdusJ�|j�|d�IdH}|j}d}d}|j�d||�z|�d|||�IdH|jr<|dkr<|�||dd�||kr�t|||j�}|rO|d}	n,zt	t
|�||�IdH�}	|	sctt
d��Wnttfyz}
z|
}WYd}
~
nd}
~
ww|�|	�IdH|t|	�7}|jr�|�||||�||ks@W|��IdHn|��IdHw|r�|�|�t|dd	�n|��|��IdH}|p�|}|r�|�dS)
zSend a file over SCPN�rbrz  Sending file %s, size %d�Cr�zUnexpected EOFr]T)r:r�rWr�r�r�r��minr�r
rHr<rfr!r�r r�r�r?r�rdr�r�)
r0r�r�rP�file_objr:�	local_excr;�blocklenr=re�
remote_exc�	final_excr.r.r1�
_send_file�sT�
�
����� 
�z_SCPSource._send_filec�s��|j�d|�|�d|d|�IdH|j�|�2z$3dHW}tt|j�}|dvr*q|�t	�
||�t	�
||�|j�IdHq6|�d�IdH|j�d|�dS)zSend directory over SCPz  Starting send of directory %s�DrN)rxs..�Ez  Finished send of directory %s)
r�r�r�r�rTr
rHr��_send_files�	posixpathr�rPr�)r0r�r�rP�entryrnr.r.r1�	_send_dirs�
��
z_SCPSource._send_dirc
�s��z8|jr
|�|�IdH|jr"|jtkr"|�|||�IdHWdS|jtkr4|�|||�IdHWdStt	d|��t
ttfyT}z|�
|�WYd}~dSd}~ww)zSend files via SCPNzNot a regular file)r�r�r��typerrrrrfr!r�r rlr�)r0r�r�rPrer.r.r1r!s�
��z_SCPSource._send_filesc
�s �d}z�z=t|t�rt|�}t|t�r|�d�}|��IdH}|r#|�t|j��|�IdHD]}|�t	t
|j�d|j�IdHq.Wn$t
jyMd}Yn$ttfye}z|�|�WYd}~nd}~wwW|�|�IdHdSW|�|�IdHdSW|�|�IdHdS|�|�IdHw)zStart SCP transferFr_Nr�T)rbrrYr�r�rr��matchrr
rHr�rPr��CancelledErrorr�r r�r?)r0r�r�rernr.r.r1�run2s6�


�������&z_SCPSource.run)rArBrCrD�_SCP_BLOCK_SIZErIrFrGr%r$r�rHrr�r�rrrr|rr�r.r.r�r1r��s\��������

��
�
��
�
6�
�
�
�r�cs�eZdZdZedddfdeddddd	ed
ededed
ede	def�fdd�
Z
dedededdfdd�Zdededdfdd�Z
dededdfdd�Zdeddfdd�Z�ZS)�_SCPSinkzSCP handler for receiving filesNFr�r�r�r�r�r�r�r�r�r�r�r�cs:t��|||	|
�||_||_||_||_||_||_dSr�)r�r�r��_must_be_dirr�r�r�r�)r0r�r�r�r�r�r�r�r�r�r�r�r.r1r�Qs
z_SCPSink.__init__r�r�r:r,c
�sl�|j�|d�IdH}d}d}|j�d||�zs|��|jr+|dkr+|�||dd�||kr�t|||j�}|�|�IdH}|sIt	t
dddd��|smz|�||�IdHWntt
fyl}	z|	}WYd}	~	nd}	~	ww|t|�7}|jr~|�||||�||ks/W|��IdHn|��IdHw|��IdH}
|r�|�|�t|dd�n|��|
p�|}|r�|�dS)	zReceive a file via SCP�wbNrz  Receiving file %s, size %dr�Tr�r])r�rWr�r�r�r�r�r�r�rfr#r>r�r r�r?r�r�rd)r0r�r�r:rrr;rr=rerrr.r.r1�
_recv_file_sL������ 
�z_SCPSink._recv_filec�s��|js	ttd��|j�d|�|j�|�IdHr)|j�|�IdHs(ttd|��n	|j�	|�IdH|�
||�IdH|j�d|�dS)zReceive a directory over SCPz"Directory received without recursez"  Starting receive of directory %sN�Not a directoryz"  Finished receive of directory %s)r�rfr"r�r�r�rRrSr!rU�_recv_files)r0r�r�r.r.r1�	_recv_dir�s���z_SCPSink._recv_dirc
�s��|��t�}	|��IdH\}}|sdS|dusJ�z�|dvr+tt||dkdd��|dkr?|jr:t|�\|_|_|��nj|dkrJ|��WdS|dvr�zQt	|�\|_
}}t�||�}|j
�|�IdHrmt�||�}	n|}	|d	kr}|�||	�IdHn
|�||	|�IdH|jr�|j�d
|�|j
�|	|�IdHWt�}n	t�}wttd��Wnttfy�}
z|�|
�WYd}
~
nd}
~
wwq	)zReceive files over SCPTNr�r�r�r�r�CDrr�zUnknown request)r�rr�rfr!r�rsrrrprormr	r�r�rSrrr�r�rQr"r�r r�)r0r�r�rPr�rgr:rn�new_srcpath�new_dstpathrer.r.r1r�sZ��

��
����z_SCPSink._recv_filesc
�s�d}z{z4t|t�rt|�}t|t�r|�d�}|jr.|j�|�IdHs.|�tt	d|��n	|�
d|�IdHWn%tjyDd}Yn%t
ttfy]}z|�|�WYd}~nd}~wwW|�|�IdHdSW|�|�IdHdSW|�|�IdHdS|�|�IdHw)zStart SCP file receiveFr_Nrr�T)rbrrYr�rr�rSr�rfr!rr�rr�r rlr?)r0r�r�rer.r.r1r�s2�



�������&z_SCPSink.run)rArBrCrDrrIrFrGr%r$r�rHrrrr|rr�r.r.r�r1rNs@�����������
�27rc@s�eZdZdZeddfddddddddd	ed
edefdd
�Ze	de
fdd��Zdeddfdd�Z
dededeefdd�Zdededdfdd�Zd dd�Zd dd�ZdS)!�
_SCPCopierz'SCP handler for remote-to-remote copiesN�
src_readerr��
src_writerr��
dst_reader�
dst_writerr�r�r�cCs8t||�|_t||�|_|jj|_||_||_||_dSr�)r��_source�_sinkr�r�r�r�r�)r0rrrrr�r�r�r.r.r1r��s

z_SCPCopier.__init__r,cCr�r�r�r/r.r.r1r�r�z_SCPCopier.loggerrecCsPt|t�r
ttdddd�}|j�dt|��|jr&t|dd�s&|�|�dS|�)r�r�Tr�r�r\FN)	rbr�rfr#r�r�rYr�r�r�r.r.r1�
_handle_errors
�z_SCPCopier._handle_error�src�dstc
�s\�z|��IdH}|r|�|�|WS|��WdSty-}z|WYd}~Sd}~ww)z6Forward an SCP response between two remote SCP serversN)r�r�r�r�)r0r#r$rer.r.r1�_forward_responses�
��z_SCPCopier._forward_responserJr:c	�s��|j�d||�d}|jr|dkr|�||dd�||krWt|||j�}|j�|�IdH}|s9ttdddd��|j	�
|�IdH|t|�7}|jrS|�||||�||ks|�|j|j	�IdH}|�|j	|j�IdH}|pp|}|rz|�
|�dSdS)z1Copy a file from one remote SCP server to anotherz  Copying file %s, size %drNr�Tr�)r�r�r�r�r�r r�rfr#r!r�r�r%r")	r0rJr:r;rr=�
source_exc�sink_excrer.r.r1�
_copy_file+s.����z_SCPCopier._copy_filec
�s��|�|j|j�IdH}|r|�|�g}g}t�}	|j��IdH\}}|s)dS|dus/J�|j�||�|dvrItt||dkd�}|�|�q|�|j|j�IdH}|r\|�|�q|dvr�z>t	|�\|_
}}|dkr�d�||g�}	|�|	|�IdH|j
�d	|�n|�|�|�|�|j
�d
d�|��Wt�}n8t�}w|dkr�|r�|j
�dd�|��|��|��}|j
�d	|�ndS|d
kr�t|�\|_|_nttd��q)z)Copy files from one SCP server to anotherNTr�r�)r\rr��/r�z  Starting copy of directory %srz  Finished copy of directory %sr�zUnknown SCP action)r%r!r r"rr�r�rfr!rormr�r(r�r��append�poprsrrrpr")
r0re�pathlist�attrlistrPr�rgr:rnrJr.r.r1�_copy_filesKs`�




���
�z_SCPCopier._copy_filesc
�s�d}zmz	|��IdHWn$tjyd}Yn.ttfy1}z|�|�WYd}~n/d}~wwW|j�|�IdH|j�|�IdHdSW|j�|�IdH|j�|�IdHdSW|j�|�IdH|j�|�IdHdS|j�|�IdH|j�|�IdHw)z#Start SCP remote-to-remote transferFNT)	r.r�rr�r r"r r?r!)r0r�rer.r.r1r�s*�������z_SCPCopier.runr@)rArBrCrDrrGr%r$r�r�rr�r�r"r�rr%rHr(r.rr.r.r.r1r�s:������
��
�
 @r)r�r�r�r�r��srcpathsr�r�r�r�c�s.�t|tttf�st|t�rt|�dkr|g}t|�dk}t|fi|��IdH\}	}}
z�|D]�}t|fi|��IdH\}}}
z�|rq|	rqt|d||||�IdH\}}t|	d||||�IdH\}}t|||||||�}|�	�IdHnM|r�t|d||||�IdH\}}t
t||||||||�	}|�	|�IdHn(|	r�t|	d||||�IdH\}}tt|||||||�}|�	|�IdHnt
d��W|
r�|dus�J�|��|��IdHq.|
r�|dus�J�|��|��IdHwwW|
r�|	dus�J�|	��|	��IdHdSdS|
�r|	du�s
J�|	��|	��IdHww)a�Copy files using SCP

       This function is a coroutine which copies one or more files or
       directories using the SCP protocol. Source and destination paths
       can be `str` or `bytes` values to reference local files or can be
       a tuple of the form `(conn, path)` where `conn` is an open
       :class:`SSHClientConnection` to reference files and directories
       on a remote system.

       For convenience, a host name or tuple of the form `(host, port)`
       can be provided in place of the :class:`SSHClientConnection` to
       request that a new SSH connection be opened to a host using
       default connect arguments. A `str` or `bytes` value of the form
       `'host:path'` may also be used in place of the `(conn, path)`
       tuple to make a new connection to the requested host on the
       default SSH port.

       Either a single source path or a sequence of source paths can be
       provided, and each path can contain '*' and '?' wildcard characters
       which can be used to match multiple source files or directories.

       When copying a single file or directory, the destination path
       can be either the full path to copy data into or the path to an
       existing directory where the data should be placed. In the latter
       case, the base file name from the source path will be used as the
       destination name.

       When copying multiple files, the destination path must refer to
       a directory. If it doesn't already exist, a directory will be
       created with that name.

       If the destination path is an :class:`SSHClientConnection` without
       a path or the path provided is empty, files are copied into the
       default destination working directory.

       If preserve is `True`, the access and modification times and
       permissions of the original files and directories are set on the
       copied files. However, do to the timing of when this information
       is sent, the preserved access time will be what was set on the
       source file before the copy begins. So, the access time on the
       source file will no longer match the destination after the
       transfer completes.

       If recurse is `True` and the source path points at a directory,
       the entire subtree under that directory is copied.

       Symbolic links found on the source will have the contents of their
       target copied rather than creating a destination symbolic link.
       When using this option during a recursive copy, one needs to watch
       out for links that result in loops. SCP does not provide a
       mechanism for preserving links. If you need this, consider using
       SFTP instead.

       The block_size value controls the size of read and write operations
       issued to copy the files. It defaults to 256 KB.

       If progress_handler is specified, it will be called after each
       block of a file is successfully copied. The arguments passed to
       this handler will be the relative path of the file being copied,
       bytes copied so far, and total bytes in the file being copied. If
       multiple source paths are provided or recurse is set to `True`,
       the progress_handler will be called consecutively on each file
       being copied.

       If error_handler is specified and an error occurs during the copy,
       this handler will be called with the exception instead of it being
       raised. This is intended to primarily be used when multiple source
       paths are provided or when recurse is set to `True`, to allow
       error information to be collected without aborting the copy of the
       remaining files. The error handler can raise an exception if it
       wants the copy to completely stop. Otherwise, after an error, the
       copy will continue starting with the next file.

       If any other keyword arguments are specified, they will be passed
       to the AsyncSSH connect() call when attempting to open any new SSH
       connections needed to perform the file transfer.

       :param srcpaths:
           The paths of the source files or directories to copy
       :param dstpath: (optional)
           The path of the destination file or directory to copy into
       :param preserve: (optional)
           Whether or not to preserve the original file attributes
       :param recurse: (optional)
           Whether or not to recursively copy directories
       :param block_size: (optional)
           The block size to use for file reads and writes
       :param progress_handler: (optional)
           The function to call to report copy progress
       :param error_handler: (optional)
           The function to call when an error occurs
       :type preserve: `bool`
       :type recurse: `bool`
       :type block_size: `int`
       :type progress_handler: `callable`
       :type error_handler: `callable`

       :raises: | :exc:`OSError` if a local file I/O error occurs
                | :exc:`SFTPError` if the server returns an error
                | :exc:`ValueError` if both source and destination are local

    rhrNTFzLocal copy not supported)rbrHrYrrzr�r�r�rrrr&r�rlr?r�)r/r�r�r�r�r�r�r�r��dstconn�	close_dstr��srcconn�	close_srcrrrr�copierr�r��sinkr�r.r.r1�scp�s��l�����
��������*
��r6�sftp_serverr�r�r�r�c
�s��t�|�r|IdH}t|�}|jr t||||j|jddd�}nt||||j|j|jddd�}z|�	|j
�IdHW|��}t�|�rJ|IdHdSdS|��}t�|�r[|IdHww)z(Run an SCP server to handle this requestNFT)r�r�)�inspect�isawaitablerr�r�r�r�rr�rrJr�)r7rgr�r�r��handlerr�r.r.r1�_scp_handlerBs,�

��
��
�r;r��stdin�stdout�stderrc
Cs�zt��|�}Wn<tyD}z0t�|�r|��|j�dt|��|�	dt|��
d�d�td|j��
d�WYd}~dSd}~ww|j�d|d	d����t||||�S)
z*Return a handler for an SCP server sessionzError starting SCP server: %sr�r_r�r'rNzStarting SCP server, args: %sr�)r�r�rlr8�iscoroutiner?r�r�rYr>r�r
r�r��stripr;)r7r�r<r=r>rgrer.r.r1�run_scp_server_s
��	rAr�)VrD�argparser�r8�pathlibrr	r�rr}�typesr�typingrrrrrr	r
rrr
�typing_extensionsrr�	constantsrrr�loggingr�miscrrrrrrr�rrrrrr r!r"r#r$r%r&r�r'�
connectionr(�streamr)r*rHrYr{r|�_SCPConnPathrr+rIr�rFrfrGrorsr�r��	Namespacer��ArgumentParserr�r�r�rrr6r;rAr.r.r.r1�<module>s������
�

�
'����
�
1 ')��������
�
(���
�����