https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/sshpeer.cpython-310.pyc
o

�]Lb@Z�@s�ddlmZddlZddlZddlmZddlmZddlm	Z	mZm
Z
mZmZm
Z
ddlmZmZmZdd	�Zddd�ZGd
d�de�Zdd�Zddd�Zdd�Zdd�ZGdd�dej�Zd dd�Zd!dd�ZdS)"�)�absolute_importN�)�_)�getattr)�error�pycompat�util�wireprototypes�wireprotov1peer�wireprotov1server)�procutil�
stringutil�urlutilcCs(|s|St�d|�r|Sd|�dd�S)z=quote a string for the remote shell ... which we assume is shs[a-zA-Z0-9@%_+=:,./-]*$s'%s'�'s'\'')�re�match�replace)�s�r�3/usr/lib/python3/dist-packages/mercurial/sshpeer.py�_serverquotes
rFcCsV|r#|js%t�|�}|r'|r|jn|j}|��D]}|td�|d�qdSdSdSdS)zYdisplay all data currently available on pipe as remote output.

    This is non blocking.�remote: �
N)�closedr�readpipe�warn�status�
splitlinesr)�ui�piperr�display�lrrr�_forwardoutput's

�r"c@sfeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
dd�Zedd��Z
dd�ZdS)�
doublepipea3Operate a side-channel pipe in addition of a main one

    The side-channel pipe contains server output to be forwarded to the user
    input. The double pipe will behave as the "main" pipe, but will ensure the
    content of the "side" pipe is properly processed while we wait for blocking
    call on the "main" pipe.

    If large amounts of data are read from "main", the forward will cease after
    the first bytes start to appear. This simplifies the implementation
    without affecting actual output of sshpeer too much as we rarely issue
    large read for data not yet emitted by the server.

    The main pipe is expected to be a 'bufferedinputpipe' from the util module
    that handle all the os specific bits. This class lives in this module
    because it focus on behavior specific to the ssh protocol.cCs||_||_||_dS�N)�_ui�_main�_side)�selfr�main�siderrr�__init__Ds
zdoublepipe.__init__cCspt|jtj�r
|jjr
dS|j��|j��g}zt�|�}Wnty)|}Ynw|j��|v|j��|vfS)z�wait until some data are available on main or side

        return a pair of boolean (ismainready, issideready)

        (This will only wait for data if the setup is supported by `util.poll`)
        )TT)	�
isinstancer&r�bufferedinputpipe�	hasbuffer�filenor'�poll�NotImplementedError)r(�fds�actrrr�_waitIs���zdoublepipe._waitcCs|�d|�S)Nswrite��_call)r(�datarrr�write_�zdoublepipe.writecC�*|�d|�}|dkr|st|j|j�|S)Nsreadr�r6r"r%r'�r(�size�rrrr�readb�zdoublepipe.readcCr:)Nsunbufferedreadrr;r<rrr�unbufferedreadmr@zdoublepipe.unbufferedreadcCs
|�d�S)Nsreadliner5�r(rrr�readlinex�
zdoublepipe.readlineNcCsn|dur|r
|jjrt|j|j�dS	|��\}}|r#t|j|j�|r6t|j|�}|dur2|�S||�Sq)zBcall <methname> on "main", forward output of "side" while blockingN�)r&rr"r%r'r4r)r(�methnamer7�	mainready�	sideready�methrrrr6{s�zdoublepipe._callcC�
|j��Sr$)r&�closerBrrrrK�rDzdoublepipe.closecCs|jjSr$)r&rrBrrrr�szdoublepipe.closedcCrJr$)r&�flushrBrrrrL�rDzdoublepipe.flushr$)�__name__�
__module__�__qualname__�__doc__r+r4r8r?rArCr6rK�propertyrrLrrrrr#3s

r#c	Cs�d}|r
|js
d}|��|r|jsd}|��|r>|js>d}z|D]
}|�td�|�q"Wnttfy9Ynw|��|rM|durO|�d|�dSdSdS)z)Clean up pipes used by an SSH connection.FTrNs.missing close on SSH connection created at:
%s)rrKrr�IOError�
ValueError�	develwarn)r�pipei�pipeo�pipeer�didsomethingr!rrr�
_cleanuppipes�s(


���rYc	CsVd||t�dt|�t|�f�f}|�d|�tj|d|d�\}}}	}
|
|||	fS)z�Create an SSH connection to a server.

    Returns a tuple of (process, stdin, stdout, stderr) for the
    spawned process.
    �%s %s %ss%s -R %s serve --stdio�running %s
r)�bufsize�env)r�
shellquoter�debug�popen4)r�sshcmd�args�	remotecmd�path�sshenv�cmd�stdin�stdout�stderr�procrrr�_makeconnection�s���	rkcCs6dh}dd�tj�tj�D�}|�dd�|��|S)zwReturn list of capabilities of this client.

    Returns a list of capabilities that are supported by this client.
    spartial-pullcSsg|]}|��j�qSr)�wireprotosupport�name)�.0�errr�
<listcomp>�s��z'_clientcapabilities.<locals>.<listcomp>scomp=%s�,)r�compengines�supportedwireengines�
CLIENTROLE�add�join)�protoparams�compsrrr�_clientcapabilities�s�rycs���fdd�}��dd�}t�tt����}z6dd}ddd	t|�|g}|r5��d
���dt|����d���d
�|�d�	|��|�
�WntyX|�Ynwtj
}	t�dt�|��}
ddg}d}|dr�|r�z?|��}
t��dd�|
�|
�}|r�|�d�}	��d|	�Wn4|ddkr�|
dkr�Wn(|
r���d|
�|�|
�|d8}Wnty�|�Ynw|dr�|sr|�t�}|	tj
kr�t|�D]}
|
�d�r�|�|
dd��d�d���nq�|s�|�t��dd�|	|fS)Ncs0t��dd�td�}��dd�}tj||d��)NT�rs#no suitable response from remote hg�uisssherrorhint��hint)r"r�configr�	RepoError)�msgr}�rirrr�badresponse�sz&_performhandshake.<locals>.badresponse�devel�debug.peer-requests%s-%s)�(0000000000000000000000000000000000000000r�shello
sbetween
s	pairs %d
s"devel-peer-request: hello+between
s&devel-peer-request:   pairs: %d bytes
ssending hello command
ssending between command
rEs^upgraded %s (.*)$sdummyi����Trzrsprotocol upgraded to %s
s1
rrs
capabilities:�:)�
configboolr�sysbytes�str�uuid�uuid4�lenr_r8rvrLrRr	�SSHV1r�compiler
�reescaperCr"r�group�append�set�reversed�
startswith�update�split)rrgrhrir��
requestlog�token�pairsarg�	handshake�	protoname�
reupgraded�lines�	max_noiser!�m�capsrr�r�_performhandshake�sn@
�



�



��

 �
r�c@s�eZdZ	d-dd�ZdhZdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zd.dd�Z
dd�Zd/dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd/d+d,�ZdS)0�	sshv1peerTc		Csh||_||_||_|rt|t�|�|�}t|||�}||_||_||_||_	||_
d�t�d��|_
dS)a�Create a peer from an existing SSH connection.

        ``proc`` is a handle on the underlying SSH process.
        ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio
        pipes for that process.
        ``caps`` is a set of capabilities supported by the remote.
        ``autoreadstderr`` denotes whether to automatically read from
        stderr and to forward its output.
        rErN)�_urlr�_subprocessr#rr-�_pipeo�_pipei�_pipee�_caps�_autoreadstderrrv�getstackframes�
