%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.12/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.12/__pycache__/telnetlib.cpython-312.pyc

�

���f[����dZddlZddlZddlZddlmZddlZeje	d��dgZ
dZdZe
dg�Ze
d	g�Ze
d
g�Ze
dg�Ze
dg�Ze
dg�Ze
d
g�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Ze
dg�Z e
dg�Z!e
dg�Z"e
dg�Z#e
dg�Z$e
dg�Z%e
dg�Z&e
dg�Z'e
d g�Z(e
d!g�Z)e
d"g�Z*e
d#g�Z+e
d$g�Z,e
d%g�Z-e
d&g�Z.e
d'g�Z/e
d(g�Z0e
d)g�Z1e
d*g�Z2e
d+g�Z3e
d,g�Z4e
d-g�Z5e
dg�Z6e
d.g�Z7e
d/g�Z8e
d0g�Z9e
d1g�Z:e
d2g�Z;e
d3g�Z<e
d4g�Z=e
d5g�Z>e
d6g�Z?e
d7g�Z@e
d8g�ZAe
d9g�ZBe
d:g�ZCe
d;g�ZDe
d<g�ZEe
d=g�ZFe
d>g�ZGe
d?g�ZHe
d@g�ZIe
dAg�ZJe
dBg�ZKe
dCg�ZLe
dDg�ZMe
dEg�ZNe
dFg�ZOe
dGg�ZPe
dHg�ZQe
dIg�ZRe
dJg�ZSe
dg�ZTe
dg�ZUeVedK�r
ej�ZXnej�ZXGdL�d�ZZdM�Z[e	dNk(re[�yy)OaQTELNET client class.

Based on RFC 854: TELNET Protocol Specification, by J. Postel and
J. Reynolds

Example:

>>> from telnetlib import Telnet
>>> tn = Telnet('www.python.org', 79)   # connect to finger port
>>> tn.write(b'guido\r\n')
>>> print(tn.read_all())
Login       Name               TTY         Idle    When    Where
guido    Guido van Rossum      pts/2        <Dec  2 11:10> snag.cnri.reston..

>>>

Note that read_all() won't read until eof -- it just reads some data
-- but it guarantees to read at least one byte unless EOF is hit.

It is possible to pass a Telnet object to a selector in order to wait until
more data is available.  Note that in this case, read_eager() may return b''
even if there was data on the socket, because the protocol negotiation may have
eaten the data.  This is why EOFError is needed in some cases to distinguish
between "no data" and "connection closed" (since the socket also appears ready
for reading when it is closed).

To do:
- option negotiation
- timeout should be intrinsic to the connection object instead of an
  option on one of the read calls only

�N)�	monotonic)��
)�remove�Telnet������������������������r������	�
��r������������������ �!�"�#�$�%�&�'�(�)�*�+�,�-�.�/�0�1����PollSelectorc���eZdZdZddej
fd�Zdej
fd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd d�Zd�Z d�Z!y)!ra�Telnet interface class.

    An instance of this class represents a connection to a telnet
    server.  The instance is initially not connected; the open()
    method must be used to establish a connection.  Alternatively, the
    host name and optional port number can be passed to the
    constructor, too.

    Don't try to reopen an already connected instance.

    This class has many read_*() methods.  Note that some of them
    raise EOFError when the end of the connection is read, because
    they can return an empty string for other reasons.  See the
    individual doc strings.

    read_until(expected, [timeout])
        Read until the expected string has been seen, or a timeout is
        hit (default is no timeout); may block.

    read_all()
        Read all data until EOF; may block.

    read_some()
        Read at least one byte or EOF; may block.

    read_very_eager()
        Read all data available already queued or on the socket,
        without blocking.

    read_eager()
        Read either data already queued or some data available on the
        socket, without blocking.

    read_lazy()
        Read all data in the raw queue (processing it first), without
        doing any socket I/O.

    read_very_lazy()
        Reads all data in the cooked queue, without doing any socket
        I/O.

    read_sb_data()
        Reads available data between SB ... SE sequence. Don't block.

    set_option_negotiation_callback(callback)
        Each time a telnet option is read on the input flow, this callback
        (if set) is called with the following parameters :
        callback(telnet socket, command, option)
            option will be chr(0) when there is no option.
        No other action is done afterwards by telnetlib.

    Nrc���t|_||_||_||_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
|�|j|||�yy)z�Constructor.

        When called without arguments, create an unconnected instance.
        With a hostname argument, it connects the instance; port number
        and timeout are optional.
        N�r)�
DEBUGLEVEL�
debuglevel�host�port�timeout�sock�rawq�irawq�cookedq�eof�iacseq�sb�sbdataq�option_callback�open��selfrPrQrRs    � /usr/lib/python3.12/telnetlib.py�__init__zTelnet.__init__�s{��%�����	���	������	���	���
����������������#������I�I�d�D�'�*�rMc��d|_|st}||_||_||_tjd|||�tj||f|�|_	y)z�Connect to a host.

        The optional second argument is the port number, which
        defaults to the standard telnet port (23).

        Don't try to reopen an already connected instance.
        rztelnetlib.Telnet.openN)
rW�TELNET_PORTrPrQrR�sys�audit�socket�create_connectionrSr]s    r_r\zTelnet.open�sS�������D���	���	�����	�	�)�4��t�<��,�,�d�D�\�7�C��	rMc�$�|j�y)z#Destructor -- close the connection.N��close�r^s r_�__del__zTelnet.__del__�s���
�
�rMc��|jdkDrEtd|j�d|j�d�d��|rt||z�yt|�yy)z�Print a debug message, when the debug level is > 0.

        If extra arguments are present, they are substituted in the
        message using the standard string formatting operator.

        rzTelnet(�,z):� )�endN)rO�printrPrQ)r^�msg�argss   r_rqz
Telnet.msg�sB���?�?�Q���d�i�i����;��E���c�D�j�!��c�
�rMc��||_y)zhSet the debug level.

        The higher it is, the more debug output you get (on sys.stdout).

        N)rO)r^rOs  r_�set_debuglevelzTelnet.set_debuglevels��%��rMc�z�|j}d|_d|_d|_d|_|r|j	�yy)zClose the connection.NTrMr)rSrWrXrYri)r^rSs  r_rizTelnet.close
s8���y�y����	������������J�J�L�rMc��|jS)z)Return the socket object used internally.)rSrjs r_�
get_socketzTelnet.get_sockets���y�y�rMc�6�|jj�S)z9Return the fileno() of the socket object used internally.)rS�filenorjs r_ryz
Telnet.filenos���y�y���!�!rMc���t|vr!|jtttz�}tjd||�|j	d|�|j
j
|�y)z�Write a string to the socket, doubling any IAC characters.

        Can block if the connection is blocked.  May raise
        OSError if the connection is closed.

        ztelnetlib.Telnet.writezsend %rN)�IAC�replacercrdrqrS�sendall)r^�buffers  r_�writezTelnet.writesP���&�=��^�^�C��S��1�F��	�	�*�D�&�9�����F�#��	�	���&�!rMc�P�t|�}|j�|jj|�}|dk\r*||z}|jd|}|j|d|_|S|�
t	�|z}t�5}|j
|tj�|js�|j|�r�tdt|j�|z
�}|j�|j�|jj||�}|dk\r3||z}|jd|}|j|d|_|cddd�S|�t	�z
}|dkrn
|js��ddd�|j�S#1swY|j�SxYw)aRead until a given string is encountered or until timeout.

        When no match is found, return whatever is available instead,
        possibly the empty string.  Raise EOFError if the connection
        is closed and no cooked data is available.

        rN)�len�process_rawqrV�find�_time�_TelnetSelector�register�	selectors�
EVENT_READrW�select�max�	fill_rawq�read_very_lazy)r^�matchrR�n�i�buf�deadline�selectors        r_�
read_untilzTelnet.read_until)s���
��J�������L�L���e�$����6��!��A��,�,�r��"�C��<�<���+�D�L��J����w��(�H�
�
�	�(����d�I�$8�$8�9��h�h��?�?�7�+��A�s�4�<�<�0��2�3�A��N�N�$��%�%�'����)�)�%��3�A��A�v��a�C��"�l�l�2�A�.��'+�|�|�A�B�'7���"�	�	��&�&���0�G���{���h�h�	�"�"�"�$�$�#	�"�"�"�$�$�s�?C
F
�!F
�
F%c��|j�|js-|j�|j�|js�-|j}d|_|S)z7Read all data until EOF; block until connection closed.rM)r�rWr�rV�r^r�s  r_�read_allzTelnet.read_allNsK�������(�(��N�N�������(�(��l�l������
rMc���|j�|jsE|js9|j�|j�|js
|js�9|j}d|_|S)z�Read at least one byte of cooked data unless EOF is hit.

        Return b'' if EOF is hit.  Block if no data is immediately
        available.

        rM)r�rVrWr�r�s  r_�	read_somezTelnet.read_someXsY��	
�����,�,�t�x�x��N�N�������,�,�t�x�x��l�l������
rMc���|j�|jsM|j�r=|j�|j�|js|j�r�=|j	�S)aRead everything that's possible without blocking in I/O (eager).

        Raise EOFError if connection closed and no cooked data
        available.  Return b'' if no cooked data available otherwise.
        Don't block unless in the midst of an IAC sequence.

        )r�rW�
