aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/master.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-03-15 12:47:03 +1300
committerAldo Cortesi <aldo@nullcube.com>2017-03-15 13:44:48 +1300
commitef582333ff432e11e696b95d7da456d8b6eae5cd (patch)
tree0279f29f9146b96e3915ce8215c520a029d9ff55 /mitmproxy/master.py
parenteba6d4359cdf147b378ffa5eb66b12fc9249bc69 (diff)
downloadmitmproxy-ef582333ff432e11e696b95d7da456d8b6eae5cd.tar.gz
mitmproxy-ef582333ff432e11e696b95d7da456d8b6eae5cd.tar.bz2
mitmproxy-ef582333ff432e11e696b95d7da456d8b6eae5cd.zip
Extract flow reading into addons
This patch moves the final pieces of master functionality into addons. - Add a ReadFile addon to read from file - Add a separate ReadStdin addon to read from stdin, only used by mitmdump - Remove all methods that know about io and serialization from master.Master
Diffstat (limited to 'mitmproxy/master.py')
-rw-r--r--mitmproxy/master.py30
1 files changed, 0 insertions, 30 deletions
diff --git a/mitmproxy/master.py b/mitmproxy/master.py
index 79747a97..69359de6 100644
--- a/mitmproxy/master.py
+++ b/mitmproxy/master.py
@@ -1,8 +1,6 @@
-import os
import threading
import contextlib
import queue
-import sys
from mitmproxy import addonmanager
from mitmproxy import options
@@ -12,7 +10,6 @@ from mitmproxy import exceptions
from mitmproxy import connections
from mitmproxy import http
from mitmproxy import log
-from mitmproxy import io
from mitmproxy.proxy.protocol import http_replay
from mitmproxy.types import basethread
import mitmproxy.net.http
@@ -160,33 +157,6 @@ class Master:
for e, o in eventsequence.iterate(f):
getattr(self, e)(o)
- def load_flows(self, fr: io.FlowReader) -> int:
- """
- Load flows from a FlowReader object.
- """
- cnt = 0
- for i in fr.stream():
- cnt += 1
- self.load_flow(i)
- return cnt
-
- def load_flows_file(self, path: str) -> int:
- path = os.path.expanduser(path)
- try:
- if path == "-":
- try:
- sys.stdin.buffer.read(0)
- except Exception as e:
- raise IOError("Cannot read from stdin: {}".format(e))
- freader = io.FlowReader(sys.stdin.buffer)
- return self.load_flows(freader)
- else:
- with open(path, "rb") as f:
- freader = io.FlowReader(f)
- return self.load_flows(freader)
- except IOError as v:
- raise exceptions.FlowReadException(v.strerror)
-
def replay_request(
self,
f: http.HTTPFlow,