Merge remote-tracking branch 'base/master'

This commit is contained in:
Marcelo Glezer 2015-01-12 10:55:47 -03:00
commit 27950f1972
5 changed files with 44 additions and 8 deletions

View File

@ -130,7 +130,7 @@ The main classes you will deal with in writing mitmproxy scripts are:
</td> </td>
</tr> </tr>
<tr> <tr>
<th>libmproxy.certutils.SSLCert</th> <th>netlib.certutils.SSLCert</th>
<td>Exposes information SSL certificates.</td> <td>Exposes information SSL certificates.</td>
</tr> </tr>
</table> </table>

View File

@ -510,6 +510,10 @@ class ConsoleMaster(flow.FlowMaster):
def client_playback_path(self, path): def client_playback_path(self, path):
err, ret = self._readflow(path) err, ret = self._readflow(path)
if err: if err:
if not self.statusbar:
print >> sys.stderr, ret
sys.exit(1)
else:
self.statusbar.message(ret) self.statusbar.message(ret)
else: else:
self.start_client_playback(ret, False) self.start_client_playback(ret, False)
@ -517,6 +521,10 @@ class ConsoleMaster(flow.FlowMaster):
def server_playback_path(self, path): def server_playback_path(self, path):
err, ret = self._readflow(path) err, ret = self._readflow(path)
if err: if err:
if not self.statusbar:
print >> sys.stderr, ret
sys.exit(1)
else:
self.statusbar.message(ret) self.statusbar.message(ret)
else: else:
self.start_server_playback( self.start_server_playback(
@ -825,8 +833,8 @@ class ConsoleMaster(flow.FlowMaster):
if changed: if changed:
self.statusbar.redraw() self.statusbar.redraw()
size = self.drawscreen() size = self.drawscreen()
changed = self.tick(self.masterq, 0.01) changed = self.tick(self.masterq, timeout=0.1)
self.ui.set_input_timeouts(max_wait=0.01) self.ui.set_input_timeouts(max_wait=0)
keys = self.ui.get_input() keys = self.ui.get_input()
if keys: if keys:
changed = True changed = True

View File

@ -108,7 +108,11 @@ class Master(object):
self.should_exit.clear() self.should_exit.clear()
self.server.start_slave(Slave, Channel(self.masterq, self.should_exit)) self.server.start_slave(Slave, Channel(self.masterq, self.should_exit))
while not self.should_exit.is_set(): 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() self.shutdown()
def handle(self, mtype, obj): def handle(self, mtype, obj):

View File

@ -758,7 +758,7 @@ class FlowMaster(controller.Master):
self.shutdown() self.shutdown()
self.client_playback.tick(self) self.client_playback.tick(self)
return controller.Master.tick(self, q, timeout) return super(FlowMaster, self).tick(q, timeout)
def duplicate_flow(self, f): def duplicate_flow(self, f):
return self.load_flow(f.copy()) return self.load_flow(f.copy())

24
test/tools/bench.py Normal file
View File

@ -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))