sock_availr�r�rjs r_�read_very_eagerzTelnet.read_very_eagergsY��	
�����(�(�t���0��N�N�������(�(�t���0��"�"�$�$rMc�$�|j�|jse|jsY|j�rI|j	�|j�|js|js|j�r�I|j�S)z�Read readily available data.

        Raise EOFError if connection closed and no cooked data
        available.  Return b'' if no cooked data available otherwise.
        Don't block unless in the midst of an IAC sequence.

        )r�rVrWr�r�r�rjs r_�
read_eagerzTelnet.read_eageruse��	
�����,�,�t�x�x�D�O�O�4E��N�N�������,�,�t�x�x�D�O�O�4E��"�"�$�$rMc�B�|j�|j�S)aProcess and return data that's already in the queues (lazy).

        Raise EOFError if connection closed and no data available.
        Return b'' if no cooked data available otherwise.  Don't block
        unless in the midst of an IAC sequence.

        )r�r�rjs r_�	read_lazyzTelnet.read_lazy�s��	
�����"�"�$�$rMc�v�|j}d|_|s#|jr|jstd��|S)z�Return any data available in the cooked queue (very lazy).

        Raise EOFError if connection closed and no data available.
        Return b'' if no cooked data available otherwise.  Don't block.

        rMztelnet connection closed)rVrWrT�EOFErrorr�s  r_r�zTelnet.read_very_lazy�s4���l�l������t�x�x��	�	��5�6�6��
rMc�,�|j}d|_|S)aReturn any data available in the SB ... SE queue.

        Return b'' if no SB ... SE available. Should only be called
        after seeing a SB or SE command. When a new SB command is
        found, old unread SB data will be discarded. Don't block.

        rM)rZr�s  r_�read_sb_datazTelnet.read_sb_data�s���l�l������
rMc��||_y)zIProvide a callback function called after each receipt of a telnet option.N)r[)r^�callbacks  r_�set_option_negotiation_callbackz&Telnet.set_option_negotiation_callback�s
��'��rMc�X�ddg}	|j�r�|j�}|jsP|tk(r�3|dk(r�9|tk7r ||j
|z||j
<�b|xj|z
c_�nSt
|j�dk(r�|ttttfvr|xj|z
c_��d|_|tk(r!||j
|z||j
<�n�|tk(rd|_d|_n,|tk(r#d|_|j|dz|_d|d<|jr#|j|j|t ��ni|j#dt%|�z��nJt
|j�dk(�r1|jdd}d|_|}|ttfvr|j#d|tk(xrdxsd	t%|��|jr|j|j||�n�|jj'ttz|z�n�|ttfvr~|j#d|tk(xrd
xsdt%|��|jr|j|j||�n)|jj'ttz|z�|jr���|j*|dz|_|j|dz|_y#t($rd|_d|_Y�HwxYw)
z�Transfer from raw queue to cooked queue.

        Set self.eof when connection is closed.  Don't block unless in
        the midst of an IAC sequence.

        rM�rrzIAC %d not recognizedrz	IAC %s %d�DO�DONT�WILL�WONTN)rT�rawq_getcharrX�theNULLr{rYr�r�r�r�r��SBrZ�SEr[rS�NOOPTrq�ordr}r�rV)r^r��c�cmd�opts     r_r�zTelnet.process_rawq�s����C�j��;	��)�)��%�%�'���{�{��G�|� ��G�|� ��C�x�'*�4�7�7�|�a�'7��D�G�G�� ����q�(������%��*��R��t�T�2�2����q�(�� �"%�D�K��C�x�'*�4�7�7�|�a�'7��D�G�G����7�&'�D�G�+.�D�L��"�W�&'�D�G�+/�<�<�#�a�&�+@�D�L�%(�C��F��/�/�!�0�0����A�u�E�
!�H�H�%<�s�1�v�%E�F�����%��*��+�+�a��*�C�"%�D�K��C��r�4�j�(������2�I�.�$�8�&�#�c�(�D��/�/� �0�0����C��E� �I�I�-�-�c�D�j�3�.>�?���t��,������4�K�2�F�<�f�c�#�h�H��/�/� �0�0����C��E� �I�I�-�-�c�D�j�3�.>�?�o�)�)�v�|�|�c�!�f�,����|�|�c�!�f�,����	�	��D�K��D�G�	�s�KL�L)�(L)c�6�|js"|j�|jrt�|j|j|jdz}|jdz|_|jt|j�k\rd|_d|_|S)z�Get next char from raw queue.

        Block if no data is immediately available.  Raise EOFError
        when connection is closed.

        rrMr)rTr�rWr�rUr�)r^r�s  r_r�zTelnet.rawq_getchar�ss���y�y��N�N���x�x����I�I�d�j�j����A��.���Z�Z�!�^��
��:�:��T�Y�Y��'��D�I��D�J��rMc��|jt|j�k\rd|_d|_|jj	d�}|jd|�||_|j|z|_y)z�Fill raw queue from exactly one recv() system call.

        Block if no data is immediately available.  Set self.eof when
        connection is closed.

        rMr�2zrecv %rN)rUr�rTrS�recvrqrWr�s  r_r�zTelnet.fill_rawqs`���:�:��T�Y�Y��'��D�I��D�J��i�i�n�n�R� ������C� ��G����I�I��O��	rMc��t�5}|j|tj�t	|jd��cddd�S#1swYyxYw)z-Test whether data is available on the socket.rN)r�r�r�r��boolr�)r^r�s  r_r�zTelnet.sock_availsF��
�
�	,�(����d�I�$8�$8�9������*�+�	,�	,�	,�s�:A�Ac�:�tjdk(r|j�yt�5}|j	|t
j�|j	tjt
j�	|j�D]�\}}|j|ura	|j�}|s�(tjj|jd��tjj!��u|jtjus��tjj#�j%d�}|s
ddd�y|j|�����#t$rtd�Yddd�ywxYw#1swYyxYw)z9Interaction function, emulates a very dumb telnet client.�win32N�(*** Connection closed by remote host ***�ascii)rc�platform�mt_interactr�r�r�r��stdinr��fileobjr�r�rp�stdoutr�decode�flush�readline�encode)r^r��key�events�text�lines      r_�interactzTelnet.interactsF���<�<�7�"������
�
�	)�(����d�I�$8�$8�9����c�i�i��)=�)=�>��#+�?�?�#4�)�K�C���{�{�d�*�#�#'�?�?�#4�D� ��J�J�,�,�T�[�[��-A�B��J�J�,�,�.�����	�	�1�"�y�y�1�1�3�:�:�7�C��#�"�%	)�	)�&�
�
�4�(�)���
 (�#�!�"L�M�"�	)�	)�#��	)�	)�sC�A4F�$E.�4F�7A)F�!0F�F�.F�F�
F�F�Fc���ddl}|j|jd�	tjj�}|sy|j
|jd���B)z$Multithreaded version of interact().rN�r�)�_thread�start_new_thread�listenerrcr�r�rr�)r^r�r�s   r_r�zTelnet.mt_interact5sN���� � �����3���9�9�%�%�'�D����J�J�t�{�{�7�+�,�	rMc��		|j�}|r/tjj|j
d��ntjj��a#t$rtd�YywxYw)z>Helper for mt_interact() -- this executes in the other thread.r�Nr�)r�r�rprcr�rr�r�)r^�datas  r_r�zTelnet.listener?sh���
����(����
�
� � ����W�!5�6��
�
� � �"����
��@�A��
�s�A#�#A:�9A:c�&�d}|dd}tt|��}|D]/}t||d�r�|sddl}|j	||�||<�1|�
t�|z}t
�5}|j|tj�|js�|j�|D]e}||j|j�}|s�$|j�}	|jd|	}
|j|	d|_
|||
fccddd�S|�'|j|�}t�z
}|s|dkrn��|j!�|js��ddd�|j#�}
|
s|jrt$�dd|
fS#1swY�2xYw)a�Read until one from a list of a regular expressions matches.

        The first argument is a list of regular expressions, either
        compiled (re.Pattern instances) or uncompiled (strings).
        The optional second argument is a timeout, in seconds; default
        is no timeout.

        Return a tuple of three items: the index in the list of the
        first regular expression that matches; the re.Match object
        returned; and the text read up till and including the match.

        If EOF is read and no text was read, raise EOFError.
        Otherwise, when nothing matches, return (-1, None, text) where
        text is the text received so far (may be the empty string if a
        timeout happened).

        If a regular expression ends with a greedy match (e.g. '.*')
        or if more than one expression can match the same input, the
        results are undeterministic, and may depend on the I/O timing.

        N�searchr���)�ranger��hasattr�re�compiler�r�r�r�r�rWr�r�rVror�r�r�r�)r^�listrRr��indicesr�r�r��m�er��readys            r_�expectz
Telnet.expectLs���,���A�w����D�	�"���	.�A��4��7�H�-��9��*�*�T�!�W�-��Q��	.����w��(�H�
�
�	!�(����d�I�$8�$8�9��h�h��!�!�#� �,�A��Q����t�|�|�4�A���E�E�G��#�|�|�B�Q�/��'+�|�|�A�B�'7��� !�1�d�|�+�	!�	!�,��&�$�O�O�G�4�E�&���0�G� �"�Q�;�!�$���� �#�h�h�	!�(�"�"�$�������N��D�$���/	!�	!�s�)A"F�9F�AF�Fc��|S�Nr�rjs r_�	__enter__zTelnet.__enter__�s���rMc�$�|j�yr�rh)r^�type�value�	tracebacks    r_�__exit__zTelnet.__exit__�s���
�
�rMr�)"�__name__�
__module__�__qualname__�__doc__re�_GLOBAL_DEFAULT_TIMEOUTr`r\rkrqrtrirwryrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rMr_rr�s���3�j!�q��7�7�+�0 ��)G�)G�D�"��%���"�"�#%�J�
�%�%�	%��
�(�E-�N�$$�",�)�4-�#�6 �p�rMc��d}tjddrVtjddk(r@|dz}tjd=tjddrtjddk(r�@d}tjddrtjd}d}tjddrtjd}	t|�}t
�5}|j|�|j||d�	�|j�ddd�y#t$rt	j
|d�}Y�jwxYw#1swYyxYw)
z�Test program for telnetlib.

    Usage: python telnetlib.py [-d] ... [host [port]]

    Default host is localhost; default port is 23.

    rrNz-d�	localhostr�tcpg�?)rR)
