403Webshell
Server IP : 77.50.203.18  /  Your IP : 192.168.0.10
Web Server : Apache/2.4.62 (CentOS Stream) OpenSSL/3.5.7 mpm-itk/2.4.7-04 PHP/8.4.23
System : Linux web2 5.14.0-722.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 6 09:07:51 UTC 2026 x86_64
User : warsnews.ru ( 1001)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.9/site-packages/cockpit/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.9/site-packages/cockpit/__pycache__/router.cpython-39.pyc
a

7(=j�2�@s�ddlZddlZddlZddlmZmZmZddlmZm	Z	ddl
mZmZm
Z
e�e�ZGdd�d�ZGdd	�d	�ZGd
d�de�ZGdd
�d
�ZGdd�d�ZGdd�de
�ZdS)�N)�Dict�List�Optional�)�
JsonObject�	JsonValue)�CockpitProblem�CockpitProtocolError�CockpitProtocolServerc@s.eZdZdZdd�Zdd�Zdd�dd	�ZdS)
�ExecutionQueueawTemporarily delay calls to a given set of class methods.

    Functions by replacing the named function at the instance __dict__
    level, effectively providing an override for exactly one instance
    of `method`'s object.
    Queues the invocations.  Run them later with .run(), which also reverses
    the redirection by deleting the named methods from the instance.
    cCs*t��|_||_|jD]}|�|�qdS�N)�collections�deque�queue�methods�_wrap)�selfr�method�r�2/usr/lib/python3.9/site-packages/cockpit/router.py�__init__s

zExecutionQueue.__init__cs t�j�jj��fdd��dS)Ncs�j��|f�Sr)r�append)�args�rrrr�<lambda>%�z&ExecutionQueue._wrap.<locals>.<lambda>)�setattr�__self__�__func__�__name__)rrrrrr!szExecutionQueue._wrapN��returncCsJt�dt|j��|jD]\}}||�q|jD]}t|j|jj�q0dS)Nz.ExecutionQueue: Running %d queued method calls)	�logger�debug�lenrr�delattrrrr)rrrrrr�run's


zExecutionQueue.run)r�
__module__�__qualname__�__doc__rrr&rrrrrsrc@s�eZdZUded<dZeeed<dd�dd�Zdd�d	d
�Zdd�dd�Z	dd�d
d�Z
eeedd�dd�Z
eedd�dd�Zddedd�dd�Zeedd�dd�Zeededd�dd�Zd"dedd�d d!�ZdS)#�Endpoint�Router�routerN� _Endpoint__endpoint_frozen_queue�r,cCs|�|�||_dSr)�add_endpointr,�rr,rrrr4s
zEndpoint.__init__r cCs4|jdusJ�t�d|�t|j|j|jh�|_dS)NzFreezing endpoint %s)r-r"r#r�do_channel_control�do_channel_data�do_kill�rrrr�freeze_endpoint8szEndpoint.freeze_endpointcCs.|jdusJ�t�d|�|j��d|_dS)NzThawing endpoint %s)r-r"r#r&r4rrr�
thaw_endpoint=s
zEndpoint.thaw_endpointcCst�dSr��NotImplementedErrorr4rrr�do_closeDszEndpoint.do_close��channel�command�messager!cCst�dSrr7)rr;r<r=rrrr1GszEndpoint.do_channel_control�r;�datar!cCst�dSrr7�rr;r?rrrr2JszEndpoint.do_channel_data�
str | None��host�groupr=r!cCst�dSrr7)rrCrDr=rrrr3MszEndpoint.do_killcCs|j�||�dSr)r,Zwrite_channel_datar@rrr�send_channel_dataQszEndpoint.send_channel_data�JsonObject | None)r;r<�msg�kwargsr!cKsD|jj|f||d�|��|dkr@|jj|�|�|j�|�dS)N�r;r<�close)r,�
write_control�	endpoints�remove�drop_channel)rr;r<rGrHrrr�send_channel_controlTszEndpoint.send_channel_control)rGrHr!cKs|jj||fi|��dSr)r,�shutdown_endpoint)rrGrHrrrrP\szEndpoint.shutdown_endpoint)N)rr'r(�__annotations__r-rrrr5r6r9�strrr1�bytesr2r3rErrOrPrrrrr*0s
�r*c@seZdZdS)�RoutingErrorN)rr'r(rrrrrT`srTc@sFeZdZUded<dd�dd�Zeeed�dd�Zd	d
�dd�Z	d	S)
�RoutingRuler+r,r.cCs
||_dSrr.r0rrrrgszRoutingRule.__init__��optionsr!cCst�dS)a]Check if a routing rule applies to a given 'open' message.

        This should inspect the options dictionary and do one of the following three things:

            - return an Endpoint to handle this channel
            - raise a RoutingError to indicate that the open should be rejected
            - return None to let the next rule run
        Nr7)rrWrrr�
