2222
2323from utils .filter import filter_process
2424from utils .shortcuts import shortcuts_process
25+ from utils .cancel_inspect import cancel_inspect_process
2526from utils .logger import configure_file_logger , configure_console_logger
2627
2728class ProxyServer :
@@ -35,7 +36,7 @@ class ProxyServer:
3536 def __init__ (self , host , port , debug , access_log , block_log ,
3637 html_403 , no_filter , filter_mode , no_logging_access , no_logging_block , ssl_inspect ,
3738 blocked_sites , blocked_url , shortcuts , inspect_ca_cert ,
38- inspect_ca_key , inspect_certs_folder ):
39+ inspect_ca_key , inspect_certs_folder , cancel_inspect ):
3940 """
4041 Initializes the ProxyServer instance with the provided configurations.
4142 """
@@ -53,10 +54,14 @@ def __init__(self, host, port, debug, access_log, block_log,
5354 self .shortcuts_proc = None
5455 self .shortcuts_queue = multiprocessing .Queue ()
5556 self .shortcuts_result_queue = multiprocessing .Queue ()
57+ self .cancel_inspect_proc = None
58+ self .cancel_inspect_queue = multiprocessing .Queue ()
59+ self .cancel_inspect_result_queue = multiprocessing .Queue ()
5660 self .console_logger = configure_console_logger ()
5761 self .config_blocked_sites = blocked_sites
5862 self .config_blocked_url = blocked_url
5963 self .config_shortcuts = shortcuts
64+ self .config_cancel_inspect = cancel_inspect
6065 self .config_inspect_cert = inspect_ca_cert
6166 self .config_inspect_key = inspect_ca_key
6267 self .config_inspect_certs_folder = inspect_certs_folder
@@ -145,6 +150,18 @@ def start(self):
145150 self .shortcuts_proc .start ()
146151 self .console_logger .debug ("[*] Starting the shortcuts process..." )
147152
153+ if self .config_cancel_inspect and os .path .isfile (self .config_cancel_inspect ):
154+ self .cancel_inspect_proc = multiprocessing .Process (
155+ target = cancel_inspect_process ,
156+ args = (
157+ self .cancel_inspect_queue ,
158+ self .cancel_inspect_result_queue ,
159+ self .config_cancel_inspect
160+ )
161+ )
162+ self .cancel_inspect_proc .start ()
163+ self .console_logger .debug ("[*] Starting the cancel inspection process..." )
164+
148165 server = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
149166 server .bind (self .host_port )
150167 server .listen (10 )
@@ -198,11 +215,8 @@ def handle_http_request(self, client_socket, request):
198215
199216 if self .config_shortcuts :
200217 domain , _ = self .parse_url (url )
201- print (url )
202- print (domain )
203218 self .shortcuts_queue .put (domain )
204219 shortcut_url = self .shortcuts_result_queue .get ()
205- print (shortcut_url )
206220 if shortcut_url :
207221 response = (
208222 f"HTTP/1.1 302 Found\r \n "
@@ -344,6 +358,10 @@ def handle_https_connection(self, client_socket, first_line):
344358 return
345359
346360 if self .ssl_inspect :
361+ self .cancel_inspect_queue .put (server_host )
362+ not_inspect = self .cancel_inspect_result_queue .get ()
363+
364+ if self .ssl_inspect and not not_inspect :
347365 cert_path , key_path = self .generate_certificate (server_host )
348366 client_context = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
349367 client_context .load_cert_chain (certfile = cert_path , keyfile = key_path )
0 commit comments