_initstack)	r(r�urlrjrgrhrir��autoreadstderrrrrr+wszsshv1peer.__init__sbatchcC�|jSr$)r�rBrrrr���z
sshv1peer.urlcCsdSr$rrBrrr�local��zsshv1peer.localcCs|Sr$rrBrrr�peer�r�zsshv1peer.peercCsdS)NTrrBrrr�canpush�r�zsshv1peer.canpushcCs|��dSr$��_cleanuprBrrrrK�r9zsshv1peer.closecCr�r$)r�rBrrr�capabilities�r�zsshv1peer.capabilitiescCst|j|j�dSr$)r"rr�rBrrr�_readerr��zsshv1peer._readerrcCs|��|�r$r�)r(�	exceptionrrr�_abort�szsshv1peer._abortNcCst|j|j|j|j|d�dS�Nrz)rYrr�r�r�)r(rrrrr��szsshv1peer._cleanupcCs|j|jd�dSr�)r�r�rBrrr�__del__�r�zsshv1peer.__del__FcCs�|jjrL|j�dd�rL|jj}d}|||�t|���D].\}}t|t�s3||d|t|�f�qt|���D]\}}	||d||t|	�f�q9q|j�d|�|j	�
d|�tj|\}
}|�
�}i}
|D]}|dkrw||
d<n
|||
|<||=qktt�|
��D]8\}}|j	�
d	|t|�f�t|t�r�t�|�D]\}}	|j	�
d	|t|	�f�|j	�
|	�q�q�|j	�
|�q�|j	��|r�|��}t�|j|�S|jS)
Nr�r�sdevel-peer-request: %s
s  %s: %d bytess  %s-%s: %dssending %s command
s%s
�*s%s %d
)r�	debugflagr�r_�sorted�itemsr,�dictr�r�r8r�commandsr�r�	iteritemsrL�
_getamountr�cappedreaderr�)r(rfrb�framed�dbg�line�key�value�dk�dv�_func�names�keys�wireargs�k�v�amountrrr�_sendrequest�sH�
�
�
zsshv1peer._sendrequestcK� t�|�}|j||||jvd�S�N�r��r�byteskwargsr��_FRAMED_COMMANDS�r(rfrbrrr�_callstream��
zsshv1peer._callstreamcKr�r�r�r�rrr�_callcompressable�r�zsshv1peer._callcompressablecKst�|�}|j||dd���S)NTr�)rr�r�r?r�rrrr6�s
zsshv1peer._callcsn|j|fi|��}|rd|fSt�fdd�d�D]}|�|�q|jddd�|��}|r1d|fS|��dfS)NrEc�
��d�S�Ni�r?r��fprr�<lambda>�
z%sshv1peer._callpush.<locals>.<lambda>T�rL)r6�iter�_writeframed�_readframed�r(rfr�rbr>�drr�r�	_callpush�szsshv1peer._callpushcs^|j|fi|��}|rt�td�|��t�fdd�d�D]}|�|�q|jddd�|jS)Nsunexpected remote reply: %scr�r�r�rr�rrr�r�z-sshv1peer._calltwowaystream.<locals>.<lambda>rETr�)r6r�Abortrr�r�r�r�rr�r�_calltwowaystreamszsshv1peer._calltwowaystreamc	Cs~|j��}|dkr|jr|��td�}|�tj|d��|jr$|��zt|�WSt	y>|�t�
td�|��YdSw)Nrscheck previous remote outputr|sunexpected response:)r�rCr�r�rr�r�OutOfBandError�intrS�
ResponseError)r(r!r�rrrr�!s

�zsshv1peer._getamountcCs|��}|sdS|j�|�S)NrE)r�r�r?)r(r=rrrr�/szsshv1peer._readframedcCsH|j�dt|��|r|j�|�|r|j��|jr"|��dSdS)Ns%d
)r�r8r�rLr�r�)r(r7rLrrrr�6s
�zsshv1peer._writeframed�Tr$�F)rMrNrOr+r�r�r�r�r�rKr�r�r�r�r�r�r�r�r6r�r�r�r�r�rrrrr�vs0
�"�

-r�Tc	
Cs�zt||||�\}}Wntyt||||dd��w|tjkr.t||||||||d�St||||dd�t�td�|��)a�Make a peer instance from existing pipes.

    ``path`` and ``proc`` are stored on the eventual peer instance and may
    not be used for anything meaningful.

    ``stdin``, ``stdout``, and ``stderr`` are the pipes connected to the
    SSH server's stdio handles.

    This function is factored out to allow creating peers that don't
    actually spawn a new process. It is useful for starting SSH protocol
    servers and clients via non-standard means, which can be useful for
    testing.
    Nrz)r�s#unknown version of SSH protocol: %s)	r��	ExceptionrYr	r�r�rrr)	rrdrjrgrhrir�r�r�rrr�makepeer@s*�
�
�r�c	Cs�tj|ddd�}|jdks|jr|jdurt�td�|��t�|�|j	dur/t�td���|�
dd�}|�
dd�}t|�d	��}t
�|�}	|jpKd
}
t
�||j|j|j�}|r�|rbt�td���d||t
�d
t|�t|
�f�f}|�d|�|j|d|	d�}
|
dkr�t�td���t|||||
|	�\}}}}t||||||�}d|��vr�z|jdd�tt���d�W|Sty�|��t�td���w|S)ziCreate an SSH peer.

    The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
    F)�
parsequery�
parsefragmentssshNscouldn't parse location %sspassword in URL not supportedr{s	remotecmdssshenv�.s8cannot create remote SSH repositories with extra optionsrZs
%s init %sr[ssshpeer)�
blockedtag�environrscould not create remote repos	protocaps� )r�scapability exchange failed)rr��scheme�hostrdrrr�checksafessh�passwdr~r��configitemsr�shellenviron�sshargs�user�portr^rr_�systemrkr�r�r6rvr�ryrRr�)rrd�create�intents�
createopts�urarc�	sshaddenvre�
remotepathrbrf�resrjrgrhrir�rrr�instancefs^



���������rr�r$r�)NN)�
__future__rrr��i18nrrr�rrr	r
r�utilsrr
rrr"�objectr#rYrkryr��wirepeerr�r�rrrrr�<module>s& 
	d

K&

https://t.me/RX1948 - 2025