From 49c1532af76594338ffbd12e4daaed9501471f6f Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 13 Mar 2011 16:21:41 +1300 Subject: Add anticache support for mitmproxy Also stub out an option toggle command for anticache, killextra and norefresh options. --- libmproxy/console.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/libmproxy/console.py b/libmproxy/console.py index d9a70e74..f13bc933 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -27,10 +27,18 @@ class Stop(Exception): pass def format_keyvals(lst, key="key", val="text", space=5, indent=0): ret = [] if lst: - pad = max(len(i[0]) for i in lst if i) + space + pad = max(len(i[0]) for i in lst if i and i[0]) + space for i in lst: if i is None: ret.extend("\n") + elif i[0] is None: + ret.extend( + [ + " "*(pad + indent), + (val, i[1]), + "\n" + ] + ) else: ret.extend( [ @@ -679,7 +687,8 @@ class StatusBar(WWrap): r.append("[") r.append(("statusbar_highlight", "t")) r.append(":%s]"%self.master.stickycookie_txt) - + if self.master.anticache: + r.append("[anticache]") return r @@ -861,6 +870,7 @@ class ConsoleMaster(flow.FlowMaster): self.stickycookie = None self.stickyhosts = {} + self.anticache = options.anticache def spawn_external_viewer(self, data, contenttype): @@ -1054,6 +1064,10 @@ class ConsoleMaster(flow.FlowMaster): ("j, k", "up, down"), ("l", "set limit filter pattern"), ("L", "load saved flows"), + ("o", "toggle options:"), + (None, " anticache: modify requests to prevent cached responses"), + (None, " killextra: kill requests not part of server replay"), + (None, " norefresh: disable server replay response refresh"), ("q", "quit / return to connection list"), ("Q", "quit without confirm prompt"), ("r", "replay request"), @@ -1282,6 +1296,17 @@ class ConsoleMaster(flow.FlowMaster): self.load_flows ) k = None + elif k == "o": + self.prompt_onekey( + "Options", + ( + ("anticache", "a"), + ("killextra", "k"), + ("norefresh", "n"), + ), + self._change_options + ) + k = None elif k == "t": self.prompt( "Sticky cookie: ", @@ -1298,6 +1323,10 @@ class ConsoleMaster(flow.FlowMaster): if a != "n": raise Stop + def _change_options(self, a): + if a == "a": + self.anticache = not self.anticache + def shutdown(self): for i in self.state.flow_list: i.kill() -- cgit v1.2.3