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,
|
||||
anticomp = options.anticomp,
|
||||
client_replay = options.client_replay,
|
||||
flow_detail = options.flow_detail,
|
||||
kill = options.kill,
|
||||
no_server = options.no_server,
|
||||
refresh_server_playback = not options.norefresh,
|
||||
|
|
|
@ -15,6 +15,7 @@ class Options(object):
|
|||
"anticache",
|
||||
"anticomp",
|
||||
"client_replay",
|
||||
"flow_detail",
|
||||
"keepserving",
|
||||
"kill",
|
||||
"no_server",
|
||||
|
@ -125,7 +126,7 @@ class DumpMaster(flow.FlowMaster):
|
|||
try:
|
||||
self.load_flows(freader)
|
||||
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:
|
||||
self.start_app(self.o.app_host, self.o.app_port, self.o.app_external)
|
||||
|
@ -139,10 +140,11 @@ class DumpMaster(flow.FlowMaster):
|
|||
raise DumpError(v.strerror)
|
||||
return flows
|
||||
|
||||
def add_event(self, e, level="info"):
|
||||
#FIXME refactor_loglevel
|
||||
print >> self.outfile, e
|
||||
self.outfile.flush()
|
||||
def add_event(self, e, level="error"):
|
||||
needed = dict(error=1, info=2, debug=3)[level]
|
||||
if self.o.verbosity >= needed:
|
||||
print >> self.outfile, e
|
||||
self.outfile.flush()
|
||||
|
||||
def indent(self, n, t):
|
||||
l = str(t).strip().split("\n")
|
||||
|
@ -154,12 +156,12 @@ class DumpMaster(flow.FlowMaster):
|
|||
return
|
||||
|
||||
if f.response:
|
||||
sz = utils.pretty_size(len(f.response.content))
|
||||
if self.o.verbosity > 0:
|
||||
if self.o.flow_detail > 0:
|
||||
sz = utils.pretty_size(len(f.response.content))
|
||||
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)
|
||||
if self.o.verbosity > 2:
|
||||
if self.o.flow_detail > 2:
|
||||
if utils.isBin(f.response.content):
|
||||
d = netlib.utils.hexdump(f.response.content)
|
||||
d = "\n".join("%s\t%s %s"%i for i in d)
|
||||
|
@ -172,16 +174,16 @@ class DumpMaster(flow.FlowMaster):
|
|||
elif f.error:
|
||||
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, result
|
||||
elif self.o.verbosity == 2:
|
||||
elif self.o.flow_detail == 2:
|
||||
print >> self.outfile, str_request(f.request, self.showhost)
|
||||
print >> self.outfile, self.indent(4, f.request.headers)
|
||||
print >> self.outfile
|
||||
print >> self.outfile, result
|
||||
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, self.indent(4, f.request.headers)
|
||||
if utils.isBin(f.request.content):
|
||||
|
@ -191,7 +193,7 @@ class DumpMaster(flow.FlowMaster):
|
|||
print >> self.outfile
|
||||
print >> self.outfile, result
|
||||
print >> self.outfile, "\n"
|
||||
if self.o.verbosity:
|
||||
if self.o.flow_detail:
|
||||
self.outfile.flush()
|
||||
|
||||
def handle_log(self, l):
|
||||
|
|
|
@ -478,9 +478,9 @@ class FlowMaster(controller.Master):
|
|||
"host": host,
|
||||
"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
|
||||
|
||||
|
|
6
mitmdump
6
mitmdump
|
@ -21,12 +21,18 @@ if __name__ == '__main__':
|
|||
action="store_true", dest="keepserving", default=False,
|
||||
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)
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
if options.quiet:
|
||||
options.verbose = 0
|
||||
options.flow_detail = 0
|
||||
|
||||
proxyconfig = process_proxy_options(parser, options)
|
||||
if options.no_server:
|
||||
|
|
Loading…
Reference in New Issue