§
    £	Êjž  ã                   ó&  — d dl Z d dlZddlmZ ddlmZmZ ddlmZm	Z	m
Z
mZ  G d„ dee j        ¦  «        Z G d„ d	ee j        ¦  «        Z G d
„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ dej        ¦  «        Z G d„ d¦  «        ZdS )é    Né   )Ú
StrOrBytes)ÚProtocolErrorÚ
SOCKSError)ÚAddressTypeÚdecode_addressÚencode_addressÚ#get_address_port_tuple_from_addressc                   ó"   — e Zd ZdZdZdZdZdZdS )ÚSOCKS4ReplyCodez"Enumeration of SOCKS4 reply codes.ó   Zó   [ó   \ó   ]N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚREQUEST_GRANTEDÚREQUEST_REJECTED_OR_FAILEDÚCONNECTION_FAILEDÚAUTHENTICATION_FAILED© ó    ú>C:\Projects\Muse2API\.venv\Lib\site-packages\socksio/socks4.pyr   r      s-   € € € € € Ø,Ð,à€OØ!(ÐØÐØ#ÐÐÐr   r   c                   ó   — e Zd ZdZdZdZdS )ÚSOCKS4Commandz$Enumeration of SOCKS4 command codes.ó   ó   N)r   r   r   r   ÚCONNECTÚBINDr   r   r   r   r      s   € € € € € Ø.Ð.à€GØ€D€D€Dr   r   c            
       óô   — e Zd ZU dZeed<   eed<   eed<   dZe	j
        e         ed<   e	 ddede	j        ee	j        eef         f         de	j
        e         dd fd	„¦   «         Zdde	j
        e         defd
„ZdS )ÚSOCKS4Requestaj  Encapsulates a request to the SOCKS4 proxy server

    Args:
        command: The command to request.
        port: The port number to connect to on the target host.
        addr: IP address of the target host.
        user_id: Optional user ID to be included in the request, if not supplied
            the user *must* provide one in the packing operation.
    ÚcommandÚportÚaddrNÚuser_idÚaddressÚreturnc                 ó¦   — t          |¦  «        \  }}t          |¦  «        \  }}|t          j        k    rt	          d¦  «        ‚ | ||||¬¦  «        S )aº  Convenience class method to build an instance from command and address.

        Args:
            command: The command to request.
            address: A string in the form 'HOST:PORT' or a tuple of ip address string
                and port number.
            user_id: Optional user ID.

        Returns:
            A SOCKS4Request instance.

        Raises:
            SOCKSError: If a domain name or IPv6 address was supplied.
        z;IPv6 addresses and domain names are not supported by SOCKS4©r$   r&   r%   r'   )r
   r	   r   ÚIPV4r   ©Úclsr$   r(   r'   r%   ÚatypeÚencoded_addrs          r   Úfrom_addresszSOCKS4Request.from_address.   se   € õ* <¸GÑDÔD‰ˆ�Ý,¨WÑ5Ô5Ñˆˆ|Ø•KÔ$Ò$Ð$ÝØMñô ð ð ˆs˜7¨¸DÈ'ÐRÑRÔRÐRr   c                 ó´   — |p| j         }|€t          d¦  «        ‚d                     d| j        | j                             dd¬¦  «        | j        |dg¦  «        S )	áš  Packs the instance into a raw binary in the appropriate form.

        Args:
            user_id: Optional user ID as an override, if not provided the instance's
                will be used, if none was provided at initialization an error is raised.

        Returns:
            The packed request.

        Raises:
            SOCKSError: If no user was specified in this call or on initialization.
        Nú-SOCKS4 requires a user_id, none was specifiedr   ó   é   Úbig©Ú	byteorderó    ©r'   r   Újoinr$   r%   Úto_bytesr&   ©Úselfr'   s     r   ÚdumpszSOCKS4Request.dumpsK   sj   € ð Ð)˜Tœ\ˆØˆ?ÝÐLÑMÔMÐMà�xŠxàØ”Ø”×$Ò$ Q°%Ð$Ñ8Ô8Ø”	ØØðñ	
