mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
mitmweb: add --no-browser
This commit is contained in:
parent
e3dc46a8cd
commit
1d3cb9eeb8
@ -867,6 +867,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,
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user