mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
add -d switch to mitmdump to compensate for old verbosity functionality
This commit is contained in:
parent
aefb30ea60
commit
7e86744226
@ -161,6 +161,7 @@ def get_common_options(options):
|
|||||||
anticache = options.anticache,
|
anticache = options.anticache,
|
||||||
anticomp = options.anticomp,
|
anticomp = options.anticomp,
|
||||||
client_replay = options.client_replay,
|
client_replay = options.client_replay,
|
||||||
|
flow_detail = options.flow_detail,
|
||||||
kill = options.kill,
|
kill = options.kill,
|
||||||
no_server = options.no_server,
|
no_server = options.no_server,
|
||||||
refresh_server_playback = not options.norefresh,
|
refresh_server_playback = not options.norefresh,
|
||||||
|
@ -15,6 +15,7 @@ class Options(object):
|
|||||||
"anticache",
|
"anticache",
|
||||||
"anticomp",
|
"anticomp",
|
||||||
"client_replay",
|
"client_replay",
|
||||||
|
"flow_detail",
|
||||||
"keepserving",
|
"keepserving",
|
||||||
"kill",
|
"kill",
|
||||||
"no_server",
|
"no_server",
|
||||||
@ -125,7 +126,7 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
try:
|
try:
|
||||||
self.load_flows(freader)
|
self.load_flows(freader)
|
||||||
except flow.FlowReadError, v:
|
except flow.FlowReadError, v:
|
||||||
self.add_event("Flow file corrupted. Stopped loading.")
|
self.add_event("Flow file corrupted. Stopped loading.", "error")
|
||||||
|
|
||||||
if self.o.app:
|
if self.o.app:
|
||||||
self.start_app(self.o.app_host, self.o.app_port, self.o.app_external)
|
self.start_app(self.o.app_host, self.o.app_port, self.o.app_external)
|
||||||
@ -139,8 +140,9 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
raise DumpError(v.strerror)
|
raise DumpError(v.strerror)
|
||||||
return flows
|
return flows
|
||||||
|
|
||||||
def add_event(self, e, level="info"):
|
def add_event(self, e, level="error"):
|
||||||
#FIXME refactor_loglevel
|
needed = dict(error=1, info=2, debug=3)[level]
|
||||||
|
if self.o.verbosity >= needed:
|
||||||
print >> self.outfile, e
|
print >> self.outfile, e
|
||||||
self.outfile.flush()
|
self.outfile.flush()
|
||||||
|
|
||||||
@ -154,12 +156,12 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if f.response:
|
if f.response:
|
||||||
|
if self.o.flow_detail > 0:
|
||||||
sz = utils.pretty_size(len(f.response.content))
|
sz = utils.pretty_size(len(f.response.content))
|
||||||
if self.o.verbosity > 0:
|
|
||||||
result = " << %s %s"%(str_response(f.response), sz)
|
result = " << %s %s"%(str_response(f.response), sz)
|
||||||
if self.o.verbosity > 1:
|
if self.o.flow_detail > 1:
|
||||||
result = result + "\n\n" + self.indent(4, f.response.headers)
|
result = result + "\n\n" + self.indent(4, f.response.headers)
|
||||||
if self.o.verbosity > 2:
|
if self.o.flow_detail > 2:
|
||||||
if utils.isBin(f.response.content):
|
if utils.isBin(f.response.content):
|
||||||
d = netlib.utils.hexdump(f.response.content)
|
d = netlib.utils.hexdump(f.response.content)
|
||||||
d = "\n".join("%s\t%s %s"%i for i in d)
|
d = "\n".join("%s\t%s %s"%i for i in d)
|
||||||
@ -172,16 +174,16 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
elif f.error:
|
elif f.error:
|
||||||
result = " << %s"%f.error.msg
|
result = " << %s"%f.error.msg
|
||||||
|
|
||||||
if self.o.verbosity == 1:
|
if self.o.flow_detail == 1:
|
||||||
print >> self.outfile, str_request(f.request, self.showhost)
|
print >> self.outfile, str_request(f.request, self.showhost)
|
||||||
print >> self.outfile, result
|
print >> self.outfile, result
|
||||||
elif self.o.verbosity == 2:
|
elif self.o.flow_detail == 2:
|
||||||
print >> self.outfile, str_request(f.request, self.showhost)
|
print >> self.outfile, str_request(f.request, self.showhost)
|
||||||
print >> self.outfile, self.indent(4, f.request.headers)
|
print >> self.outfile, self.indent(4, f.request.headers)
|
||||||
print >> self.outfile
|
print >> self.outfile
|
||||||
print >> self.outfile, result
|
print >> self.outfile, result
|
||||||
print >> self.outfile, "\n"
|
print >> self.outfile, "\n"
|
||||||
elif self.o.verbosity >= 3:
|
elif self.o.flow_detail >= 3:
|
||||||
print >> self.outfile, str_request(f.request, self.showhost)
|
print >> self.outfile, str_request(f.request, self.showhost)
|
||||||
print >> self.outfile, self.indent(4, f.request.headers)
|
print >> self.outfile, self.indent(4, f.request.headers)
|
||||||
if utils.isBin(f.request.content):
|
if utils.isBin(f.request.content):
|
||||||
@ -191,7 +193,7 @@ class DumpMaster(flow.FlowMaster):
|
|||||||
print >> self.outfile
|
print >> self.outfile
|
||||||
print >> self.outfile, result
|
print >> self.outfile, result
|
||||||
print >> self.outfile, "\n"
|
print >> self.outfile, "\n"
|
||||||
if self.o.verbosity:
|
if self.o.flow_detail:
|
||||||
self.outfile.flush()
|
self.outfile.flush()
|
||||||
|
|
||||||
def handle_log(self, l):
|
def handle_log(self, l):
|
||||||
|
@ -478,9 +478,9 @@ class FlowMaster(controller.Master):
|
|||||||
"host": host,
|
"host": host,
|
||||||
"port": port}).start()
|
"port": port}).start()
|
||||||
|
|
||||||
def add_event(self, e, level="info"):
|
def add_event(self, e, level="error"):
|
||||||
"""
|
"""
|
||||||
level: info, error
|
level: debug, info, error
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
6
mitmdump
6
mitmdump
@ -21,12 +21,18 @@ if __name__ == '__main__':
|
|||||||
action="store_true", dest="keepserving", default=False,
|
action="store_true", dest="keepserving", default=False,
|
||||||
help="Continue serving after client playback or file read. We exit by default."
|
help="Continue serving after client playback or file read. We exit by default."
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-d",
|
||||||
|
action="count", dest="flow_detail", default=1,
|
||||||
|
help="Increase flow detail display level. Can be passed multiple times."
|
||||||
|
)
|
||||||
parser.add_argument('args', nargs=argparse.REMAINDER)
|
parser.add_argument('args', nargs=argparse.REMAINDER)
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if options.quiet:
|
if options.quiet:
|
||||||
options.verbose = 0
|
options.verbose = 0
|
||||||
|
options.flow_detail = 0
|
||||||
|
|
||||||
proxyconfig = process_proxy_options(parser, options)
|
proxyconfig = process_proxy_options(parser, options)
|
||||||
if options.no_server:
|
if options.no_server:
|
||||||
|
Loading…
Reference in New Issue
Block a user