AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/internet/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/internet/__pycache__/unix.cpython-310.pyc
o

�b�W�@s
dZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZddlm
Z
mZddlmZmZmZddlmZmZmZmZmZmZmZmZddlmZddlmZm Z m!Z!m"Z"dd	l#m$Z$dd
l%m&Z&ddl'm(Z(zddlm)Z*Wne+ydZ)Ynwe*Z)e,ed
�s�e+d��dd�Z-Gdd�d�Z.Gdd�d�Z/e)r�e.Z.ne/Z.eej0�Gdd�de.ej1��Z1dd�Z2Gdd�d�Z3Gdd�de3ej4�Z4eej0�Gdd�de.ej5��Z6Gdd �d ej7�Z8eej9�Gd!d"�d"e3ej4��Z:eej;geej<��R�Gd#d$�d$e:��Z=dS)%z�
UNIX socket support for Twisted.

End users shouldn't use this module directly - use the reactor APIs instead.

Maintainer: Itamar Shtull-Trauring
�N)�EAGAIN�ECONNREFUSED�EINTR�EMSGSIZE�ENOBUFS�EWOULDBLOCK)�Optional�Type)�
implementedBy�implementer�implementer_only)�address�base�error�
interfaces�main�protocol�tcp�udp)�FileDescriptor)�failure�lockfile�log�reflect)�
lazyByteSlice)�_coerceToFilesystemEncoding)�untilConcludes)�sendmsg�AF_UNIXz+UNIX sockets not supported on this platformcCst�d|�}tjtj|fgS)zh
    Pack an integer into an ancillary data structure suitable for use with
    L{sendmsg.sendmsg}.
    �i)�struct�pack�socket�
SOL_SOCKETr�
SCM_RIGHTS)�fd�packed�r'�7/usr/lib/python3/dist-packages/twisted/internet/unix.py�_ancillaryDescriptor)sr)c@sZeZdZUdZdZeeeed<dZ	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�ZdS)�
_SendmsgMixina

    Mixin for stream-oriented UNIX transports which uses sendmsg and recvmsg to
    offer additional functionality, such as copying file descriptors into other
    processes.

    @ivar _writeSomeDataBase: The class which provides the basic implementation
        of C{writeSomeData}.  Ultimately this should be a subclass of
        L{twisted.internet.abstract.FileDescriptor}.  Subclasses which mix in
        L{_SendmsgMixin} must define this.

    @ivar _sendmsgQueue: A C{list} of C{int} holding file descriptors which are
        currently buffered before being sent.

    @ivar _fileDescriptorBufferSize: An C{int} giving the maximum number of file
        descriptors to accept and queue for sending before pausing the
        registered producer, if there is one.
    N�_writeSomeDataBase�@cCs
g|_dS�N)�
_sendmsgQueue��selfr'r'r(�__init__H�
z_SendmsgMixin.__init__cCst|j�|jkp
|j�|�S)a�
        Determine whether the user-space send buffer for this transport is full
        or not.

        This extends the base determination by adding consideration of how many
        file descriptors need to be sent using L{sendmsg.sendmsg}.  When there
        are more than C{self._fileDescriptorBufferSize}, the buffer is
        considered full.

        @return: C{True} if it is full, C{False} otherwise.
        )�lenr.�_fileDescriptorBufferSizer+�_isSendBufferFullr/r'r'r(r5Ks����z_SendmsgMixin._isSendBufferFullcCs |j�|�|��|��dS)zY
        Queue the given file descriptor to be sent and start trying to send it.
        N)r.�append�_maybePauseProducer�startWriting)r0�filenor'r'r(�sendFileDescriptordsz _SendmsgMixin.sendFileDescriptorc
Cs6t|j�t|�kr
t��Sd}zg|t|j�kro|j|}zttj|j|||d�t|��Wn4tyc}z(|j	dt
tfvrO|WYd}~W|jd|�=Stj
WYd}~W|jd|�=Sd}~ww|d7}|t|j�ksW|jd|�=n|jd|�=wt||�}|j�||�}z||WSty�|YSw)zg
        Send as much of C{data} as possible.  Also send any pending file
        descriptors.
        r�N)r3r.r�FileDescriptorOverrunrrr"r)�OSError�argsrrr�CONNECTION_LOSTrr+�
writeSomeData�	TypeError)r0�data�indexr%�se�limitedData�resultr'r'r(r@ls@	
������

�z_SendmsgMixin.writeSomeDatac
Cs�zttj|j|j�\}}}Wn#ty1}z|jdtkr$WYd}~dStj	WYd}~Sd}~ww|D](\}}}|tj
krI|tjkrI|�|�q4t
jd|��|��|�|j�||d�q4|�|�S)a�
        Calls {IProtocol.dataReceived} with all available data and
        L{IFileDescriptorReceiver.fileDescriptorReceived} once for each
        received file descriptor in ancillary data.

        This reads up to C{self.bufferSize} bytes of data from its socket, then
        dispatches the data to protocol callbacks to be handled.  If the
        connection is not lost through an error in the underlying recvmsg(),
        this function will return the result of the dataReceived call.
        rNz�%(protocolName)s (on %(hostAddress)r) received unsupported ancillary data (level=%(cmsgLevel)r, type=%(cmsgType)r) from %(peerAddress)r.)�format�hostAddress�peerAddress�protocolName�	cmsgLevel�cmsgType)rr�recvmsgr"�
bufferSizer=r>rrr?r#r$�%_ancillaryLevelSOLSOCKETTypeSCMRIGHTSr�msg�getHost�getPeer�
_getLogPrefixr�
_dataReceived)r0rB�	ancillary�flagsrDrKrL�cmsgDatar'r'r(�doRead�s,���
�
z_SendmsgMixin.doReadcCs~t|�d}t�d||�}tj�|j�r"|D]}|j�|�qdStj	d|�
�|��|�|j�d�|D]}t
�|�q5dS)a�
        Processes ancillary data with level SOL_SOCKET and type SCM_RIGHTS,
        indicating that the ancillary data payload holds file descriptors.

        Calls L{IFileDescriptorReceiver.fileDescriptorReceived} once for each
        received file descriptor or logs a message if the protocol does not
        implement L{IFileDescriptorReceiver}.

        @param cmsgData: Ancillary data payload.
        @type cmsgData: L{bytes}
        �rz�%(protocolName)s (on %(hostAddress)r) does not provide IFileDescriptorReceiver; closing file descriptor received (from %(peerAddress)r).)rGrHrIrJN)r3r �unpackr�IFileDescriptorReceiver�
providedByr�fileDescriptorReceivedrrPrQrRrS�os�close)r0rW�fdCount�fdsr%r'r'r(rO�s
�
�
�z3_SendmsgMixin._ancillaryLevelSOLSOCKETTypeSCMRIGHTS)�__name__�
__module__�__qualname__�__doc__r+rr	r�__annotations__r4r1r5r:r@rXrOr'r'r'r(r*2s
.)r*c@seZdZdZdS)�_UnsupportedSendmsgMixinz�
    Behaviorless placeholder used when C{twisted.python.sendmsg} is not
    available, preventing L{IUNIXTransport} from being supported.
    N)rbrcrdrer'r'r'r(rg�srgc@s6eZdZejZdd�Zedd��Zdd�Z	dd�Z
d	S)
�Serverc	Cs*t�|�tj�||||df|||�dSr-)r*r1rrh)r0�sockr�client�server�	sessionno�reactorr'r'r(r1�s
�zServer.__init__c	Cs�t�|tjtj�}t�|���}|�|�}|dur|��dSd}||||�	�d||�}d�
|jjj
|j|���|_d�
|jjj
|j|���|_|�|�|S)a
        Create a new L{Server} based on an existing connected I{SOCK_STREAM}
        socket.

        Arguments are the same as to L{Server.__init__}, except where noted.

        @param fileDescriptor: An integer file descriptor associated with a
            connected socket.  The socket must be in non-blocking mode.  Any
            additional attributes desired, such as I{FD_CLOEXEC}, must also be
            set already.

        @return: A new instance of C{cls} wrapping the socket given by
            C{fileDescriptor}.
        Nrz<{} #{} on {}>z{},{},{})r"�fromfdr�SOCK_STREAMr