apply_rulejs	zRoutingRule.apply_ruleNr cCst�dSrr7r4rrr�shutdownuszRoutingRule.shutdown)
rr'r(rQrrrr*rXrYrrrrrUds
rUc@s�eZdZUded<ded<eed<ded<ded	<ed
d�dd
�Zed
d�dd�Zed
d�dd�Zd
d�dd�Z	dd�Z
d
d�dd
d�dd�Zd
S)�SessionControllerr+r,zset[str]�channels�timeoutzfloat | None�deadlinezasyncio.TimerHandle | None�timerN)r\r!cCs$t�|_||_d|_d|_||_dSr)�setr[r\r]r^r,)rr\r,rrrr�s
zSessionController.__init__�r;r!cCs(|j�|�|jdur$|j|jd�dS�N�r\)r[�addr]�_updater\�rr;rrr�add_channel�s
zSessionController.add_channelcCs"|j�|�|js|jdd�dS)Nrrb)r[rMrdrerrr�remove_channel�sz SessionController.remove_channelr cCs|jdur|j|jd�dSra)r]rdr\r4rrr�reset_session_timeout�s
z'SessionController.reset_session_timeoutcKs(|jD]}|jjf||d�|��qdS)NrI)r[r,rK)rr<rH�crrr�
_send_message�s
zSessionController._send_messagerb�
int | NonecCs�|jdur|j��d|_t��}|��}|dkr:d|_n|durL|||_|jdurZdS|j|}t�d|�|dkr~d}nT|dkr�t|�}|j	d|d�t
|dd�}n&|dkr�|�	d�d}n|j��dS|j|}||ks�J�|�
||j�|_dS)	Nrz.SessionController: update with %.2fs remaining�Z	countdown)�counterri����Zlogout)r^�cancel�asyncio�get_running_loop�timer]r"r#�roundrj�maxr,rJZcall_atrd)rr\ZloopZnowZ	remainingZnext_remainingrmZwake_atrrrrd�s6







zSessionController._update)rr'r(rQ�intrrRrfrgrhrjrdrrrrrZys
rZc@s:eZdZUeeed<eeefed<ded<e	j
ed<ded<dZeed	<d
d�eedd
�dd�Z
ed�dd�Zeed�dd�Zed
d�dd�Zed
d�dd�Zd2eded
d�dd�Zd d ed
d!�d"d#�Zeeed
d$�d%d&�Zeed
d'�d(d)�Zed�d*d+�Zd
Zee	jed,<eed
d-�d.d/�Zd
d�d0d1�Zd
S)3r+�
routing_rules�
open_channelszdict[Endpoint, set[str]]rL�no_endpointszSessionController | None�session_controllerF�_eofN)�session_timeoutrk)rurzcCsT|D]
}||_q||_i|_i|_t��|_|j��d|_|durPt	||�|_dSr)
r,rurvrLro�Eventrwr_rxrZ)rrurz�rulerrrr�s

zRouter.__init__r cCsiS)z7Used by the 'info' channel.  Gets overridden in Bridge.rr4rrr�info�szRouter.inforVcCsT|jD]6}t�d|�|�|�}|durt�d|�|Sqt�d�td��dS)Nz  applying rule %sz    resulting endpoint is %sz  No rules matchedz
not-supported)rur"r#rXrT)rrWr|�endpointrrr�check_rules�s



zRouter.check_rulesr`cCsDz|j�|�t�d|�Wn"ty>t�d||j�Yn0dS)Nzrouter dropped channel %sz.trying to drop non-existent channel %s from %s)rv�popr"r#�KeyError�errorrerrrrN�s
zRouter.drop_channel)r~r!cCst�|j|<|j��dSr)r_rLrw�clear)rr~rrrr/�szRouter.add_endpointrF)r~rGrHr!cKs�|j�|�}t�d|||�|D]&}|j|fd|d�|��|�|�q |jsX|j��|jr�t�d|j�|js�|j	r�t�d�|j	�
�dS)Nz'shutdown_endpoint(%s, %s) will close %srJ�r<r;�  endpoints remaining: %rz  close transport)rLr�r"r#rKrNrwr_ryZ	transportrJ)rr~rGrHr[r;rrrrP�s

zRouter.shutdown_endpointrArBcCs:t|j�}t�d||t|��|D]}|�|||�q"dS)Nz+do_kill(%s, %s).  Considering %d endpoints.)r_rLr"r#r$r3)rrCrDr=rLr~rrrr3
s
zRouter.do_killr:c
Cs�|jdurtd��|dkr�||jvr,td��z"t�d||�d��|�|�}Wn:ty�}z"|j|�	�d|d�WYd}~dSd}~00||j|<|j
|�|�n$z|j|}Wnty�YdS0|�
|||�dS)Nz,channel control message received before init�openzchannel is already openz5Trying to find endpoint for new channel %s payload=%sZpayloadrJr�)�	init_hostr	rvr"r#�getrrTrKZ	get_attrsrLrcr�r1)rr;r<r=r~�excrrr�channel_control_receiveds$


zRouter.channel_control_receivedr>cCsF|jdurtd��z|j|}Wnty4YdS0|�||�dS)Nz)channel data message received before init)r�r	rvr�r2)rr;r?r~rrr�channel_data_received.s
zRouter.channel_data_receivedcCsFt�d|�t|j�}|D]}|��qd|_t�d|j�t|j�S)Nzeof_received(%r)Tr�)r"r#r_rLr9ry�bool)rrLr~rrr�eof_received9s

zRouter.eof_received�_communication_done)r�r!cCs>|js|��|jdur:|dur.|j�d�n|j�|�dSr)ryr�r�Z
set_resultZ
set_exception)rr�rrr�	do_closedFs
zRouter.do_closedc	�s||jdusJ�t����|_zBz|jIdHWnttfyDYn0Wd|_|j��IdHnd|_|j��IdH0dS)zNWait until communication is complete on the router and all endpoints are done.N)r�rorpZ
create_future�BrokenPipeError�ConnectionResetErrorrw�waitr4rrr�communicateQs�zRouter.communicate)N) rr'r(rrUrQrrRr*ror{ryr�rrr}rrNr/rrPr3r�rSr�r�r�rZFuture�	Exceptionr�r�rrrrr+�s&

r+)ror
Zlogging�typingrrrZjsonutilrrZprotocolrr	r
Z	getLoggerrr"rr*rTrUrZr+rrrr�<module>s
0Q

Youez - 2016 - github.com/yon3zu
LinuXploit