diff --git a/lyrebird/mitm/mitm_script.py b/lyrebird/mitm/mitm_script.py index 657304bc..e68fe779 100644 --- a/lyrebird/mitm/mitm_script.py +++ b/lyrebird/mitm/mitm_script.py @@ -20,7 +20,7 @@ def to_mock_server(flow: http.HTTPFlow): if raw_url.port: raw_host += f':{raw_url.port}' # mock path 为/mock开头加上原始url - flow.request.path = '/mock/' + flow.request.url + flow.request.path = '/' + flow.request.url # mock scheme 统一为http flow.request.scheme = 'http' # mock server port @@ -43,15 +43,7 @@ def request(flow: http.HTTPFlow): if 'mitm.it' in flow.request.url: # Support mitm.it return - - if not PROXY_FILTERS: - to_mock_server(flow) - return - - for _filter in PROXY_FILTERS: - if re.search(_filter, flow.request.url): - to_mock_server(flow) - break + to_mock_server(flow) def responseheaders(flow): diff --git a/lyrebird/mitm/proxy_server.py b/lyrebird/mitm/proxy_server.py index e7f75ca4..81663356 100644 --- a/lyrebird/mitm/proxy_server.py +++ b/lyrebird/mitm/proxy_server.py @@ -51,6 +51,7 @@ def wait_for_mitm_start(self, config, logger): def start_mitmdump(self, queue, config, logger, mitmdump_path): proxy_port = config.get('proxy.port', 4272) mock_port = config.get('mock.port', 9090) + extra_mock_port = config.get('extra.mock.port', 9999) ''' --ignore_hosts: The ignore_hosts option allows you to specify a regex which is matched against a host:port @@ -79,7 +80,7 @@ def start_mitmdump(self, queue, config, logger, mitmdump_path): if ignore_hosts: mitm_arguments += ['--ignore-hosts', ignore_hosts] mitmenv = os.environ - mitmenv['PROXY_PORT'] = str(mock_port) + mitmenv['PROXY_PORT'] = str(extra_mock_port) mitmenv['PROXY_FILTERS'] = json.dumps(config.get('proxy.filters', [])) logger.info('HTTP proxy server starting...') subprocess.Popen([str(mitmdump_path)]+mitm_arguments, env=mitmenv)