Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/twisted/protocols/haproxy/__pycache__/_v1parser.cpython-39.pyc
Ðазад
a k�h� � @ sp d Z ddlmZmZ ddlmZ ddlmZ ddlm Z m Z ddlmZm Z mZmZ ee j�G dd � d ��Zd S )zD IProxyParser implementation for version one of the PROXY protocol. � )�Tuple�Union)�implementer)�address� )�_info�_interfaces)�InvalidNetworkProtocol�InvalidProxyHeader�MissingAddressData�convertErrorc @ sx e Zd ZdZdZdZdZdZeeefZdZ dd�d d �Z eee ejef e d f d�d d�Zeeejd�dd��ZdS )�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. s PROXYs UNKNOWNs TCP4s TCP6s N)�returnc C s d| _ d S )N� )�buffer)�self� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/twisted/protocols/haproxy/_v1parser.py�__init__, s zV1Parser.__init__�NN)�datar c C sv | j |7 _ t| j �dkr.| j| j vr.t� �| j �| jd�}t|�dksNdS d| _ |�� }|�� }| �|�}||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. �k r r r )r �len�NEWLINEr �split�pop�parse)r r �lines� remaining�header�infor r r �feed/ s z V1Parser.feed)�liner c C s$ |}d}d}d}d}d}d}t tt�� |�dd�\}}W d � n1 sL0 Y || jkrft� �t tt�� |�dd�\}}W d � n1 s�0 Y || jvr�t� �|| jkr�t� |dd�S t tt �� |�dd�\}}W d � n1 s�0 Y t tt �� |�dd�\}}W d � n1 �s40 Y t tt �� |�dd�\}}W d � n1 �sp0 Y t tt �� |�d�d }W d � n1 �s�0 Y || jk�r�t� |t� d|�� t|��t� d|�� t|���S t� |t�d|�� t|��t�d|�� t|���S )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� r r ZTCP)r � ValueErrorr r �PROXYSTRr �ALLOWED_NET_PROTOS� UNKNOWN_PROTOr � ProxyInfor � TCP4_PROTOr �IPv4Address�decode�int�IPv6Address) �clsr"