ó
    Ö›‘h‹  ã                   ó–   • S r SSKJrJr  SSKJr  SSKJr  SSKJ	r	J
r
  SSKJrJrJrJr  \" \
R                   5       " S S	5      5       rg
)zD
IProxyParser implementation for version one of the PROXY protocol.
é    )ÚTupleÚUnion)Úimplementer)Úaddressé   )Ú_infoÚ_interfaces)ÚInvalidNetworkProtocolÚInvalidProxyHeaderÚMissingAddressDataÚconvertErrorc                   ó°   • \ rS rSrSrSrSrSrSr\\\4r	Sr
SS
 jrS\S\\\R                   \4   \S   4   4S jr\S\S\R                   4S j5       rSrg	)ÚV1Parseré   zá
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   
ÚreturnNc                 ó   • SU l         g )Nó    ©Úbuffer)Úselfs    ÚgC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/protocols/haproxy/_v1parser.pyÚ__init__ÚV1Parser.__init__,   s	   € Øˆ�r   Údata©NNc                 óˆ  • U =R                   U-  sl         [        U R                   5      S:”  a$  U R                  U R                   ;  a
  [        5       eU R                   R	                  U R                  S5      n[        U5      S:”  d  gSU l         UR                  5       nUR                  5       nU R                  U5      nXS4$ )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Úinfos         r   ÚfeedÚV1Parser.feed/   s—   € ð" 	�Š�tÑ�Üˆt�{‰{Ó˜cÓ! d§l¡l¸$¿+¹+Ó&EÜ$Ó&Ð&Ø—‘×#Ñ# D§L¡L°!Ó4ˆÜ�5‹z˜A‹~ØØˆŒØ—I‘I“Kˆ	Ø—‘“ˆØ�z‰z˜&Ó!ˆØÐ Ð r   Úlinec                 óÚ  • UnSnSnSnSnSnSn[        [        [        5         UR                  SS5      u  p1SSS5        X0R                  :w  a
  [        5       e[        [        [
        5         UR                  SS5      u  pASSS5        X@R                  ;  a
  [        5       eX@R                  :X  a  [        R                  " USS5      $ [        [        [        5         UR                  SS5      u  pQSSS5        [        [        [        5         UR                  SS5      u  pqSSS5        [        [        [        5         UR                  SS5      u  paSSS5        [        [        [        5         UR                  S5      S   nSSS5        X@R                  :X  ar  [        R                  " U[        R                  " SUR                  5       [        U5      5      [        R                  " SUR                  5       [        U5      5      5      $ [        R                  " U[        R                   " SUR                  5       [        U5      5      [        R                   " SUR                  5       [        U5      5      5      $ ! , (       d  f       GNP= f! , (       d  f       GN= f! , (       d  f       GN¹= f! , (       d  f       GNš= f! , (       d  f       GN{= f! , (       d  f       GN\= f)a0  
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   ÚTCP)r   Ú
ValueErrorr   r    ÚPROXYSTRr
   ÚALLOWED_NET_PROTOSÚUNKNOWN_PROTOr   Ú	ProxyInfor   Ú
TCP4_PROTOr   ÚIPv4AddressÚdecodeÚintÚIPv6Address)	Úclsr)   ÚoriginalLineÚproxyStrÚnetworkProtocolÚ
sourceAddrÚ
sourcePortÚdestAddrÚdestPorts	            r   r"   ÚV1Parser.parseL   s-  € ð( ˆØˆØˆØˆ
Øˆ
ØˆØˆäœ*Ô&8Õ9Ø!ŸZ™Z¨¨aÓ0‰NˆH÷ :ð —|‘|Ó#Ü$Ó&Ð&äœ*Ô&<Õ=Ø$(§J¡J¨t°QÓ$7Ñ!ˆO÷ >ð ×"8Ñ"8Ó8Ü(Ó*Ð*à×/Ñ/Ó/Ü—?’? <°°tÓ<Ð<äœ*Ô&8Õ9Ø#Ÿz™z¨$°Ó2ÑˆJ÷ :ô œ*Ô&8Õ9Ø!ŸZ™Z¨¨aÓ0‰NˆH÷ :ô œ*Ô&8Õ9Ø#Ÿz™z¨$°Ó2ÑˆJ÷ :ô œ*Ô&8Õ9Ø—z‘z $Ó'¨Ñ*ˆH÷ :ð Ÿn™nÓ,Ü—?’?ØÜ×#Ò# E¨:×+<Ñ+<Ó+>ÄÀJÃÓPÜ×#Ò# E¨8¯?©?Ó+<¼cÀ(»mÓLóð ô �ŠØÜ×Ò  z×'8Ñ'8Ó':¼CÀ
»OÓLÜ×Ò  x§¡Ó'8¼#¸h»-ÓHó
ð 	
÷E :Ö9ú÷ >Ö=ú÷ :Ö9ú÷ :Ö9ú÷ :Ö9ú÷ :Ö9úsG   £JÁ-JÃJ%ÄJ7Å K	Å1KÊ
JÊ
J"Ê%
J4Ê7
KË	
KË
K*r   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r.   r0   r2   Ú
TCP6_PROTOr/   r   r   Úbytesr   r   r   r1   r'   Úclassmethodr"   Ú__static_attributes__© r   r   r   r      s–   † ñð €HØ€MØ€JØ€JàØØðÐð
 €Gôð!Øð!à	ˆu�U—_‘_ eÐ+Ñ,¨e°JÑ.?Ð?Ñ	@ô!ð: ðA
˜ð A
 5§?¡?ó A
ó óA
r   r   N)rD   Útypingr   r   Úzope.interfacer   Útwisted.internetr   Ú r   r	   Ú_exceptionsr
   r   r   r   ÚIProxyParserr   rI   r   r   Ú<module>rP      sI   ðñ÷  å &å $ß  ÷ó ñ ˆ[×%Ñ%Ó&÷v
ð v
ó 'ñv
r   