%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/protocols/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/protocols/__pycache__/ident.cpython-312.pyc

�

Ϫ�f
���dZddlZddlmZddlmZddlmZmZdZ	dZ
Gd�d	e�ZGd
�de�Z
Gd�d
e�ZGd�de�ZGd�dej �ZGd�d�ZGd�dej �Zgd�Zy)z 
Ident protocol implementation.
�N)�defer)�basic)�failure�log�i��c� �eZdZdZdZdefd�Zy)�
IdentErrorz;
    Can't determine connection owner; reason unknown.
    z
UNKNOWN-ERROR�returnc��|jS�N)�identDescription��selfs �9/usr/lib/python3/dist-packages/twisted/protocols/ident.py�__str__zIdentError.__str__s���$�$�$�N)�__name__�
__module__�__qualname__�__doc__r
�strr�rrr	r	s���'��%��%rr	c��eZdZdZdZy)�NoUserz�
    The connection specified by the port pair is not currently in use or
    currently not owned by an identifiable entity.
    zNO-USERN�rrrrr
rrrrrs���
!�rrc��eZdZdZdZy)�InvalidPorta
    Either the local or foreign port was improperly specified. This should
    be returned if either or both of the port ids were out of range (TCP
    port numbers are from 1-65535), negative integers, reals or in any
    fashion not recognized as a non-negative integer.
    zINVALID-PORTNrrrrrr's���&�rrc��eZdZdZdZy)�
HiddenUserz�
    The server was able to identify the user of this port, but the
    information was not returned at the request of the user.
    zHIDDEN-USERNrrrrrr2s���
%�rrc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�IdentServera�
    The Identification Protocol (a.k.a., "ident", a.k.a., "the Ident
    Protocol") provides a means to determine the identity of a user of a
    particular TCP connection. Given a TCP port number pair, it returns a
    character string which identifies the owner of that connection on the
    server's system.

    Server authors should subclass this class and override the lookup method.
    The default implementation returns an UNKNOWN-ERROR response for every
    query.
    c��|jd�}t|�dk7r|j�y	tt|�\}}t
|cxkr	tkr,nn)t
|cxkr	tkrnn|j||�y|jtjt��||�y#t$r|j�YywxYw)N�,�)
�split�len�invalidQuery�map�int�	_MIN_PORT�	_MAX_PORT�
validQuery�	_ebLookupr�Failurer�
ValueError)r�line�parts�portOnServer�portOnClients     r�lineReceivedzIdentServer.lineReceivedHs����
�
�3����u�:��?�����

�-0��e�_�*��l�
��:��:�!�\�>�Y�>��O�O�L�,�?��N�N�����
�6��l����
$��!�!�#�
$�s�B3�3C�Cc�8�|jj�yr)�	transport�loseConnectionrs rr'zIdentServer.invalidQuery\s�����%�%�'rc�J�|jj�j|f}|jj�j|f}t	j
|j||�j|j||�j|j||�y)z�
        Called when a valid query is received to look up and deliver the
        response.

        @param portOnServer: The server port from the query.
        @param portOnClient: The client port from the query.
        N)r6�getHost�host�getPeerr�
maybeDeferred�lookup�addCallback�	_cbLookup�
addErrbackr-)rr2r3�
serverAddr�
clientAddrs     rr,zIdentServer.validQuery_s|���^�^�+�+�-�2�2�L�@�
��^�^�+�+�-�2�2�L�@�
�
���D�K�K��Z�@�L�L��N�N�L�,�	
�
�*�T�^�^�\�<�
@rc�>�|\}}|jd||||fz�y)Nz%d, %d : USERID : %s : %s)�sendLine)r�result�sport�cport�sysName�userIds      rr?zIdentServer._cbLookupms'��"���&��
�
�1�U�E�7�F�4S�S�Trc���|jt�r"|jd|||jfz�yt	j
|�|jd||t|j�fz�y)Nz%d, %d : ERROR : %s)�checkr	rD�valuer�err)rrrFrGs    rr-zIdentServer._ebLookupqs]���7�=�=��$��M�M�/�5�%����2O�O�P��G�G�G���M�M�%���z�'�-�-�7P�(Q�Q�
rc��t��)aq
        Lookup user information about the specified address pair.

        Return value should be a two-tuple of system name and username.
        Acceptable values for the system name may be found online at::

            U{http://www.iana.org/assignments/operating-system-names}

        This method may also raise any IdentError subclass (or IdentError
        itself) to indicate user information will not be provided for the
        given query.

        A Deferred may also be returned.

        @param serverAddress: A two-tuple representing the server endpoint
        of the address being queried.  The first element is a string holding
        a dotted-quad IP address.  The second element is an integer
        representing the port.

        @param clientAddress: Like I{serverAddress}, but represents the
        client endpoint of the address being queried.
        �r	)r�
