Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/web/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/web/__pycache__/distrib.cpython-310.pyc
o

�bW.�@s:dZddlZddlZzddlZWneydZYnwddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZmZmZmZmZddlmZGdd
�d
ej�ZGdd�dejej�Ze� eje�Gdd�d�Z!Gdd�dej"�Z#Gdd�dej$ej%�Z&Gdd�dej"�Z'dS)z�
Distributed web servers.

This is going to have to be refactored so that argument parsing is done
by each subprocess and not by the main web server (i.e. GET, POST etc.).
�N)�BytesIO)�getDOMImplementation)�address�reactor)�Logger)�styles)�pb)�
SIZE_LIMIT)�http�resource�server�static�util)�Headersc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�_ReferenceableProducerWrappercC�
||_dS�N)�producer)�selfr�r�5/usr/lib/python3/dist-packages/twisted/web/distrib.py�__init__$�
z&_ReferenceableProducerWrapper.__init__cC�|j��dSr)r�resumeProducing�rrrr�remote_resumeProducing'�z4_ReferenceableProducerWrapper.remote_resumeProducingcCrr)r�pauseProducingrrrr�remote_pauseProducing*rz3_ReferenceableProducerWrapper.remote_pauseProducingcCrr)r�
stopProducingrrrr�remote_stopProducing-rz2_ReferenceableProducerWrapper.remote_stopProducingN)�__name__�
__module__�__qualname__rrrr!rrrrr#s
rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Requestzn
    A request which was received by a L{ResourceSubscription} and sent via
    PB to a distributed node.
    cs�dD]$}||�ddd��d���fdd��fdd�d	���}|||<qtt|d
��|d
<tj�||�t|j�|_|j�	d�|_
|j�	d�|_|j�	d
�|_|j�	d�|_
|j�	d�|_|j�	d�|_|j�	d�|_dS)z�
        Initialize this L{twisted.web.distrib.Request} based on the copied
        state so that it closely resembles a L{twisted.web.server.Request}.
        )�host�client�TCP�UNIX)�INETr)rcst���d�d�S)N��)r�IPv4Addressr��addrdesc�tuprr�<lambda>@sz*Request.setCopyableState.<locals>.<lambda>cst��d�S)Nr+)r�UNIXAddressr)r0rrr1As)r(r)�requestHeaders�finish�	setHeader�	addCookie�setETag�setResponseCode�setLastModified�writeN)r�dictr�
RemoteCopy�setCopyableStater�content_data�content�remote�remoteMethodr4r5r6r7r8r9�_write)r�state�k�addrrr.rr=7s&
��
zRequest.setCopyableStatecCs>d}t}	|�|||��|t7}|t7}|t|�krdSq)z�
        Write the given bytes to the response body.

        @param bytes: The bytes to write.  If this is longer than 640k, it
            will be split up into smaller pieces.
        rTN)r	rB�len)r�bytes�start�endrrrr:Ss�z
Request.writecCs |j�dt|�|��|j�dS)N�registerProducer)r@�
callRemoter�
addErrback�fail)rr�	streamingrrrrJcs
�zRequest.registerProducercCs|j�d��|j�dS)N�unregisterProducer)r@rKrLrMrrrrrOhszRequest.unregisterProducercCs|jjd|d�dS)N�)�failure)�_logrQ�rrQrrrrMkszRequest.failN)	r"r#r$�__doc__r=r:rJrOrMrrrrr%1sr%c@s*eZdZe�Zdd�Zdd�Zdd�ZdS)�IssuecCrr)�request)rrVrrrrurzIssue.__init__cCs:|tjurt|t�sJd��|j�|�|j��dSdS)Nzreturn value not a string)r�NOT_DONE_YET�
isinstance�strrVr:r4)r�resultrrr�finishedxs

�zIssue.finishedc
CsLt|�}|j�t�tjddt�|���	|j��|j�
�|j�|�dS)NzServer Connection Lostz&Connection to distributed server lost:)
rYrVr:r�	ErrorPager
�INTERNAL_SERVER_ERRORr�_PRE�renderr4rR�inforSrrr�failed~s��
zIssue.failedN)r"r#r$rrRrr[rarrrrrUrs
rUc@sJeZdZdZdZe�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�ResourceSubscriptionr+rcCs(tj�|�||_||_g|_d|_dSr)r�Resourcerr&�port�pending�	publisher)rr&rdrrrr�s

zResourceSubscription.__init__cCs(t�|j�}d|d<d|d<g|d<|S)z3Get persistent state for this ResourceSubscription.Nrfr�waitingre)�copy�__dict__)rrCrrr�__getstate__�s
z!ResourceSubscription.__getstate__cCsF|j�d�|j�|j�||_d|_|jD]}|�|�qg|_dS)z=I've connected to a publisher; I'll now send all my requests.zconnected to publisherrN)	rRr`�broker�notifyOnDisconnect�bootedrfrgrer_)rrfrVrrr�	connected�s

zResourceSubscription.connectedcCsD|jjd|d�d|_d|_|jD]}|�d�|��qg|_dS)zXI can't connect to a publisher; I'll now reply to all pending
        requests.
        z3could not connect to distributed web service: {msg})�msgrNz(Unable to connect to distributed server.)rRr`rgrfrer:r4)rrorVrrr�notConnected�s