ô 	
ð 		
r   ©N©r   r   r   r   r   Ú__annotations__ÚintÚbytesr'   ÚtypingÚOptionalÚclassmethodÚUnionr   ÚTupler1   r@   r   r   r   r#   r#      sú   € € € € € € ðð ð ÐÐÑØ
€I€I�IØ
€K€K�KØ&*€GˆVŒ_˜UÔ#Ð*Ð*Ñ*àð
 +/ð	Sð SàðSð ”˜j¨&¬,°zÀ3°Ô*GÐGÔHðSð ” Ô'ð	Sð
 
ðSð Sð Sñ „[ðSð8
ð 
˜Vœ_¨UÔ3ð 
¸uð 
ð 
ð 
ð 
ð 
ð 
r   r#   c            
       óô   — e Zd ZU dZeed<   eed<   eed<   dZe	j
        e         ed<   e	 ddede	j        ee	j        eef         f         de	j
        e         dd fd	„¦   «         Zdde	j
        e         defd
„ZdS )ÚSOCKS4ARequestak  Encapsulates a request to the SOCKS4A proxy server

    Args:
        command: The command to request.
        port: The port number to connect to on the target host.
        addr: IP address of the target host.
        user_id: Optional user ID to be included in the request, if not supplied
            the user *must* provide one in the packing operation.
    r$   r%   r&   Nr'   r(   r)   c                 óh   — t          |¦  «        \  }}t          |¦  «        \  }} | ||||¬¦  «        S )ac  Convenience class method to build an instance from command and address.

        Args:
            command: The command to request.
            address: A string in the form 'HOST:PORT' or a tuple of ip address string
                and port number.
            user_id: Optional user ID.

        Returns:
            A SOCKS4ARequest instance.
        r+   )r
   r	   r-   s          r   r1   zSOCKS4ARequest.from_addressx   s@   € õ$ <¸GÑDÔD‰ˆ�Ý,¨WÑ5Ô5Ñˆˆ|Øˆs˜7¨¸DÈ'ÐRÑRÔRÐRr   c           
      ó¸   — |p| j         }|€t          d¦  «        ‚d                     d| j        | j                             dd¬¦  «        d|d	| j        d	g¦  «        S )
r3   Nr4   r   r5   r6   r7   r8   s      ÿr:   r;   r>   s     r   r@   zSOCKS4ARequest.dumpsŽ   sp   € ð Ð)˜Tœ\ˆØˆ?ÝÐLÑMÔMÐMà�xŠxàØ”Ø”×$Ò$ Q°%Ð$Ñ8Ô8Ø#ØØØ”	Øð	ñ
ô 
ð 	
r   rA   rB   r   r   r   rL   rL   h   sú   € € € € € € ðð ð ÐÐÑØ
€I€I�IØ
€K€K�KØ&*€GˆVŒ_˜UÔ#Ð*Ð*Ñ*àð
 +/ð	Sð SàðSð ”˜j¨&¬,°zÀ3°Ô*GÐGÔHðSð ” Ô'ð	Sð
 
ðSð Sð Sñ „[ðSð*
ð 
˜Vœ_¨UÔ3ð 
¸uð 
ð 
ð 
ð 
ð 
ð 
r   rL   c                   óh   — e Zd ZU dZeed<   eed<   ej        e	         ed<   e
dedd fd„¦   «         ZdS )	ÚSOCKS4ReplyzÒEncapsulates a reply from the SOCKS4 proxy server

    Args:
        reply_code: The code representing the type of reply.
        port: The port number returned.
        addr: Optional IP address returned.
    Ú
reply_coder%   r&   Údatar)   c           
      ór  — t          |¦  «        dk    s|dd…         dk    rt          d¦  «        ‚	  | t          |dd…         ¦  «        t                               |dd…         d¬	¦  «        t          t          j        |dd…         ¦  «        ¬
¦  «        S # t          $ r}t          d¦  «        |‚d}~ww xY w)z½Unpacks the reply data into an instance.

        Returns:
            The unpacked reply instance.

        Raises:
            ProtocolError: If the data does not match the spec.
        é   r   r   r:   zMalformed replyr6   é   r7   r8   )rQ   r%   r&   N)	Úlenr   r   rD   Ú
