文件操作 - _wrapper.cpython-310.pyc
返回文件管理
返回主菜单
删除本文件
文件: /usr/lib/python3/dist-packages/twisted/protocols/haproxy/__pycache__/_wrapper.cpython-310.pyc
编辑文件内容
o �b] � @ s� d Z ddlmZmZ ddlmZ ddlmZ ddlm Z ddl mZ ddlm Z dd lmZ dd lmZ G dd� de j�ZG d d� de j�Zdejdefdd�ZdS )z@ Protocol wrapper that provides HAProxy PROXY protocol support. � )�Optional�Union)� interfaces)�_WrapperServerEndpoint)�policies� )�_info)�InvalidProxyHeader)�V1Parser)�V2Parserc s` e Zd ZdZdejdejf� fdd�Zde ddfd d �Z dejfdd�Zdejfd d�Z � ZS )�HAProxyProtocolWrappera A Protocol wrapper that provides HAProxy support. This protocol reads the PROXY stream header, v1 or v2, parses the provided connection data, and modifies the behavior of getPeer and getHost to return the data provided by the PROXY header. �factory�wrappedProtocolc s t � �||� d | _d | _d S �N)�super�__init__� _proxyInfo�_parser)�selfr r �� __class__� �D/usr/lib/python3/dist-packages/twisted/protocols/haproxy/_wrapper.pyr s zHAProxyProtocolWrapper.__init__�data�returnNc C s� | j d ur| j�|�S | j}|d u rPt|�dkr4|d d� tjkr4t|dd� �d@ dkr4t� | _}nt|�dkrJ|d d� tj krJt� | _}n| � � d S z|�|�\| _ }|rd| j�|� W d S W d S tyt | � � Y d S w )N� � � �� � � � ) r r �dataReceivedr �lenr �PREFIX�ordr �PROXYSTR�loseConnection�feedr )r r �parser� remainingr r r r"