Add the --host option, which uses the value in the Host header for dispaly URLs.

- Can be toggled with "o" then "h" in mitmproxy
- Useful for transparent mode
This commit is contained in:
Aldo Cortesi
2013-03-17 17:31:35 +13:00
parent 790ad468e4
commit 0e993bec6f
9 changed files with 56 additions and 8 deletions

View File

@@ -174,6 +174,8 @@ class StatusBar(common.WWrap):
opts.append("anticache")
if self.master.anticomp:
opts.append("anticomp")
if self.master.showhost:
opts.append("showhost")
if not self.master.refresh_server_playback:
opts.append("norefresh")
if self.master.killextra:
@@ -338,6 +340,7 @@ class Options(object):
"refresh_server_playback",
"rfile",
"script",
"showhost",
"replacements",
"rheaders",
"setheaders",
@@ -398,6 +401,7 @@ class ConsoleMaster(flow.FlowMaster):
self.killextra = options.kill
self.rheaders = options.rheaders
self.nopop = options.nopop
self.showhost = options.showhost
self.eventlog = options.eventlog
self.eventlist = urwid.SimpleListWalker([])
@@ -918,6 +922,7 @@ class ConsoleMaster(flow.FlowMaster):
(
("anticache", "a"),
("anticomp", "c"),
("showhost", "h"),
("killextra", "k"),
("norefresh", "n"),
("no-upstream-certs", "u"),
@@ -957,6 +962,10 @@ class ConsoleMaster(flow.FlowMaster):
self.anticache = not self.anticache
if a == "c":
self.anticomp = not self.anticomp
if a == "h":
self.showhost = not self.showhost
self.sync_list_view()
self.refresh_flow(self.currentflow)
elif a == "k":
self.killextra = not self.killextra
elif a == "n":

View File

@@ -177,7 +177,7 @@ class FlowCache:
flowcache = FlowCache()
def format_flow(f, focus, extended=False, padding=2):
def format_flow(f, focus, extended=False, hostheader=False, padding=2):
d = dict(
intercepting = f.intercepting,
@@ -185,7 +185,7 @@ def format_flow(f, focus, extended=False, padding=2):
req_is_replay = f.request.is_replay(),
req_method = f.request.method,
req_acked = f.request.reply.acked,
req_url = f.request.get_url(),
req_url = f.request.get_url(hostheader=hostheader),
err_msg = f.error.msg if f.error else None,
resp_code = f.response.code if f.response else None,

View File

@@ -105,7 +105,7 @@ class ConnectionItem(common.WWrap):
common.WWrap.__init__(self, w)
def get_text(self):
return common.format_flow(self.flow, self.f)
return common.format_flow(self.flow, self.f, hostheader=self.master.showhost)
def selectable(self):
return True

View File

@@ -88,11 +88,11 @@ footer = [
class FlowViewHeader(common.WWrap):
def __init__(self, master, f):
self.master, self.flow = master, f
self.w = common.format_flow(f, False, extended=True, padding=0)
self.w = common.format_flow(f, False, extended=True, padding=0, hostheader=self.master.showhost)
def refresh_flow(self, f):
if f == self.flow:
self.w = common.format_flow(f, False, extended=True, padding=0)
self.w = common.format_flow(f, False, extended=True, padding=0, hostheader=self.master.showhost)
class CallbackCache:

View File

@@ -97,6 +97,10 @@ class HelpView(urwid.ListBox):
common.highlight_key("anticomp", "c") +
[("text", ": prevent compressed responses")]
),
(None,
common.highlight_key("showhost", "h") +
[("text", ": use Host header for URL display")]
),
(None,
common.highlight_key("killextra", "k") +
[("text", ": kill requests not part of server replay")]