use flt instead of filt for flowfilter expressions

This commit is contained in:
Thomas Kriechbaumer 2016-10-04 14:50:42 +02:00
parent 76ae9fdbaa
commit 90898f9084
4 changed files with 11 additions and 11 deletions

View File

@ -25,7 +25,7 @@ Should give output something like this:
> mitmproxy/controller 69 0 100% > mitmproxy/controller 69 0 100%
> mitmproxy/dump 150 0 100% > mitmproxy/dump 150 0 100%
> mitmproxy/encoding 39 0 100% > mitmproxy/encoding 39 0 100%
> mitmproxy/filt 201 0 100% > mitmproxy/flowfilter 201 0 100%
> mitmproxy/flow 891 0 100% > mitmproxy/flow 891 0 100%
> mitmproxy/proxy 427 0 100% > mitmproxy/proxy 427 0 100%
> mitmproxy/script 27 0 100% > mitmproxy/script 27 0 100%

View File

@ -11,13 +11,13 @@ class FileStreamer:
self.stream = None self.stream = None
self.active_flows = set() # type: Set[models.Flow] self.active_flows = set() # type: Set[models.Flow]
def start_stream_to_path(self, path, mode, filt): def start_stream_to_path(self, path, mode, flt):
path = os.path.expanduser(path) path = os.path.expanduser(path)
try: try:
f = open(path, mode) f = open(path, mode)
except IOError as v: except IOError as v:
return str(v) return str(v)
self.stream = io.FilteredFlowWriter(f, filt) self.stream = io.FilteredFlowWriter(f, flt)
self.active_flows = set() self.active_flows = set()
def configure(self, options, updated): def configure(self, options, updated):

View File

@ -67,17 +67,17 @@ class FlowView(FlowList):
def _build(self, flows, flt=None): def _build(self, flows, flt=None):
if flt: if flt:
self.filt = flt self.filter = flt
self._list = list(filter(self.filt, flows)) self._list = list(filter(self.filter, flows))
def _add(self, f): def _add(self, f):
if self.filt(f): if self.filter(f):
self._list.append(f) self._list.append(f)
def _update(self, f): def _update(self, f):
if f not in self._list: if f not in self._list:
self._add(f) self._add(f)
elif not self.filt(f): elif not self.filter(f):
self._remove(f) self._remove(f)
def _remove(self, f): def _remove(self, f):
@ -187,12 +187,12 @@ class State(object):
self.flows = FlowStore() self.flows = FlowStore()
self.view = FlowView(self.flows, None) self.view = FlowView(self.flows, None)
# These are compiled filt expressions: # These are compiled filter expressions:
self.intercept = None self.intercept = None
@property @property
def filter_txt(self): def filter_txt(self):
return getattr(self.view.filt, "pattern", None) return getattr(self.view.filter, "pattern", None)
def flow_count(self): def flow_count(self):
return len(self.flows) return len(self.flows)

View File

@ -10,12 +10,12 @@ class TestDumpMaster(mastertest.MasterTest):
mastertest.MasterTest.dummy_cycle(self, master, n, content) mastertest.MasterTest.dummy_cycle(self, master, n, content)
return master.options.tfile.getvalue() return master.options.tfile.getvalue()
def mkmaster(self, filt, **options): def mkmaster(self, flt, **options):
if "verbosity" not in options: if "verbosity" not in options:
options["verbosity"] = 0 options["verbosity"] = 0
if "flow_detail" not in options: if "flow_detail" not in options:
options["flow_detail"] = 0 options["flow_detail"] = 0
o = dump.Options(filtstr=filt, tfile=StringIO(), **options) o = dump.Options(filtstr=flt, tfile=StringIO(), **options)
return dump.DumpMaster(None, o) return dump.DumpMaster(None, o)
def test_basic(self): def test_basic(self):