mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +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 = 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(
|
group.add_argument(
|
||||||
"--wport",
|
"--wport",
|
||||||
action="store", type=int, dest="wport", default=8081,
|
action="store", type=int, dest="wport", default=8081,
|
||||||
|
@ -132,6 +132,7 @@ def mitmweb(args=None): # pragma: no cover
|
|||||||
try:
|
try:
|
||||||
web_options = web.master.Options(**cmdline.get_common_options(args))
|
web_options = web.master.Options(**cmdline.get_common_options(args))
|
||||||
web_options.intercept = args.intercept
|
web_options.intercept = args.intercept
|
||||||
|
web_options.open_browser = args.open_browser
|
||||||
web_options.wdebug = args.wdebug
|
web_options.wdebug = args.wdebug
|
||||||
web_options.wiface = args.wiface
|
web_options.wiface = args.wiface
|
||||||
web_options.wport = args.wport
|
web_options.wport = args.wport
|
||||||
|
@ -20,12 +20,14 @@ class Options(options.Options):
|
|||||||
self,
|
self,
|
||||||
*, # all args are keyword-only.
|
*, # all args are keyword-only.
|
||||||
intercept: Optional[str] = None,
|
intercept: Optional[str] = None,
|
||||||
|
open_browser: bool = True,
|
||||||
wdebug: bool = False,
|
wdebug: bool = False,
|
||||||
wport: int = 8081,
|
wport: int = 8081,
|
||||||
wiface: str = "127.0.0.1",
|
wiface: str = "127.0.0.1",
|
||||||
**kwargs
|
**kwargs
|
||||||
) -> None:
|
) -> None:
|
||||||
self.intercept = intercept
|
self.intercept = intercept
|
||||||
|
self.open_browser = open_browser
|
||||||
self.wdebug = wdebug
|
self.wdebug = wdebug
|
||||||
self.wport = wport
|
self.wport = wport
|
||||||
self.wiface = wiface
|
self.wiface = wiface
|
||||||
@ -122,11 +124,13 @@ class WebMaster(master.Master):
|
|||||||
try:
|
try:
|
||||||
url = "http://{}:{}/".format(self.options.wiface, self.options.wport)
|
url = "http://{}:{}/".format(self.options.wiface, self.options.wport)
|
||||||
print("Server listening at {}".format(url), file=sys.stderr)
|
print("Server listening at {}".format(url), file=sys.stderr)
|
||||||
if not open_browser(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))
|
print("No webbrowser found. Please open a browser and point it to {}".format(url))
|
||||||
|
|
||||||
iol.start()
|
iol.start()
|
||||||
except (KeyboardInterrupt):
|
except KeyboardInterrupt:
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user