<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    "@Wa                  	   @   s&  d Z ddlZzddlZddlZW n, ek
rL   ddlmZ ddlmZ Y nX ddl	Z	dd Z
G dd dejZG dd dejZG d	d
 d
ejejZedkr"ddlZzeejd ZW n eefk
r   dZY nX eee	jdeZeded    eded    dS )z
SocksiPy + urllib2 handler

version: 0.3
author: e<e@tr0ll.in>

This module provides a Handler which you can use with urllib2 to allow it to tunnel your connection through a socks.sockssocket socket, with out monkey patching the original socket...
    Nc                 C   s   |   }|| |S N)copyupdate)abd r   =/opt/alt/python38/lib/python3.8/site-packages/sockshandler.py
merge_dict   s    
r
   c                   @   s   e Zd ZdddZdd ZdS )SocksiPyConnectionNTc           	      O   s*   ||||||f| _ tjj| f|| d S r   )	proxyargshttplibHTTPConnection__init__	selfZ	proxytypeZ	proxyaddrZ	proxyportZrdnsusernamepasswordargskwargsr   r   r	   r      s    zSocksiPyConnection.__init__c                 C   sP   t  | _| jj| j  t| jttfkr8| j	| j | j
| j| jf d S r   )socks
socksocketsocksetproxyr   typetimeoutintfloat
settimeoutconnecthostportr   r   r   r	   r      s
    
zSocksiPyConnection.connect)NTNN__name__
__module____qualname__r   r   r   r   r   r	   r      s   
r   c                   @   s   e Zd ZdddZdd ZdS )SocksiPyConnectionSNTc           	      O   s*   ||||||f| _ tjj| f|| d S r   )r   r   HTTPSConnectionr   r   r   r   r	   r   '   s    zSocksiPyConnectionS.__init__c                 C   s\   t  }|j| j  t| jttfkr2|| j |	| j
| jf t|| j| j| _d S r   )r   r   r   r   r   r   r   r   r   r   r    r!   sslZwrap_socketZkey_fileZ	cert_filer   )r   r   r   r   r	   r   +   s    zSocksiPyConnectionS.connect)NTNNr#   r   r   r   r	   r'   &   s   
r'   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )SocksiPyHandlerc                 O   s   || _ || _tj|  d S r   )r   kwurllib2HTTPHandlerr   )r   r   r   r   r   r	   r   4   s    zSocksiPyHandler.__init__c                    s   d fdd	}  ||S )Nr   c                    s(   t  j|}t j| ||d|}|S N)r    r!   r   )r
   r+   r   r   r    r!   r   r   r+   Zconnr"   r   r	   build:   s    z(SocksiPyHandler.http_open.<locals>.build)Nr   Zdo_openr   Zreqr0   r   r"   r	   	http_open9   s    zSocksiPyHandler.http_openc                    s   d fdd	}  ||S )Nr   c                    s(   t  j|}t j| ||d|}|S r.   )r
   r+   r'   r   r/   r"   r   r	   r0   A   s    z)SocksiPyHandler.https_open.<locals>.build)Nr   r1   r2   r   r"   r	   
https_open@   s    zSocksiPyHandler.https_openN)r$   r%   r&   r   r3   r4   r   r   r   r	   r*   3   s   r*   __main__   iZ#  Z	localhostzHTTP: zhttp://httpbin.org/ipzHTTPS: zhttps://httpbin.org/ip) __doc__r)   r,   r   ImportErrorZurllib.requestZrequestZhttp.clientZclientr   r
   r   r   r(   r'   r-   ZHTTPSHandlerr*   r$   sysr   argvr!   
ValueError
IndexErrorZbuild_openerZPROXY_TYPE_SOCKS5Zopenerprintopenreaddecoder   r   r   r	   <module>   s*   

