mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-30 03:14:22 +00:00
Merge pull request #1453 from dufferzafar/limit-to-filter
Rename "Limit" feature to "Filter View"
This commit is contained in:
commit
7ea9726e5d
@ -772,7 +772,7 @@ def mitmproxy():
|
|||||||
help="Show event log."
|
help="Show event log."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-f", "--follow",
|
"--follow",
|
||||||
action="store_true", dest="follow",
|
action="store_true", dest="follow",
|
||||||
help="Follow flow list."
|
help="Follow flow list."
|
||||||
)
|
)
|
||||||
@ -791,9 +791,9 @@ def mitmproxy():
|
|||||||
help="Intercept filter expression."
|
help="Intercept filter expression."
|
||||||
)
|
)
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"-l", "--limit", action="store",
|
"-f", "--filter", action="store",
|
||||||
type=str, dest="limit", default=None,
|
type=str, dest="filter", default=None,
|
||||||
help="Limit filter expression."
|
help="Filter view expression."
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ def _mkhelp():
|
|||||||
("d", "delete flow"),
|
("d", "delete flow"),
|
||||||
("D", "duplicate flow"),
|
("D", "duplicate flow"),
|
||||||
("e", "toggle eventlog"),
|
("e", "toggle eventlog"),
|
||||||
|
("f", "filter view"),
|
||||||
("F", "toggle follow flow list"),
|
("F", "toggle follow flow list"),
|
||||||
("l", "set limit filter pattern"),
|
|
||||||
("L", "load saved flows"),
|
("L", "load saved flows"),
|
||||||
("m", "toggle flow mark"),
|
("m", "toggle flow mark"),
|
||||||
("M", "toggle marked flow view"),
|
("M", "toggle marked flow view"),
|
||||||
@ -367,11 +367,11 @@ class FlowListBox(urwid.ListBox):
|
|||||||
elif key == "G":
|
elif key == "G":
|
||||||
self.master.state.set_focus(self.master.state.flow_count())
|
self.master.state.set_focus(self.master.state.flow_count())
|
||||||
signals.flowlist_change.send(self)
|
signals.flowlist_change.send(self)
|
||||||
elif key == "l":
|
elif key == "f":
|
||||||
signals.status_prompt.send(
|
signals.status_prompt.send(
|
||||||
prompt = "Limit",
|
prompt = "Filter View",
|
||||||
text = self.master.state.limit_txt,
|
text = self.master.state.filter_txt,
|
||||||
callback = self.master.set_limit
|
callback = self.master.set_view_filter
|
||||||
)
|
)
|
||||||
elif key == "L":
|
elif key == "L":
|
||||||
signals.status_prompt_path.send(
|
signals.status_prompt_path.send(
|
||||||
|
@ -80,7 +80,7 @@ def _mkhelp():
|
|||||||
("r", "replay request"),
|
("r", "replay request"),
|
||||||
("V", "revert changes to request"),
|
("V", "revert changes to request"),
|
||||||
("v", "view body in external viewer"),
|
("v", "view body in external viewer"),
|
||||||
("w", "save all flows matching current limit"),
|
("w", "save all flows matching current view filter"),
|
||||||
("W", "save this flow"),
|
("W", "save this flow"),
|
||||||
("x", "delete body"),
|
("x", "delete body"),
|
||||||
("z", "encode/decode a request/response"),
|
("z", "encode/decode a request/response"),
|
||||||
|
@ -75,8 +75,8 @@ class ConsoleState(flow.State):
|
|||||||
self.update_focus()
|
self.update_focus()
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def set_limit(self, limit):
|
def set_view_filter(self, txt):
|
||||||
ret = super(ConsoleState, self).set_limit(limit)
|
ret = super(ConsoleState, self).set_view_filter(txt)
|
||||||
self.set_focus(self.focus)
|
self.set_focus(self.focus)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -153,8 +153,8 @@ class ConsoleState(flow.State):
|
|||||||
last_focus, _ = self.get_focus()
|
last_focus, _ = self.get_focus()
|
||||||
nearest_marked = self.get_nearest_matching_flow(last_focus, marked_filter)
|
nearest_marked = self.get_nearest_matching_flow(last_focus, marked_filter)
|
||||||
|
|
||||||
self.last_filter = self.limit_txt
|
self.last_filter = self.filter_txt
|
||||||
self.set_limit(marked_filter)
|
self.set_view_filter(marked_filter)
|
||||||
|
|
||||||
# Restore Focus
|
# Restore Focus
|
||||||
if last_focus.marked:
|
if last_focus.marked:
|
||||||
@ -171,7 +171,7 @@ class ConsoleState(flow.State):
|
|||||||
last_focus, _ = self.get_focus()
|
last_focus, _ = self.get_focus()
|
||||||
nearest_marked = self.get_nearest_matching_flow(last_focus, marked_filter)
|
nearest_marked = self.get_nearest_matching_flow(last_focus, marked_filter)
|
||||||
|
|
||||||
self.set_limit(self.last_filter)
|
self.set_view_filter(self.last_filter)
|
||||||
self.last_filter = ""
|
self.last_filter = ""
|
||||||
|
|
||||||
# Restore Focus
|
# Restore Focus
|
||||||
@ -203,7 +203,7 @@ class Options(mitmproxy.options.Options):
|
|||||||
eventlog=False, # type: bool
|
eventlog=False, # type: bool
|
||||||
follow=False, # type: bool
|
follow=False, # type: bool
|
||||||
intercept=False, # type: bool
|
intercept=False, # type: bool
|
||||||
limit=None, # type: Optional[str]
|
filter=None, # type: Optional[str]
|
||||||
palette=None, # type: Optional[str]
|
palette=None, # type: Optional[str]
|
||||||
palette_transparent=False, # type: bool
|
palette_transparent=False, # type: bool
|
||||||
no_mouse=False, # type: bool
|
no_mouse=False, # type: bool
|
||||||
@ -212,7 +212,7 @@ class Options(mitmproxy.options.Options):
|
|||||||
self.eventlog = eventlog
|
self.eventlog = eventlog
|
||||||
self.follow = follow
|
self.follow = follow
|
||||||
self.intercept = intercept
|
self.intercept = intercept
|
||||||
self.limit = limit
|
self.filter = filter
|
||||||
self.palette = palette
|
self.palette = palette
|
||||||
self.palette_transparent = palette_transparent
|
self.palette_transparent = palette_transparent
|
||||||
self.no_mouse = no_mouse
|
self.no_mouse = no_mouse
|
||||||
@ -234,8 +234,8 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
print("Intercept error: {}".format(r), file=sys.stderr)
|
print("Intercept error: {}".format(r), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if options.limit:
|
if options.filter:
|
||||||
self.set_limit(options.limit)
|
self.set_view_filter(options.filter)
|
||||||
|
|
||||||
self.set_stream_large_bodies(options.stream_large_bodies)
|
self.set_stream_large_bodies(options.stream_large_bodies)
|
||||||
|
|
||||||
@ -672,8 +672,8 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
def accept_all(self):
|
def accept_all(self):
|
||||||
self.state.accept_all(self)
|
self.state.accept_all(self)
|
||||||
|
|
||||||
def set_limit(self, txt):
|
def set_view_filter(self, txt):
|
||||||
v = self.state.set_limit(txt)
|
v = self.state.set_view_filter(txt)
|
||||||
signals.flowlist_change.send(self)
|
signals.flowlist_change.send(self)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@ -167,10 +167,10 @@ class StatusBar(urwid.WidgetWrap):
|
|||||||
r.append("[")
|
r.append("[")
|
||||||
r.append(("heading_key", "i"))
|
r.append(("heading_key", "i"))
|
||||||
r.append(":%s]" % self.master.state.intercept_txt)
|
r.append(":%s]" % self.master.state.intercept_txt)
|
||||||
if self.master.state.limit_txt:
|
if self.master.state.filter_txt:
|
||||||
r.append("[")
|
r.append("[")
|
||||||
r.append(("heading_key", "l"))
|
r.append(("heading_key", "f"))
|
||||||
r.append(":%s]" % self.master.state.limit_txt)
|
r.append(":%s]" % self.master.state.filter_txt)
|
||||||
if self.master.options.stickycookie:
|
if self.master.options.stickycookie:
|
||||||
r.append("[")
|
r.append("[")
|
||||||
r.append(("heading_key", "t"))
|
r.append(("heading_key", "t"))
|
||||||
|
@ -191,7 +191,7 @@ class State(object):
|
|||||||
self.intercept = None
|
self.intercept = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def limit_txt(self):
|
def filter_txt(self):
|
||||||
return getattr(self.view.filt, "pattern", None)
|
return getattr(self.view.filt, "pattern", None)
|
||||||
|
|
||||||
def flow_count(self):
|
def flow_count(self):
|
||||||
@ -225,8 +225,8 @@ class State(object):
|
|||||||
def load_flows(self, flows):
|
def load_flows(self, flows):
|
||||||
self.flows._extend(flows)
|
self.flows._extend(flows)
|
||||||
|
|
||||||
def set_limit(self, txt):
|
def set_view_filter(self, txt):
|
||||||
if txt == self.limit_txt:
|
if txt == self.filter_txt:
|
||||||
return
|
return
|
||||||
if txt:
|
if txt:
|
||||||
f = filt.parse(txt)
|
f = filt.parse(txt)
|
||||||
|
@ -68,7 +68,7 @@ def mitmproxy(args=None): # pragma: no cover
|
|||||||
console_options.eventlog = args.eventlog
|
console_options.eventlog = args.eventlog
|
||||||
console_options.follow = args.follow
|
console_options.follow = args.follow
|
||||||
console_options.intercept = args.intercept
|
console_options.intercept = args.intercept
|
||||||
console_options.limit = args.limit
|
console_options.filter = args.filter
|
||||||
console_options.no_mouse = args.no_mouse
|
console_options.no_mouse = args.no_mouse
|
||||||
|
|
||||||
server = process_options(parser, console_options, args)
|
server = process_options(parser, console_options, args)
|
||||||
|
@ -76,7 +76,7 @@ class TestConsoleState:
|
|||||||
self._add_response(c)
|
self._add_response(c)
|
||||||
self._add_request(c)
|
self._add_request(c)
|
||||||
self._add_response(c)
|
self._add_response(c)
|
||||||
assert not c.set_limit("~s")
|
assert not c.set_view_filter("~s")
|
||||||
assert len(c.view) == 3
|
assert len(c.view) == 3
|
||||||
assert c.focus == 0
|
assert c.focus == 0
|
||||||
|
|
||||||
|
@ -504,13 +504,13 @@ class TestState:
|
|||||||
c = flow.State()
|
c = flow.State()
|
||||||
f = tutils.tflow()
|
f = tutils.tflow()
|
||||||
c.add_flow(f)
|
c.add_flow(f)
|
||||||
c.set_limit("~e")
|
c.set_view_filter("~e")
|
||||||
assert not c.view
|
assert not c.view
|
||||||
f.error = tutils.terr()
|
f.error = tutils.terr()
|
||||||
assert c.update_flow(f)
|
assert c.update_flow(f)
|
||||||
assert c.view
|
assert c.view
|
||||||
|
|
||||||
def test_set_limit(self):
|
def test_set_view_filter(self):
|
||||||
c = flow.State()
|
c = flow.State()
|
||||||
|
|
||||||
f = tutils.tflow()
|
f = tutils.tflow()
|
||||||
@ -519,24 +519,24 @@ class TestState:
|
|||||||
c.add_flow(f)
|
c.add_flow(f)
|
||||||
assert len(c.view) == 1
|
assert len(c.view) == 1
|
||||||
|
|
||||||
c.set_limit("~s")
|
c.set_view_filter("~s")
|
||||||
assert c.limit_txt == "~s"
|
assert c.filter_txt == "~s"
|
||||||
assert len(c.view) == 0
|
assert len(c.view) == 0
|
||||||
f.response = HTTPResponse.wrap(netlib.tutils.tresp())
|
f.response = HTTPResponse.wrap(netlib.tutils.tresp())
|
||||||
c.update_flow(f)
|
c.update_flow(f)
|
||||||
assert len(c.view) == 1
|
assert len(c.view) == 1
|
||||||
c.set_limit(None)
|
c.set_view_filter(None)
|
||||||
assert len(c.view) == 1
|
assert len(c.view) == 1
|
||||||
|
|
||||||
f = tutils.tflow()
|
f = tutils.tflow()
|
||||||
c.add_flow(f)
|
c.add_flow(f)
|
||||||
assert len(c.view) == 2
|
assert len(c.view) == 2
|
||||||
c.set_limit("~q")
|
c.set_view_filter("~q")
|
||||||
assert len(c.view) == 1
|
assert len(c.view) == 1
|
||||||
c.set_limit("~s")
|
c.set_view_filter("~s")
|
||||||
assert len(c.view) == 1
|
assert len(c.view) == 1
|
||||||
|
|
||||||
assert "Invalid" in c.set_limit("~")
|
assert "Invalid" in c.set_view_filter("~")
|
||||||
|
|
||||||
def test_set_intercept(self):
|
def test_set_intercept(self):
|
||||||
c = flow.State()
|
c = flow.State()
|
||||||
|
Loading…
Reference in New Issue
Block a user