diff options
Diffstat (limited to 'libmproxy/console')
| -rw-r--r-- | libmproxy/console/__init__.py | 31 | ||||
| -rw-r--r-- | libmproxy/console/contentview.py | 5 | ||||
| -rw-r--r-- | libmproxy/console/flowlist.py | 3 | ||||
| -rw-r--r-- | libmproxy/console/grideditor.py | 11 |
4 files changed, 29 insertions, 21 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 210e2b95..536b0bac 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -442,16 +442,18 @@ class ConsoleMaster(flow.FlowMaster): else: self.add_event("Method %s error: %s"%(method, val[1])) - def run_script_once(self, path, f): - if not path: + def run_script_once(self, command, f): + if not command: return - self.add_event("Running script on flow: %s"%path) - ret = self.get_script(shlex.split(path, posix=(os.name != "nt"))) - if ret[0]: + self.add_event("Running script on flow: %s"%command) + + try: + s = script.Script(command, self) + except script.ScriptError, v: self.statusbar.message("Error loading script.") - self.add_event("Error loading script:\n%s"%ret[0]) + self.add_event("Error loading script:\n%s"%v.args[0]) return - s = ret[1] + if f.request: self._run_script_method("request", s, f) if f.response: @@ -460,15 +462,15 @@ class ConsoleMaster(flow.FlowMaster): self._run_script_method("error", s, f) s.unload() self.refresh_flow(f) - self.state.last_script = path + self.state.last_script = command - def set_script(self, path): - if not path: + def set_script(self, command): + if not command: return - ret = self.load_script(path) + ret = self.load_script(command) if ret: self.statusbar.message(ret) - self.state.last_script = path + self.state.last_script = command def toggle_eventlog(self): self.eventlog = not self.eventlog @@ -781,6 +783,9 @@ class ConsoleMaster(flow.FlowMaster): else: self.view_flowlist() + def edit_scripts(self, *args, **kwargs): + pass + def loop(self): changed = True try: @@ -883,7 +888,7 @@ class ConsoleMaster(flow.FlowMaster): grideditor.ScriptEditor( self, [[i.argv[0]] for i in self.scripts], - None + self.edit_scripts ) ) #if self.scripts: diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py index 70f39d83..a5cb679e 100644 --- a/libmproxy/console/contentview.py +++ b/libmproxy/console/contentview.py @@ -397,7 +397,10 @@ class ViewProtobuf: name = "Protocol Buffer" prompt = ("protobuf", "p") - content_types = ["application/x-protobuf"] + content_types = [ + "application/x-protobuf", + "application/x-protobuffer", + ] @staticmethod def is_available(): diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py index 7f11a7e2..6ba97733 100644 --- a/libmproxy/console/flowlist.py +++ b/libmproxy/console/flowlist.py @@ -12,7 +12,6 @@ def _mkhelp(): ("e", "toggle eventlog"), ("F", "toggle follow flow list"), ("l", "set limit filter pattern"), - ("/", "same as above"), ("L", "load saved flows"), ("r", "replay request"), ("V", "revert changes to request"), @@ -245,7 +244,7 @@ class FlowListBox(urwid.ListBox): self.master.clear_flows() elif key == "e": self.master.toggle_eventlog() - elif key == "l" or key == "/": + elif key == "l": self.master.prompt("Limit: ", self.master.state.limit_txt, self.master.set_limit) elif key == "L": self.master.path_prompt( diff --git a/libmproxy/console/grideditor.py b/libmproxy/console/grideditor.py index fa5142f3..bbdde4e3 100644 --- a/libmproxy/console/grideditor.py +++ b/libmproxy/console/grideditor.py @@ -1,7 +1,7 @@ import copy, re, os import urwid import common -from .. import utils, filt +from .. import utils, filt, script from netlib import http_uastrings @@ -486,8 +486,9 @@ class PathEditor(GridEditor): class ScriptEditor(GridEditor): title = "Editing scripts" columns = 1 - headings = ("Path",) + headings = ("Command",) def is_error(self, col, val): - return False - - + try: + script.Script.parse_command(val) + except script.ScriptError, v: + return str(v) |