z!ResourceSubscription.notConnectedcCs|�d�dS)Nzconnection dropped)rprrrrrm�rzResourceSubscription.bootedcCs�|js<|j�|�|js9d|_t��}d}|jdkr#t�|j	||�n
t�
|j|j	||�|��}|�|j
|j�tjSt|�}|j�d|��|j|j�tjS)a:Render this request, from my server.

        This will always be asynchronous, and therefore return NOT_DONE_YET.
        It spins off a request to the pb client, and either adds it to the list
        of pending issues or requests it immediately, depending on if the
        client is already connected.
        r+�
�unixrV)rfre�appendrgr�PBClientFactoryr&r�connectUNIXrd�
connectTCP�
getRootObject�addCallbacksrnrprUrKr[rarrW)rrV�bf�timeout�d�irrrr_�s"
��zResourceSubscription.renderN)
r"r#r$�isLeafrgrrRrrjrnrprmr_rrrrrb�s
rbc@s:eZdZdZe�Zdd�ZdZdd�Zdd�Z	d	d
�Z
dS)�ResourcePublisherz�
    L{ResourcePublisher} exposes a remote API which can be used to respond
    to request.

    @ivar site: The site which will be used for resource lookup.
    @type site: L{twisted.web.server.Site}
    cCrr)�site)rrrrrr�rzResourcePublisher.__init__r,cCs*|jj�d�|jj|j=|`|`|`dS)N�web)�application�
authorizer�removeIdentity�services�serviceName�perspectiveNamerrrr�upgradeToVersion2�s
z#ResourcePublisher.upgradeToVersion2cCs|Srr)r�namerrr�getPerspectiveNamed�sz%ResourcePublisher.getPerspectiveNamedcCsD|j�|�}|j�|�|�|�}|tjur|�|�|��tjS)zK
        Look up the resource for the given request and render it.
        )	r�getResourceForrRr`r_rrWr:r4)rrV�resrZrrr�remote_request�s


z ResourcePublisher.remote_requestN)r"r#r$rTrrRr�persistenceVersionr�r�r�rrrrr~�sr~c@s>eZdZdZdZdZdZddd�Zdd	�Zd
d�Z	dd
�Z
dS)�
UserDirectoryz�
    A resource which lists available user resources and serves them as
    children.

    @ivar _pwd: An object like L{pwd} which is used to enumerate users and
        their home directories.
    �public_htmlz.twistd-web-pba�
<html>
    <head>
    <title>twisted.web.distrib.UserDirectory</title>
    <style>

    a
    {
        font-family: Lucida, Verdana, Helvetica, Arial, sans-serif;
        color: #369;
        text-decoration: none;
    }

    th
    {
        font-family: Lucida, Verdana, Helvetica, Arial, sans-serif;
        font-weight: bold;
        text-decoration: none;
        text-align: left;
    }

    pre, code
    {
        font-family: "Courier New", Courier, monospace;
    }

    p, body, td, ol, ul, menu, blockquote, div
    {
        font-family: Lucida, Verdana, Helvetica, Arial, sans-serif;
        color: #000;
    }
    </style>
    </head>

    <body>
    <h1>twisted.web.distrib.UserDirectory</h1>

    %(users)s
</body>
</html>
NcCs"tj�|�|durt}||_dSr)rrcr�pwd�_pwd)r�userDatabaserrrr7s
zUserDirectory.__init__c
Cs�g}|j��D]F}|\}}}}}}}	|�d�d}
|
s|}
tj�tj�||j��r2|�||
df�tj�||j	�}tj�|�rM|d}|�||
df�q|S)z|
        Return a list of two-tuples giving links to user resources and text to
        associate with those links.
        �,rz (file)�.twistdz	 (twistd))
r��getpwall�split�os�path�exists�join�userDirNamers�userSocketName)
r�users�userr��passwd�uid�gid�gecos�dir�shell�realname�
twistdsock�linkNamerrr�_users=s�zUserDirectory._userscCs�t�}|�ddd�}|j}|��D]*\}}|�d�}|�d|d�|�|�}|�|�|�d�}	|	�|�|�|	�q|jd|�	�i}
|
�
d�S)	zm
        Render as HTML a listing of all known users with links to their
        personal resources.
        N�ul�a�href�/�lir�zutf-8)r�createDocument�documentElementr��
createElement�setAttribute�createTextNode�appendChild�template�toxml�encode)rrV�domImpl�newDoc�listing�link�text�linkElement�textNode�item�htmlDocrrr�
render_GETPs





zUserDirectory.render_GETcCs�|dkr|Sd}|t|�d�|kr|dt|��}d}n|}d}z|j�|�\}}}}	}
}}Wn
ty?t��YSw|rWtj�||j	�}
t
d|
�}|�||�|Stj�||j�}tj�
|�sit��St�|�S)NrPr�r+rrr)rFr��getpwnam�KeyErrorr�
NoResourcer�r�r�r�rb�putChildr�r�r
�File)rr�rV�td�username�sub�pw_name�	pw_passwd�pw_uid�pw_gid�pw_gecos�pw_dir�pw_shellr��rsr�rrr�getChildes<
	��

zUserDirectory.getChildr)r"r#r$rTr�r�r�rr�r�r�rrrrr�s
*r�)(rTrhr�r��ImportError�ior�xml.dom.minidomr�twisted.internetrr�twisted.loggerr�twisted.persistedr�twisted.spreadr�twisted.spread.bananar	�twisted.webr
rrr
r�twisted.web.http_headersr�
Referenceablerr<r%�setUnjellyableForClassrUrcrb�Root�	Versionedr~r�rrrr�<module>s0�>N'

Spamworldpro Mini