aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadt1m <blackjuniper@protonmail.com>2018-06-30 12:20:27 +0200
committermadt1m <blackjuniper@protonmail.com>2018-06-30 12:20:27 +0200
commit66aff8d2a46f800348408a247a057b4fc8a883b5 (patch)
tree2b8d43bb004e0eae351c6b41509e154bfeb3a7a9
parent85da4694f111f1029bad878000b1d40b49aceb7d (diff)
downloadmitmproxy-66aff8d2a46f800348408a247a057b4fc8a883b5.tar.gz
mitmproxy-66aff8d2a46f800348408a247a057b4fc8a883b5.tar.bz2
mitmproxy-66aff8d2a46f800348408a247a057b4fc8a883b5.zip
view can load from both io interfaces
-rw-r--r--mitmproxy/addons/view.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py
index 3730aa8d..25142a2c 100644
--- a/mitmproxy/addons/view.py
+++ b/mitmproxy/addons/view.py
@@ -447,9 +447,17 @@ class View(collections.Sequence):
Load flows into the view, without processing them with addons.
"""
try:
- dh = io.DbHandler(path)
- for f in dh.load():
- self.add([f.copy()])
+ if path.endswith(".sqlite"):
+ dh = io.DbHandler(path)
+ for f in dh.load():
+ self.add([f.copy()])
+ else:
+ with open(path, "rb") as f:
+ for i in io.FlowReader(f).stream():
+ # Do this to get a new ID, so we can load the same file N times and
+ # get new flows each time. It would be more efficient to just have a
+ # .newid() method or something.
+ self.add([i.copy()])
except exceptions.TypeError as e:
ctx.log.error(str(e))
except IOError as e: