aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-04-13 20:30:34 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-04-13 20:30:34 -0700
commita3f8a7c72c2077a245fecb76fb0f2dce8241c188 (patch)
tree2dffdd08ccf21d5527d0cdbbdc92858f7f4148e0
parent228197185ea19545293f1e27a2e21bf21b1e152c (diff)
downloadmitmproxy-a3f8a7c72c2077a245fecb76fb0f2dce8241c188.tar.gz
mitmproxy-a3f8a7c72c2077a245fecb76fb0f2dce8241c188.tar.bz2
mitmproxy-a3f8a7c72c2077a245fecb76fb0f2dce8241c188.zip
minor improvements
-rw-r--r--mitmproxy/console/__init__.py16
-rw-r--r--mitmproxy/controller.py3
-rw-r--r--mitmproxy/dump.py2
-rw-r--r--mitmproxy/exceptions.py2
-rw-r--r--mitmproxy/flow.py19
5 files changed, 13 insertions, 29 deletions
diff --git a/mitmproxy/console/__init__.py b/mitmproxy/console/__init__.py
index 9deb26e1..12a3b724 100644
--- a/mitmproxy/console/__init__.py
+++ b/mitmproxy/console/__init__.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import mailcap
import mimetypes
@@ -457,7 +457,6 @@ class ConsoleMaster(flow.FlowMaster):
signals.update_settings.send()
self.loop.set_alarm_in(0.01, self.ticker)
-
def run(self):
self.ui = urwid.raw_display.Screen()
self.ui.set_terminal_properties(256)
@@ -513,11 +512,11 @@ class ConsoleMaster(flow.FlowMaster):
except Exception:
self.loop.stop()
sys.stdout.flush()
- print >> sys.stderr, traceback.format_exc()
- print >> sys.stderr, "mitmproxy has crashed!"
- print >> sys.stderr, "Please lodge a bug report at:"
- print >> sys.stderr, "\thttps://github.com/mitmproxy/mitmproxy"
- print >> sys.stderr, "Shutting down..."
+ print(traceback.format_exc(), file=sys.stderr)
+ print("mitmproxy has crashed!", file=sys.stderr)
+ print("Please lodge a bug report at:", file=sys.stderr)
+ print("\thttps://github.com/mitmproxy/mitmproxy", file=sys.stderr)
+ print("Shutting down...", file=sys.stderr)
sys.stderr.flush()
self.shutdown()
@@ -717,8 +716,7 @@ class ConsoleMaster(flow.FlowMaster):
)
def process_flow(self, f):
- if self.state.intercept and f.match(
- self.state.intercept) and not f.request.is_replay:
+ if self.state.intercept and f.match(self.state.intercept) and not f.request.is_replay:
f.intercept(self)
else:
# check if flow was intercepted within an inline script by flow.intercept()
diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py
index fedfce62..84f243a0 100644
--- a/mitmproxy/controller.py
+++ b/mitmproxy/controller.py
@@ -80,8 +80,7 @@ class Slave(threading.Thread):
self.channel, self.server = channel, server
self.server.set_channel(channel)
threading.Thread.__init__(self)
- self.name = "SlaveThread (%s:%s)" % (
- self.server.address.host, self.server.address.port)
+ self.name = "SlaveThread ({})".format(repr(self.server.address))
def run(self):
self.server.serve_forever()
diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py
index 631e4d2e..2f519d28 100644
--- a/mitmproxy/dump.py
+++ b/mitmproxy/dump.py
@@ -351,7 +351,7 @@ class DumpMaster(flow.FlowMaster):
self.shutdown()
return
try:
- return flow.FlowMaster.run(self)
+ return super(DumpMaster, self).run()
except BaseException:
self.shutdown()
raise
diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py
index f0ff81a2..53916d1f 100644
--- a/mitmproxy/exceptions.py
+++ b/mitmproxy/exceptions.py
@@ -9,7 +9,6 @@ from __future__ import (absolute_import, print_function, division)
class ProxyException(Exception):
-
"""
Base class for all exceptions thrown by mitmproxy.
"""
@@ -27,7 +26,6 @@ class TlsProtocolException(ProtocolException):
class ClientHandshakeException(TlsProtocolException):
-
def __init__(self, message, server):
super(ClientHandshakeException, self).__init__(message)
self.server = server
diff --git a/mitmproxy/flow.py b/mitmproxy/flow.py
index cf07ea9a..73493d1f 100644
--- a/mitmproxy/flow.py
+++ b/mitmproxy/flow.py
@@ -845,19 +845,6 @@ class FlowMaster(controller.Master):
c = ClientConnection.make_dummy(("", 0))
s = ServerConnection.make_dummy((host, port))
- s = ServerConnection.from_state(dict(
- address=dict(address=(host, port), use_ipv6=False),
- ip_address=None,
- cert=None,
- sni=host,
- source_address=dict(address=("", 0), use_ipv6=False),
- ssl_established=True,
- timestamp_start=None,
- timestamp_tcp_setup=None,
- timestamp_ssl_setup=None,
- timestamp_end=None,
- via=None
- ))
f = HTTPFlow(c, s)
headers = Headers()
@@ -883,7 +870,7 @@ class FlowMaster(controller.Master):
if self.server and self.server.config.mode == "reverse":
f.request.host = self.server.config.upstream_server.address.host
f.request.port = self.server.config.upstream_server.address.port
- f.request.scheme = re.sub("^https?2", "", self.server.config.upstream_server.scheme)
+ f.request.scheme = self.server.config.upstream_server.scheme
f.reply = controller.DummyReply()
if f.request:
@@ -1080,7 +1067,9 @@ class FlowMaster(controller.Master):
def shutdown(self):
self.unload_scripts()
- controller.Master.shutdown(self)
+ super(FlowMaster, self).shutdown()
+
+ # Add all flows that are still active
if self.stream:
for i in self.state.flows:
if not i.response: