Enable --host option for mitmdump

This commit is contained in:
Aldo Cortesi 2013-03-17 17:43:31 +13:00
parent 0e993bec6f
commit e50da8164f
1 changed files with 6 additions and 5 deletions

View File

@ -57,12 +57,12 @@ def str_response(resp):
return r return r
def str_request(req): def str_request(req, showhost):
if req.client_conn: if req.client_conn:
c = req.client_conn.address[0] c = req.client_conn.address[0]
else: else:
c = "[replay]" c = "[replay]"
r = "%s %s %s"%(c, req.method, req.get_url()) r = "%s %s %s"%(c, req.method, req.get_url(showhost))
if req.stickycookie: if req.stickycookie:
r = "[stickycookie] " + r r = "[stickycookie] " + r
return r return r
@ -76,6 +76,7 @@ class DumpMaster(flow.FlowMaster):
self.anticache = options.anticache self.anticache = options.anticache
self.anticomp = options.anticomp self.anticomp = options.anticomp
self.eventlog = options.eventlog self.eventlog = options.eventlog
self.showhost = options.showhost
self.refresh_server_playback = options.refresh_server_playback self.refresh_server_playback = options.refresh_server_playback
if filtstr: if filtstr:
@ -179,16 +180,16 @@ class DumpMaster(flow.FlowMaster):
result = " << %s"%f.error.msg result = " << %s"%f.error.msg
if self.o.verbosity == 1: if self.o.verbosity == 1:
print >> self.outfile, str_request(f.request) 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.verbosity == 2:
print >> self.outfile, str_request(f.request) 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.verbosity >= 3:
print >> self.outfile, str_request(f.request) 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):
print >> self.outfile, self.indent(4, netlib.utils.hexdump(f.request.content)) print >> self.outfile, self.indent(4, netlib.utils.hexdump(f.request.content))