aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/mitmproxy_launcher/launch.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/mitmproxy_launcher/launch.py')
-rw-r--r--src/hydrilla/mitmproxy_launcher/launch.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/hydrilla/mitmproxy_launcher/launch.py b/src/hydrilla/mitmproxy_launcher/launch.py
index 82766b9..4fe31db 100644
--- a/src/hydrilla/mitmproxy_launcher/launch.py
+++ b/src/hydrilla/mitmproxy_launcher/launch.py
@@ -29,6 +29,7 @@
import sys
import os
import subprocess as sp
+import typing as t
from pathlib import Path
# The following import requires at least Python 3.8. There is no point adding
@@ -54,13 +55,16 @@ addons = [HaketiloAddon()]
help=_('cli_opt.haketilo.listen_host'))
@click.option('-p', '--port', default=8080, type=click.IntRange(1, 65535),
help=_('cli_opt.haketilo.port'))
+@click.option('-L/-l', '--launch-browser/--no-launch-browser', default=True,
+ help=_('cli_opt.haketilo.launch_browser'))
@click.option('-d', '--directory', default='~/.haketilo/',
type=click.Path(file_okay=False),
help=_('cli_opt.haketilo.dir'))
@click.version_option(version=_version.version, prog_name='Haketilo proxy',
message=_('%(prog)s_%(version)s_license'),
help=_('cli_opt.haketilo.version'))
-def launch(listen_host: str, port: int, directory: str):
+def launch(listen_host: str, port: int, launch_browser: bool, directory: str) \
+ -> t.NoReturn:
directory_path = Path(os.path.expanduser(directory)).resolve()
directory_path.mkdir(parents=True, exist_ok=True)
@@ -69,6 +73,8 @@ def launch(listen_host: str, port: int, directory: str):
script_path.write_text(addon_script_text)
+ launch_browser_str = 'true' if launch_browser else 'false'
+
sys.argv = [
'mitmdump',
'--listen-host', listen_host,
@@ -77,6 +83,9 @@ def launch(listen_host: str, port: int, directory: str):
'--set', 'upstream_cert=false',
'--set', 'connection_strategy=lazy',
'--set', f'haketilo_dir={directory_path}',
+ '--set', f'haketilo_listen_host={listen_host}',
+ '--set', f'haketilo_listen_port={port}',
+ '--set', f'haketilo_launch_browser={launch_browser_str}',
'--scripts', str(script_path)
]