From 14eeee3fbc0a839d918149765d2134d05cd14601 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 18 Oct 2022 17:18:32 +0200 Subject: [proxy] upon Haketilo launch automatically open Haketilo landing page in user's default web browser * The landing page instructs user to configure browser's proxy settings. * It is now possible to choose the IP address to listen on via command line parameter. * The browser launching behavior can be switched off via command line parameter. --- src/hydrilla/mitmproxy_launcher/launch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/hydrilla/mitmproxy_launcher') 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) ] -- cgit v1.2.3