from_bytesr   r   r,   Ú
ValueError)r.   rR   Úexcs      r   ÚloadszSOCKS4Reply.loadsº   sÊ   € õ ˆt‰9Œ9˜Š>ˆ>˜T ! A #œY¨'Ò1Ð1ÝÐ 1Ñ2Ô2Ð2ð	<Ø�3Ý*¨4°°!°¬9Ñ5Ô5Ý—^’^ D¨¨1¨¤I¸�^Ñ?Ô?Ý#¥KÔ$4°d¸1¸Q¸3´iÑ@Ô@ðñ ô ð øõ
 ð 	<ð 	<ð 	<ÝÐ 1Ñ2Ô2¸Ð;øøøøð	<øøøs   ²A$B Â
B6Â!B1Â1B6N)r   r   r   r   r   rC   rD   rF   rG   ÚstrrH   rE   rZ   r   r   r   rP   rP   ­   sv   € € € € € € ðð ð  ÐÐÑØ
€I€I�IØ
Œ/˜#Ô
ÐÐÑàð<˜ð < =ð <ð <ð <ñ „[ð<ð <ð <r   rP   c                   ód   — e Zd ZdZdefd„Zdej        ee	f         ddfd„Z
dedefd	„Zdefd
„ZdS )ÚSOCKS4ConnectionzøEncapsulates a SOCKS4 and SOCKS4A connection.

    Packs request objects into data suitable to be send and unpacks reply
    data into their appropriate reply objects.

    Args:
        user_id: The user ID to be sent as part of the requests.
    r'   c                 ó`   — || _         t          ¦   «         | _        t          ¦   «         | _        d S rA   )r'   Ú	bytearrayÚ_data_to_sendÚ_received_datar>   s     r   Ú__init__zSOCKS4Connection.__init__Û   s'   € ØˆŒå&™[œ[ˆÔÝ'™kœkˆÔÐÐr   Úrequestr)   Nc                 ój   — |j         p| j         }| xj        |                     |¬¦  «        z  c_        dS )z‹Packs a request object and adds it to the send data buffer.

        Args:
            request: The request instance to be packed.
        )r'   N)r'   r`   r@   )r?   rc   r'   s      r   ÚsendzSOCKS4Connection.sendá   s:   € ð ”/Ð1 T¤\ˆØÐÔ˜gŸmšm°G˜mÑ<Ô<Ñ<ÐÔÐÐr   rR   c                 óz   — | xj         |z  c_         t                               t          | j         ¦  «        ¦  «        S )z½Unpacks response data into a reply object.

        Args:
            data: The raw response data from the proxy server.

        Returns:
            The appropriate reply object.
        )ra   rP   rZ   rE   ©r?   rR   s     r   Úreceive_datazSOCKS4Connection.receive_dataê   s7   € ð 	ÐÔ˜tÑ#ÐÔÝ× Ò ¥ tÔ':Ñ!;Ô!;Ñ<Ô<Ð<r   c                 óT   — t          | j        ¦  «        }t          ¦   «         | _        |S )zqReturns the data to be sent via the I/O library of choice.

        Also clears the connection's buffer.
        )rE   r`   r_   rg   s     r   Údata_to_sendzSOCKS4Connection.data_to_sendö   s%   € õ
 �TÔ'Ñ(Ô(ˆÝ&™[œ[ˆÔØˆr   )r   r   r   r   rE   rb   rF   rI   r#   rL   re   rP   rh   rj   r   r   r   r]   r]   Ñ   s¤   € € € € € ðð ð* ð *ð *ð *ð *ð=˜FœL¨¸Ð)FÔGð =ÈDð =ð =ð =ð =ð
= ð 
=¨;ð 
=ð 
=ð 
=ð 
=ð˜eð ð ð ð ð ð r   r]   )ÚenumrF   Ú_typesr   Ú
exceptionsr   r   Úutilsr   r   r	   r
   rE   ÚEnumr   r   Ú
NamedTupler#   rL   rP   r]   r   r   r   ú<module>rq      s¥  ðØ €€€Ø €€€à Ð Ð Ð Ð Ð Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1ðð ð ð ð ð ð ð ð ð ð ð ð$ð $ð $ð $ð $�e˜TœYñ $ô $ð $ðð ð ð ð �E˜4œ9ñ ô ð ðG
ð G
ð G
ð G
ð G
�FÔ%ñ G
ô G
ð G
ðTB
ð B
ð B
ð B
ð B
�VÔ&ñ B
ô B
ð B
ðJ!<ð !<ð !<ð !<ð !<�&Ô#ñ !<ô !<ð !<ðH,ð ,ð ,ð ,ð ,ñ ,ô ,ð ,ð ,ð ,r   