@@ -32,7 +32,7 @@ class ProxyServer:
3232 """
3333 # pylint: disable=too-many-locals
3434 def __init__ (self , host , port , debug , access_log , block_log ,
35- html_403 , no_filter , no_logging_access , no_logging_block , ssl_inspect ,
35+ html_403 , no_filter , filter_mode , no_logging_access , no_logging_block , ssl_inspect ,
3636 blocked_sites , blocked_url , inspect_ca_cert , inspect_ca_key , inspect_certs_folder ):
3737 """
3838 Initializes the ProxyServer instance with the provided configurations.
@@ -41,6 +41,7 @@ def __init__(self, host, port, debug, access_log, block_log,
4141 self .debug = debug
4242 self .html_403 = html_403
4343 self .no_filter = no_filter
44+ self .filter_mode = filter_mode
4445 self .no_logging_access = no_logging_access
4546 self .no_logging_block = no_logging_block
4647 self .ssl_inspect = ssl_inspect
@@ -58,6 +59,7 @@ def __init__(self, host, port, debug, access_log, block_log,
5859 if not self .no_logging_block :
5960 self .block_logger = configure_file_logger (block_log , "BlockLogger" )
6061
62+ # pylint: disable=too-many-branches, too-many-statements
6163 def start (self ):
6264 """
6365 Starts the proxy server, initializes the filtering process if enabled,
@@ -71,6 +73,7 @@ def start(self):
7173 self .console_logger .debug ("[*] debug = %s" , self .debug )
7274 self .console_logger .debug ("[*] html_403 = %s" , self .html_403 )
7375 self .console_logger .debug ("[*] no_filter = %s" , self .no_filter )
76+ self .console_logger .debug ("[*] filter_mode = %s" , self .filter_mode )
7477 self .console_logger .debug ("[*] no_logging_access = %s" , self .no_logging_access )
7578 self .console_logger .debug ("[*] no_logging_block = %s" , self .no_logging_block )
7679 self .console_logger .debug ("[*] ssl_inspect = %s" , self .ssl_inspect )
@@ -101,19 +104,21 @@ def start(self):
101104 except OSError as e :
102105 self .console_logger .debug ("OS error deleting %s: %s" , file_path , e )
103106
104- if not os .path .exists (self .config_blocked_sites ):
105- with open (self .config_blocked_sites , "w" , encoding = 'utf-8' ):
106- pass
107- if not os .path .exists (self .config_blocked_url ):
108- with open (self .config_blocked_url , "w" , encoding = 'utf-8' ):
109- pass
107+ if self .filter_mode == "local" :
108+ if not os .path .exists (self .config_blocked_sites ):
109+ with open (self .config_blocked_sites , "w" , encoding = 'utf-8' ):
110+ pass
111+ if not os .path .exists (self .config_blocked_url ):
112+ with open (self .config_blocked_url , "w" , encoding = 'utf-8' ):
113+ pass
110114
111115 if not self .no_filter :
112116 self .filter_proc = multiprocessing .Process (
113117 target = filter_process ,
114118 args = (
115119 self .queue ,
116120 self .result_queue ,
121+ self .filter_mode ,
117122 self .config_blocked_sites ,
118123 self .config_blocked_url
119124 )
0 commit comments