%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlmZmZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
mZmZee
j �Gd�d	��Zy
)zD
IProxyParser implementation for version one of the PROXY protocol.
�)�Tuple�Union)�implementer)�address�)�_info�_interfaces)�InvalidNetworkProtocol�InvalidProxyHeader�MissingAddressData�convertErrorc��eZdZdZdZdZdZdZeeefZdZ	dd	�Z
d
edee
ejefe
dffd�Zed
edejfd��Zy)�V1Parserz�
    PROXY protocol version one header parser.

    Version one of the PROXY protocol is a human readable format represented
    by a single, newline delimited binary string that contains all of the
    relevant source and destination data.
    sPROXYsUNKNOWNsTCP4sTCP6s
�returnNc��d|_y)N�)�buffer)�selfs �E/usr/lib/python3/dist-packages/twisted/protocols/haproxy/_v1parser.py�__init__zV1Parser.__init__,s	����r�data�NNc��|xj|z
c_t|j�dkDr"|j|jvr
t��|jj	|jd�}t|�dkDsyd|_|j�}|j�}|j
|�}||fS)a�
        Consume a chunk of data and attempt to parse it.

        @param data: A bytestring.
        @type data: L{bytes}

        @return: A two-tuple containing, in order, a
            L{_interfaces.IProxyInfo} and any bytes fed to the
            parser that followed the end of the header.  Both of these values
            are None until a complete header is parsed.

        @raises InvalidProxyHeader: If the bytes fed to the parser create an
            invalid PROXY header.
        �krrr)r�len�NEWLINEr�split�pop�parse)rr�lines�	remaining�header�infos      r�feedz
V1Parser.feed/s���"	
���t����t�{�{��c�!�d�l�l�$�+�+�&E�$�&�&����#�#�D�L�L�!�4���5�z�A�~������I�I�K�	�������z�z�&�!���i� � r�linec��|}d}d}d}d}d}d}ttt�5|jdd�\}}ddd�||jk7r
t��ttt
�5|jdd�\}}ddd�||jvr
t��||jk(rtj|dd�Sttt�5|jdd�\}}ddd�ttt�5|jdd�\}}ddd�ttt�5|jdd�\}}ddd�ttt�5|jd�d}ddd�||jk(rotj|tjd|j�t|��tjd|j�t|���Stj|tj d|j�t|��tj d|j�t|���S#1swY��GxYw#1swY��	xYw#1swY���xYw#1swY���xYw#1swY��\xYw#1swY��8xYw)a�
        Parse a bytestring as a full PROXY protocol header line.

        @param line: A bytestring that represents a valid HAProxy PROXY
            protocol header line.
        @type line: bytes

        @return: A L{_interfaces.IProxyInfo} containing the parsed data.

        @raises InvalidProxyHeader: If the bytestring does not represent a
            valid PROXY header.

        @raises InvalidNetworkProtocol: When no protocol can be parsed or is
            not one of the allowed values.

        @raises MissingAddressData: When the protocol is TCP* but the header
            does not contain a complete set of addresses and ports.
        N� rr�TCP)r
�
ValueErrorrr�PROXYSTRr
�ALLOWED_NET_PROTOS�
UNKNOWN_PROTOr�	ProxyInfor�
TCP4_PROTOr�IPv4Address�decode�int�IPv6Address)	�clsr%�originalLine�proxyStr�networkProtocol�
sourceAddr�
sourcePort�destAddr�destPorts	         rrzV1Parser.parseLsi��(�������
��
�����
�*�&8�
9�	1�!�Z�Z��a�0�N�H�d�	1��s�|�|�#�$�&�&�
�*�&<�
=�	8�$(�J�J�t�Q�$7�!�O�T�	8��#�"8�"8�8�(�*�*��c�/�/�/��?�?�<��t�<�<�
�*�&8�
9�	3�#�z�z�$��2��J��	3��*�&8�
9�	1�!�Z�Z��a�0�N�H�d�	1��*�&8�
9�	3�#�z�z�$��2��J��	3��*�&8�
9�	+��z�z�$�'��*�H�	+��c�n�n�,��?�?���#�#�E�:�+<�+<�+>��J��P��#�#�E�8�?�?�+<�c�(�m�L��
���������z�'8�'8�':�C�
�O�L�����x���'8�#�h�-�H�
�	
�E	1�	1��	8�	8��	3�	3��	1�	1��	3�	3��	+�	+�sG�I>�.J�J�J%�J2�4J?�>J�J�J"�%J/�2J<�?K	)rN)�__name__�
__module__�__qualname__�__doc__r*r,r.�
TCP6_PROTOr+rr�bytesrrrr-r$�classmethodr�rrrrs�����H��M��J��J������
�G��!��!�	�u�U�_�_�e�+�,�e�J�.?�?�	@�!�:�A
��A
�5�?�?�A
��A
rrN)r>�typingrr�zope.interfacer�twisted.internetr�rr	�_exceptionsr
rrr
�IProxyParserrrBrr�<module>rIsI��� �&�$� ���
�[�
%�
%�&�v
�v
�'�v
r

Zerion Mini Shell 1.0