rc�argv�int�
ValueErrorre�
getservbynamerrtr\r�)rOrPrQ�portstr�tns     r_�testr��s���J�

�(�(�1�2�,�3�8�8�A�;�$�.���\�
��H�H�Q�K��(�(�1�2�,�3�8�8�A�;�$�.��D�
�x�x���|��x�x��{���D�
�x�x���|��(�(�1�+��	8��w�<�D�
���R�
���*�%�
����d�C��(�
���
�����	8��'�'���7�D�	8����s�=D�6D6�D3�2D3�6D?�__main__)\r�rcrer��timerr��warnings�_deprecatedr��__all__rNrb�bytesr{r�r�r�r�r�r��NOP�DM�BRK�IP�AO�AYT�EC�EL�GAr��BINARY�ECHO�RCP�SGA�NAMS�STATUS�TM�RCTE�NAOL�NAOP�NAOCRD�NAOHTS�NAOHTD�NAOFFD�NAOVTS�NAOVTD�NAOLFD�XASCII�LOGOUT�BM�DET�SUPDUP�SUPDUPOUTPUT�SNDLOC�TTYPE�EOR�TUID�OUTMRK�TTYLOC�VT3270REGIME�X3PAD�NAWS�TSPEED�LFLOW�LINEMODE�XDISPLOC�OLD_ENVIRON�AUTHENTICATION�ENCRYPT�NEW_ENVIRON�TN3270E�XAUTH�CHARSET�RSP�COM_PORT_OPTION�SUPPRESS_LOCAL_ECHO�TLS�KERMIT�SEND_URL�	FORWARD_X�PRAGMA_LOGON�
SSPI_LOGON�PRAGMA_HEARTBEAT�EXOPLr�r�rJr��SelectSelectorrr�r�rMr_�<module>r?s����F�
��#������X�g�.��*���
���
�c�U�|���c�U�|���c�U�|���c�U�|���c�U�|��
���*���S�E�l���S�E�l���S�E�l���S�E�l���S�E�l���S�E�l���S�E�l���S�E�l���S�E�l���S�E�l���S�E�l��

��s����a�S�z���Q�C�j���Q�C�j���a�S�z��	��s���
�A�3�Z���a�S�z���a�S�z���a�S�z��	��t���	��t���	��t���	��t���	��t���	��t���	��t���	��t���	��t���
�B�4�[���R�D�k��	��t����b�T�{��	��t���
�r�d����R�D�k���b�T�{��	��t���	��t����b�T�{��
�r�d����b�T�{��	��t���
�r�d����"��;���"��;���R�D�k����t���
���+���R�D�k��
���+��
�r�d���
���+���R�D�k�����+���R�D�k���R�D�k��	��t����"��;���2�$�K�	��c�U�|��
�C�5�\�
��#��<��
�s�e���
�q�c�
��
�9�n�%��,�,�O��.�.�O�x�x�v�6�z���F�rM

Zerion Mini Shell 1.0