serverAddress�
clientAddresss   rr=zIdentServer.lookupzs��.�l�rN)
rrrrr4r'r,r?r-r=rrrr!r!;s'��
��((�A�U��rr!c�j�eZdZdZdZ	ddlmZefd�Z[d�Z	d	�Z
d
�Zd�Zd�Z
y#e$rd
d�ZY�wxYw)�ProcServerMixinzDImplements lookup() to grab entries for responses from /proc/net/tcp�LINUXr)�getpwuidc��||�dS�Nrr�r�uidrUs   r�getUsernamezProcServerMixin.getUsername�s���C�=��#�#rNc��t��rrOrXs   rrZzProcServerMixin.getUsername�s
���,�rc#�K�td�5}|j�|D]}|j����	ddd�y#1swYyxYw�w)Nz
/proc/net/tcp)�open�readline�strip)r�f�Ls   r�entrieszProcServerMixin.entries�sG����
�/�
"�	 �a�
�J�J�L��
 ���g�g�i��
 �	 �	 �	 �s�A�*A�	A�A�Ac��djtttjdtj
dt
|d�����S)N�.�4Bz=L�)�joinr(r�struct�unpack�packr))r�hexstrs  r�dottedQuadFromHexStringz'ProcServerMixin.dottedQuadFromHexString�s9���x�x���V�]�]�4����T�3�v�r�?�)K�L�M�
�	
rc�l�|jd�\}}|j|�}t|d�}||fS)N�:rf)r%rlr))r�packed�addr�ports    r�
unpackAddresszProcServerMixin.unpackAddress�s9���\�\�#�&�
��d��+�+�D�1���4��}���T�z�rc���|j�j�}|j|d�\}}|j|d�\}}t|d�}||f||f|fS)Nrr$�)r_r%rrr))rr0r1�	localAddr�	localPort�
remoteAddr�
remotePortrYs        r�	parseLinezProcServerMixin.parseLine�sl���
�
��"�"�$��#�1�1�%��(�;��	�9�!%�!3�!3�E�!�H�!=��
�J��%��(�m���9�%�
�J�'?��D�Drc���|j�D]G}|j|�\}}}||k(s�|d|dk(s�*|j|j|�fcSt	��)Nr)rbry�SYSTEM_NAMErZr)rrPrQ�entrurwrYs       rr=zProcServerMixin.lookup�sk���<�<�>�	A�C�)-����)<�&�I�z�3��]�*�y��|�}�Q�?O�/O��(�(�$�*:�*:�3�*?�@�@�	A�
�h�rr)rrrrr{�pwdrUrZ�ImportErrorrbrlrrryr=rrrrSrS�sO��N��K�
� �,4�	$�
� �
�
�E���;��	��s�&�	2�2rSc�6�eZdZeeeefZd�Zd�Z	d�Z
d�Zd�Zy)�IdentClientc��g|_yr)�queriesrs r�__init__zIdentClient.__init__�s	����rc��|jjtj�||f�t	|j�dkDr|jddS|jd||fz�|jddS)zK
        Lookup user information about the specified address pair.
        r���r�%d, %d)r��appendr�Deferredr&rD)rr2r3s   rr=zIdentClient.lookup�ss��	
�����U�^�^�-�|�\�J�K��t�|�|��q� ��<�<��#�A�&�&��
�
�h�,��!=�=�>��|�|�B���"�"rc�6�|jstjd|���y|jjd�\}}}|j	||�|jr7|jd|jdd|jddfz�yy)NzUnexpected server response: rr�rr$)r�r�msg�pop�
parseResponserD)rr0�d�_s    rr4zIdentClient.lineReceived�s����|�|��G�G�2�4�(�;�<��l�l�&�&�q�)�G�A�q�!����q�$�'��|�|��
�
�h�$�,�,�q�/�!�*<�d�l�l�1�o�a�>P�)Q�Q�R�rc�n�|jD]}|djt|���!g|_yrW)r��errbackr	)r�reason�qs   r�connectionLostzIdentClient.connectionLost�s1�����	-�A�
�a�D�L�L��F�+�,�	-���rc��|jdd�}t|�dk7r|jt|��yt	t
j|�\}}}|dk(rT|jD]*}|j|k(s�|j||��y|jt|��y|j||f�y)Nrnr$��ERROR)
r%r&r�r	r(rr_�
errorTypesr
�callback)r�deferredr0r1�ports�type�addInfo�ets        rr�zIdentClient.parseResponse�s����
�
�3��"���u�:��?����Z��-�.�#&�s�y�y�%�#8� �E�4���w���/�/��B��*�*�g�5� �(�(��D��2���� � ��D�!1�2��!�!�4��/�2rN)
rrrr	rrrr�r�r=r4r�r�rrrr�r��s*���f�k�:�>�J��	#�S��

3rr�)r	rrrr!r�rS)rrh�twisted.internetr�twisted.protocolsr�twisted.pythonrrr*r+�	Exceptionr	rrr�LineOnlyReceiverr!rSr��__all__rrr�<module>r�s���
��"�#�'�
�	��	�%��%�!�Z�!�&�*�&�%��%�V�%�(�(�V�r/�/�d,3�%�(�(�,3�^�r

Zerion Mini Shell 1.0