aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Glezer <mg@tekii.com.ar>2015-01-12 10:55:47 -0300
committerMarcelo Glezer <mg@tekii.com.ar>2015-01-12 10:55:47 -0300
commit27950f19721ae68152b84d874702ca81f1b6ecee (patch)
tree12573d1c3c9976d0b39016f3f45a0ef78c1a759d
parent30213d6370bca2bb222e315a63bf4d924a9b0b94 (diff)
parente18294437c4629f26dc65e16a9252ef61a109284 (diff)
downloadmitmproxy-27950f19721ae68152b84d874702ca81f1b6ecee.tar.gz
mitmproxy-27950f19721ae68152b84d874702ca81f1b6ecee.tar.bz2
mitmproxy-27950f19721ae68152b84d874702ca81f1b6ecee.zip
Merge remote-tracking branch 'base/master'
-rw-r--r--doc-src/scripting/inlinescripts.html4
-rw-r--r--libmproxy/console/__init__.py16
-rw-r--r--libmproxy/controller.py6
-rw-r--r--libmproxy/flow.py2
-rw-r--r--test/tools/bench.py24
5 files changed, 44 insertions, 8 deletions
diff --git a/doc-src/scripting/inlinescripts.html b/doc-src/scripting/inlinescripts.html
index 2c3e0d6f..7f05eedf 100644
--- a/doc-src/scripting/inlinescripts.html
+++ b/doc-src/scripting/inlinescripts.html
@@ -130,7 +130,7 @@ The main classes you will deal with in writing mitmproxy scripts are:
</td>
</tr>
<tr>
- <th>libmproxy.certutils.SSLCert</th>
+ <th>netlib.certutils.SSLCert</th>
<td>Exposes information SSL certificates.</td>
</tr>
</table>
@@ -174,4 +174,4 @@ matching events will be skipped.
## Spaces in the script path
By default, spaces are interpreted as separator between the inline script and its arguments (e.g. <code>-s "foo.py
42"</code>). Consequently, the script path needs to be wrapped in a separate pair of quotes if it contains spaces:
-<code>-s "'./foo bar/baz.py' 42"</code>. \ No newline at end of file
+<code>-s "'./foo bar/baz.py' 42"</code>.
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py
index e2a0ec75..b2f4d96c 100644
--- a/libmproxy/console/__init__.py
+++ b/libmproxy/console/__init__.py
@@ -510,14 +510,22 @@ class ConsoleMaster(flow.FlowMaster):
def client_playback_path(self, path):
err, ret = self._readflow(path)
if err:
- self.statusbar.message(ret)
+ if not self.statusbar:
+ print >> sys.stderr, ret
+ sys.exit(1)
+ else:
+ self.statusbar.message(ret)
else:
self.start_client_playback(ret, False)
def server_playback_path(self, path):
err, ret = self._readflow(path)
if err:
- self.statusbar.message(ret)
+ if not self.statusbar:
+ print >> sys.stderr, ret
+ sys.exit(1)
+ else:
+ self.statusbar.message(ret)
else:
self.start_server_playback(
ret,
@@ -825,8 +833,8 @@ class ConsoleMaster(flow.FlowMaster):
if changed:
self.statusbar.redraw()
size = self.drawscreen()
- changed = self.tick(self.masterq, 0.01)
- self.ui.set_input_timeouts(max_wait=0.01)
+ changed = self.tick(self.masterq, timeout=0.1)
+ self.ui.set_input_timeouts(max_wait=0)
keys = self.ui.get_input()
if keys:
changed = True
diff --git a/libmproxy/controller.py b/libmproxy/controller.py
index 39e7695f..9ca89184 100644
--- a/libmproxy/controller.py
+++ b/libmproxy/controller.py
@@ -108,7 +108,11 @@ class Master(object):
self.should_exit.clear()
self.server.start_slave(Slave, Channel(self.masterq, self.should_exit))
while not self.should_exit.is_set():
- self.tick(self.masterq, 0.01)
+
+ # Don't choose a very small timeout in Python 2:
+ # https://github.com/mitmproxy/mitmproxy/issues/443
+ # TODO: Lower the timeout value if we move to Python 3.
+ self.tick(self.masterq, 0.1)
self.shutdown()
def handle(self, mtype, obj):
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index f3b138e2..97ebc572 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -758,7 +758,7 @@ class FlowMaster(controller.Master):
self.shutdown()
self.client_playback.tick(self)
- return controller.Master.tick(self, q, timeout)
+ return super(FlowMaster, self).tick(q, timeout)
def duplicate_flow(self, f):
return self.load_flow(f.copy())
diff --git a/test/tools/bench.py b/test/tools/bench.py
new file mode 100644
index 00000000..1028f61d
--- /dev/null
+++ b/test/tools/bench.py
@@ -0,0 +1,24 @@
+from __future__ import print_function
+import requests, time
+
+n = 100
+url = "http://192.168.1.1/"
+proxy = "http://192.168.1.115:8080/"
+
+start = time.time()
+for _ in range(n):
+ requests.get(url, allow_redirects=False, proxies=dict(http=proxy))
+ print(".", end="")
+t_mitmproxy = time.time()-start
+
+print("\r\nTotal time with mitmproxy: {}".format(t_mitmproxy))
+
+
+
+start = time.time()
+for _ in range(n):
+ requests.get(url, allow_redirects=False)
+ print(".", end="")
+t_without = time.time()-start
+
+print("\r\nTotal time without mitmproxy: {}".format(t_without)) \ No newline at end of file