+
    Dfj]                         R t ^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	 ^RI
Ht ^RIHt ^RIHt ^RIHt  ! R	 R
]	P$                  4      t ! R R]	P(                  4      tR R ltR# )z@
Protocol wrapper that provides HAProxy PROXY protocol support.
)OptionalUnion)
interfaces)_WrapperServerEndpoint)policies)_info)InvalidProxyHeader)V1Parser)V2Parserc                   x   a a ] tR t^t oRtV3R lV 3R lltV3R lR ltV3R lR ltV3R lR	 ltR
t	Vt
V ;t# )HAProxyProtocolWrapperz
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.
c                N   < V ^8  d   QhRS[ P                  RS[P                  /# )   factorywrappedProtocol)r   WrappingFactoryr   	IProtocol)format__classdict__s   "D/usr/lib/python3/dist-packages/twisted/protocols/haproxy/_wrapper.py__annotate__#HAProxyProtocolWrapper.__annotate__   s)     = =//=BLBVBV=    c                B   < \         SV `  W4       R V n        R V n        R # N)super__init__
_proxyInfo_parser)selfr   r   	__class__s   &&&r   r   HAProxyProtocolWrapper.__init__   s      	2598<r   c                $   < V ^8  d   QhRS[ RR/# )r   datareturnN)bytes)r   r   s   "r   r   r   $   s     " " "4 "r   c                   V P                   e   V P                  P                  V4      # V P                  pVf   \	        V4      ^8  dM   VR,          \
        P                  8X  d1   \        VR,          4      ^,          ^ 8X  d   \        4       ;V n        pMP\	        V4      ^8  d/   VR,          \        P                  8X  d   \        4       ;V n        pMV P                  4        R #  VP                  V4      w  V n         pV'       d   V P                  P                  V4       R # R #   \         d    T P                  4         R # i ; i)N:N   N:r'      N:N   N)r   r   dataReceivedr   lenr
   PREFIXordr	   PROXYSTRloseConnectionfeedr   )r   r#   parser	remainings   &&  r   r*   #HAProxyProtocolWrapper.dataReceived$   s    ??&''44T::>D	RI0U$z1T9(0
2vTaDH0A0A$A(0
2v##%	")/T):&DOY$$11)< ! 	"!	"s   ' D' D' 'EEc                4   < V ^8  d   QhRS[ P                  /# r   r$   r   IAddress)r   r   s   "r   r   r   =        ( (,, (r   c                    V P                   '       d3   V P                   P                  '       d   V P                   P                  # V P                  '       g   Q hV P                  P                  4       # r   )r   source	transportgetPeerr   s   &r   r<   HAProxyProtocolWrapper.getPeer=   sK    ???t555??)))~~~~~~%%''r   c                4   < V ^8  d   QhRS[ P                  /# r5   r6   )r   r   s   "r   r   r   C   r8   r   c                    V P                   '       d3   V P                   P                  '       d   V P                   P                  # V P                  '       g   Q hV P                  P                  4       # r   )r   destinationr;   getHostr=   s   &r   rB   HAProxyProtocolWrapper.getHostC   sK    ???t:::??...~~~~~~%%''r   )r   r   )__name__
__module____qualname____firstlineno____doc__r   r*   r<   rB   __static_attributes____classdictcell____classcell__)r    r   s   @@r   r   r      s7     = =" "2( (( ( (r   r   c                   :   a  ] tR t^Jt o Rt]tV 3R lR ltRtV t	R# )HAProxyWrappingFactoryzD
A Factory wrapper that adds PROXY protocol support to connections.
c                    < V ^8  d   QhRS[ /# r5   )str)r   r   s   "r   r   #HAProxyWrappingFactory.__annotate__Q   s     & &3 &r   c                    \         P                  P                  V P                  4      '       d   V P                  P	                  4       pM V P                  P
                  P                  pV R2# )zs
Annotate the wrapped factory's log prefix with some text indicating
the PROXY protocol is in use.

@rtype: C{str}
z (PROXY))r   ILoggingContext
providedBywrappedFactory	logPrefixr    rD   )r   rU   s   & r   rU    HAProxyWrappingFactory.logPrefixQ   sY     %%001D1DEE++557I++55>>IH%%r    N)
rD   rE   rF   rG   rH   r   protocolrU   rI   rJ   )r   s   @r   rM   rM   J   s      &H& &r   rM   c                D    V ^8  d   QhR\         P                  R\        /# )r   wrappedEndpointr$   )r   IStreamServerEndpointr   )r   s   "r   r   r   _   s&     K K55KKr   c                "    \        V \        4      # )a  
Wrap an endpoint with PROXY protocol support, so that the transport's
C{getHost} and C{getPeer} methods reflect the attributes of the proxied
connection rather than the underlying connection.

@param wrappedEndpoint: The underlying listening endpoint.
@type wrappedEndpoint: L{IStreamServerEndpoint}

@return: a new listening endpoint that speaks the PROXY protocol.
@rtype: L{IStreamServerEndpoint}
)r   rM   )rZ   s   &r   proxyEndpointr]   _   s     "/3IJJr   N)rH   typingr   r   twisted.internetr   twisted.internet.endpointsr   twisted.protocolsr    r   _exceptionsr   	_v1parserr	   	_v2parserr
   ProtocolWrapperr   r   rM   r]   rW   r   r   <module>rg      sO    # ' = &  +  3(X55 3(l&X55 &*Kr   