�UNIXAddress�getsockname�
buildProtocolr_�getpeernamerGr�	__class__rbrl�repstr�logstr�makeConnection)	�cls�fileDescriptor�factoryrm�skt�protocolAddr�protorlr0r'r'r(�_fromConnectedSocket�s(
��
zServer._fromConnectedSocketcC�t�|j���Sr-�r
rpr"rqr/r'r'r(rQ$�zServer.getHostcCst�|jpd�Sr-)r
rp�hostnamer/r'r'r(rR'r�zServer.getPeerN)rbrcrdrrhr+r1�classmethodr~rQrRr'r'r'r(rh�s
'rhcCs|dd�dvS)a�
    Determine whether the given unix socket path is in a filesystem namespace.

    While most PF_UNIX sockets are entries in the filesystem, Linux 2.2 and
    above support PF_UNIX sockets in an "abstract namespace" that does not
    correspond to any path. This function returns C{True} if the given socket
    path is stored in the filesystem and C{False} if the path is in this
    abstract namespace.
    Nr;)��r')�pathr'r'r(�_inFilesystemNamespace+s
r�c@seZdZdd�ZdS)�	_UNIXPortcCr)zV
        Returns a UNIXAddress.

        This indicates the server's address.
        r�r/r'r'r(rQ9sz_UNIXPort.getHostN)rbrcrdrQr'r'r'r(r�8sr�c@sfeZdZejZejZeZ	dZ
	ddd�Zedd��Z
d	efd
d�Zdd
�Zdd�Zdd�Zdd�ZdS)�PortN�2�rcCs4tjj||�|�j|||d�||_||_d|_dS)N�rm)rr�r1�
_buildAddr�name�mode�wantPID�_preexistingSocket)r0�fileNamerz�backlogr�rmr�r'r'r(r1Is�
z
Port.__init__cCs.t�||j|j�}||��||d�}||_|S)a�
        Create a new L{Port} based on an existing listening I{SOCK_STREAM}
        socket.

        Arguments are the same as to L{Port.__init__}, except where noted.

        @param fd: An integer file descriptor associated with a listening
            socket.  The socket must be in non-blocking mode.  Any additional
            attributes desired, such as I{FD_CLOEXEC}, must also be set already.

        @return: A new instance of C{cls} wrapping the socket given by C{fd}.
        r�)r"rn�
addressFamily�
socketTyperqr�)rxrmr%rz�portr0r'r'r(�_fromListeningDescriptorSszPort._fromListeningDescriptor�returncCs8t�|jj�}t|d�rd�|td|j��Sd|�d�S)Nr"z<{} on {!r}>��<� (not listening)>)r�qualrzrt�hasattrrGrr�)r0�factoryNamer'r'r(�__repr__fs

�z
Port.__repr__cCs
t�|�Sr-�r
rp)r0r�r'r'r(r�pr2zPort._buildAddrc
CsPtj��t�d|�|j�td|j�f�|j	rOt
�|jd�|_|j�
�s/t�d|jd��|jjsOzt�t�|j�j�rDt�|j�Wn	tyNYnw|j��z|jdura|j}d|_n
|��}|�|j�Wnty�}zt�d|j|��d}~wwt|j�r�t�|j|j�|�|j �d|_!||_"|j"j#|_#d|_$|�%�dS)z�
        Create and bind my socket, and begin listening on it.

        This is called on unserialization, and must be called after creating a
        server to begin listening on the specified port.
        z%s starting on %rr��.lockNzCannot acquire lockT�d)&r�_reservedFD�reserverrPrSrzrr�r�r�FilesystemLock�lockFile�lockr�CannotListenError�clean�stat�S_ISSOCKr^�st_mode�remove�
BaseException�doStartr��createInternetSocket�bindr=r��chmodr��listenr��	connectedr"r9�
numberAccepts�startReading�r0r{�ler'r'r(�startListeningssP


���
��

���

zPort.startListeningcCst�dtd|j��dS)z0
        Log message for closing socket
        z(UNIX Port %s Closed)r�N)rrPrr�r/r'r'r(�_logConnectionLostMsg�s���zPort._logConnectionLostMsgcCs<t|j�rt�|j�|jdur|j��tj�||�dSr-)	r�r�r^�unlinkr��unlockrr��connectionLost�r0�reasonr'r'r(r��s



zPort.connectionLost)r�r�Nr)rbrcrdr"rr�ror�rh�	transportr�r1r�r��strr�r�r�r�r�r'r'r'r(r�Bs
�


6r�c@s<eZdZdZejZejZe	j
Zd
dd�Zdd�Z
dd	�ZdS)�ClientzA client for Unix sockets.NrcCsjt�|�t�|�j}||_||_|_|r(t�	|d�s(|�
ddt�|�|�|�
|j
|��d|�dS)Nr�)r*r1r
rpr��	connector�realAddress�addrr�isLocked�_finishInitr�BadFileError�	doConnectr�)r0�filenamer�rm�checkPIDr'r'r(r1�s
zClient.__init__cC�t�|j�Sr-)r
rpr�r/r'r'r(rR��zClient.getPeercCs
t�d�Sr-r�r/r'r'r(rQ�r2zClient.getHost)Nr)rbrcrdrer"rr�ror�r�
BaseClientr+r1rRrQr'r'r'r(r��s

r�c@s$eZdZdd�Zdd�Zdd�ZdS)�	ConnectorcCs"tj�||||�||_||_dSr-)r�
BaseConnectorr1r
r�)r0r
rz�timeoutrmr�r'r'r(r1�s
zConnector.__init__cCst|j||j|j�Sr-)r�r
rmr�r/r'r'r(�_makeTransport�szConnector._makeTransportcCst�|j�Sr-r�r/r'r'r(�getDestination�r�zConnector.getDestinationN)rbrcrdr1r�r�r'r'r'r(r��sr�c@sPeZdZdZejZddd�Zdefdd	�Z	d
d�Z
dd
�Zddd�Zdd�Z
dS)�DatagramPortz4
    Datagram UNIX port, listening for packets.
    � r�NcCs tjj|||||d�||_dS)z%Initialize with address to listen on.)�
maxPacketSizermN)rr�r1r�)r0r�r}r�r�rmr'r'r(r1�s
�
zDatagramPort.__init__r�cCs8t�|jj�}t|d�rd|�d|j�d�Sd|�d�S)Nr"r�z on �>r�)rr�rrtr�r�)r0rJr'r'r(r��s�
zDatagramPort.__repr__c
Cs�t�|jj�dt|j����z|��}|jr|�|j�Wnty2}zt	�
d|j|��d}~ww|jrCt|j�rCt�
|j|j�d|_||_|jj|_dS)Nz
 starting on r;)rrPrrt�reprr�r�r�r=rr�r�r^r�r�r�r"r9r�r'r'r(�_bindSocket�s���zDatagramPort._bindSocketc
Cs�z|j�||�WSty?}z+|jd}|tkr%|�||�WYd}~S|tkr.t�d��|t	kr3n�WYd}~dSd}~ww)zWrite a datagram.rN�message too long)
r"�sendtor=r>r�writerr�MessageLengthErrorr)r0�datagramr
rD�nor'r'r(r�s

���zDatagramPort.writecCspt�dt|j��tj�||�t|d�r|j�	�d|_
|j��|`|`
t|d�r6|j�d�|`dSdS)zCleans up my socket.z(Port %s Closed)rr�dN)rrPr�r�r�BasePortr�r�r�doStopr�r"r_r9r��callbackr�r'r'r(r�s



�zDatagramPort.connectionLostcCst�|jj�d|_dS)Nz (UDP))rr�rrtrvr/r'r'r(�	setLogStr.szDatagramPort.setLogStr)r�r�Nr-)rbrcrdrer"rr�r1r�r�r�r�r�r�r'r'r'r(r��s
	
r�c@sJeZdZdZ				ddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�ConnectedDatagramPortz+
    A connected datagram UNIX socket.
    r�r�NcCs.t|tj�sJ�t�||||||�||_dSr-)�
isinstancer�ConnectedDatagramProtocolr�r1�
remoteaddr)r0r�r}r�r��bindAddressrmr'r'r(r1:s	
zConnectedDatagramPort.__init__cCsHz|��|j�|j�|��WdSty#|�t���YdSwr-)	r�r"�connectr��_connectToProtocolr��connectionFailedr�Failurer/r'r'r(r�Gs�z$ConnectedDatagramPort.startListeningcCs|��|j�|�|`dS)z�
        Called when a connection fails. Stop listening on the socket.

        @type reason: L{Failure}
        @param reason: Why the connection failed.
        N)�
stopListeningrr�r�r'r'r(r�Osz&ConnectedDatagramPort.connectionFailedc
Cs�d}||jkrbz|j�|j�\}}|t|�7}|j�|�Wn<tyN}z$|jd}|t	t
tfvr9WYd}~dS|tkrC|j�
�n�WYd}~nd}~wtyZt��Ynw||jksdSdS)z=
        Called when my socket is ready for reading.
        rN)�
maxThroughputr"�recvfromr�r3r�datagramReceivedr=r>rrrr�connectionRefusedr�r�deferr)r0�readrBr�rDr�r'r'r(rXZs&

����zConnectedDatagramPort.doReadc
Cs�z|j�|�WStyN}z;|jd}|tkr#|�|�WYd}~S|tkr,t�d��|t	kr6|j
��n|tkr;n�WYd}~dSWYd}~dSd}~ww)z#
        Write a datagram.
        rNr�)
r"�sendr=r>rr�rrr�rrr�r)r0rBrDr�r'r'r(r�os"

���zConnectedDatagramPort.writecCr�r-)r
rpr�r/r'r'r(rR�r�zConnectedDatagramPort.getPeer)r�r�NN)
rbrcrdrer1r�r�rXr�rRr'r'r'r(r�2s
�
r�)>rer^r"r�r �errnorrrrrr�typingrr	�zope.interfacer
rr�twisted.internetr
rrrrrrr�twisted.internet.abstractr�twisted.pythonrrrr�twisted.python.compatr�twisted.python.filepathr�twisted.python.utilrr�_sendmsg�ImportErrorr�r)r*rg�IUNIXTransportrhr�r�r�r�r�r�r��IUNIXDatagramTransportr��IUNIXDatagramConnectedTransportr�r�r'r'r'r(�<module>sZ	 (�
	39

}
L��

Anon7 - 2022
AnonSec Team