mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Add a --sysinfo flag to all daemons
This dumps all the platform information and mitmproxy version data we'd normally need to troubleshoot an issue.
This commit is contained in:
parent
4831e3e0bc
commit
e367b88195
@ -219,6 +219,11 @@ def basic_options(parser):
|
||||
action='version',
|
||||
version="%(prog)s" + " " + version.VERSION
|
||||
)
|
||||
parser.add_argument(
|
||||
'--sysinfo',
|
||||
action='store_true',
|
||||
dest='sysinfo',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--shortversion',
|
||||
action='version',
|
||||
|
@ -11,6 +11,7 @@ from mitmproxy import exceptions
|
||||
from mitmproxy.proxy import config
|
||||
from mitmproxy.proxy import server
|
||||
from netlib import version_check
|
||||
from netlib import debug
|
||||
|
||||
|
||||
def assert_utf8_env():
|
||||
@ -40,6 +41,15 @@ def get_server(dummy_server, options):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def process_options(parser, options):
|
||||
if options.sysinfo:
|
||||
print(debug.sysinfo())
|
||||
sys.exit(0)
|
||||
if options.quiet:
|
||||
options.verbose = 0
|
||||
return config.process_proxy_options(parser, options)
|
||||
|
||||
|
||||
def mitmproxy(args=None): # pragma: no cover
|
||||
if os.name == "nt":
|
||||
print("Error: mitmproxy's console interface is not supported on Windows. "
|
||||
@ -52,10 +62,8 @@ def mitmproxy(args=None): # pragma: no cover
|
||||
|
||||
parser = cmdline.mitmproxy()
|
||||
options = parser.parse_args(args)
|
||||
if options.quiet:
|
||||
options.verbose = 0
|
||||
proxy_config = process_options(parser, options)
|
||||
|
||||
proxy_config = config.process_proxy_options(parser, options)
|
||||
console_options = console.master.Options(**cmdline.get_common_options(options))
|
||||
console_options.palette = options.palette
|
||||
console_options.palette_transparent = options.palette_transparent
|
||||
@ -81,11 +89,10 @@ def mitmdump(args=None): # pragma: no cover
|
||||
|
||||
parser = cmdline.mitmdump()
|
||||
options = parser.parse_args(args)
|
||||
proxy_config = process_options(parser, options)
|
||||
if options.quiet:
|
||||
options.verbose = 0
|
||||
options.flow_detail = 0
|
||||
|
||||
proxy_config = config.process_proxy_options(parser, options)
|
||||
dump_options = dump.Options(**cmdline.get_common_options(options))
|
||||
dump_options.flow_detail = options.flow_detail
|
||||
dump_options.keepserving = options.keepserving
|
||||
@ -116,10 +123,8 @@ def mitmweb(args=None): # pragma: no cover
|
||||
parser = cmdline.mitmweb()
|
||||
|
||||
options = parser.parse_args(args)
|
||||
if options.quiet:
|
||||
options.verbose = 0
|
||||
proxy_config = process_options(parser, options)
|
||||
|
||||
proxy_config = config.process_proxy_options(parser, options)
|
||||
web_options = web.master.Options(**cmdline.get_common_options(options))
|
||||
web_options.intercept = options.intercept
|
||||
web_options.wdebug = options.wdebug
|
||||
|
26
netlib/debug.py
Normal file
26
netlib/debug.py
Normal file
@ -0,0 +1,26 @@
|
||||
import platform
|
||||
from netlib import version
|
||||
|
||||
"""
|
||||
Some utilities to help with debugging.
|
||||
"""
|
||||
|
||||
def sysinfo():
|
||||
data = [
|
||||
"Mitmproxy verison: %s"%version.VERSION,
|
||||
"Python version: %s"%platform.python_version(),
|
||||
"Platform: %s"%platform.platform(),
|
||||
]
|
||||
d = platform.linux_distribution()
|
||||
if d[0]:
|
||||
data.append("Linux distro: %s %s %s"%d)
|
||||
|
||||
d = platform.mac_ver()
|
||||
if d[0]:
|
||||
data.append("Mac version: %s %s %s"%d)
|
||||
|
||||
d = platform.win32_ver()
|
||||
if d[0]:
|
||||
data.append("Windows version: %s %s %s %s"%d)
|
||||
|
||||
return "\n".join(data)
|
Loading…
Reference in New Issue
Block a user