diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-11-24 16:37:45 +0100 |
---|---|---|
committer | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2016-11-25 17:20:14 +0100 |
commit | 1d3cb9eeb8972eb1c3a022365b645c23380cacb4 (patch) | |
tree | 67ff226a61b1cf7e5a01af59e2aee918efcc8ad9 | |
parent | e3dc46a8cd835671ff2a5a85ef9fcbfa70030f5e (diff) | |
download | mitmproxy-1d3cb9eeb8972eb1c3a022365b645c23380cacb4.tar.gz mitmproxy-1d3cb9eeb8972eb1c3a022365b645c23380cacb4.tar.bz2 mitmproxy-1d3cb9eeb8972eb1c3a022365b645c23380cacb4.zip |
mitmweb: add --no-browser
-rw-r--r-- | mitmproxy/tools/cmdline.py | 5 | ||||
-rw-r--r-- | mitmproxy/tools/main.py | 1 | ||||
-rw-r--r-- | mitmproxy/tools/web/master.py | 10 |
3 files changed, 13 insertions, 3 deletions
diff --git a/mitmproxy/tools/cmdline.py b/mitmproxy/tools/cmdline.py index d5a43f28..f1f8ce42 100644 --- a/mitmproxy/tools/cmdline.py +++ b/mitmproxy/tools/cmdline.py @@ -868,6 +868,11 @@ def mitmweb(): group = parser.add_argument_group("Mitmweb") group.add_argument( + "--no-browser", + action="store_false", dest="open_browser", + help="Don't start a browser" + ) + group.add_argument( "--wport", action="store", type=int, dest="wport", default=8081, metavar="PORT", diff --git a/mitmproxy/tools/main.py b/mitmproxy/tools/main.py index 478690eb..d276944d 100644 --- a/mitmproxy/tools/main.py +++ b/mitmproxy/tools/main.py @@ -132,6 +132,7 @@ def mitmweb(args=None): # pragma: no cover try: web_options = web.master.Options(**cmdline.get_common_options(args)) web_options.intercept = args.intercept + web_options.open_browser = args.open_browser web_options.wdebug = args.wdebug web_options.wiface = args.wiface web_options.wport = args.wport diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py index 5457fb40..ac028fd1 100644 --- a/mitmproxy/tools/web/master.py +++ b/mitmproxy/tools/web/master.py @@ -20,12 +20,14 @@ class Options(options.Options): self, *, # all args are keyword-only. intercept: Optional[str] = None, + open_browser: bool = True, wdebug: bool = False, wport: int = 8081, wiface: str = "127.0.0.1", **kwargs ) -> None: self.intercept = intercept + self.open_browser = open_browser self.wdebug = wdebug self.wport = wport self.wiface = wiface @@ -122,11 +124,13 @@ class WebMaster(master.Master): try: url = "http://{}:{}/".format(self.options.wiface, self.options.wport) print("Server listening at {}".format(url), file=sys.stderr) - if not open_browser(url): - print("No webbrowser found. Please open a browser and point it to {}".format(url)) + if self.options.open_browser: + success = open_browser(url) + if not success: + print("No webbrowser found. Please open a browser and point it to {}".format(url)) iol.start() - except (KeyboardInterrupt): + except KeyboardInterrupt: self.shutdown() |