aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/proxy.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-01-30 05:00:13 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-01-30 05:00:13 +0100
commit40bf42f14a7ec386024a8925502fa3c6e6f0657e (patch)
treedb4d76b903a170ba0315a1fc270b14bf9034f9ee /libmproxy/proxy.py
parent607f7778110d5c2720e60ffcf5f4b0c94e8fcc5f (diff)
downloadmitmproxy-40bf42f14a7ec386024a8925502fa3c6e6f0657e.tar.gz
mitmproxy-40bf42f14a7ec386024a8925502fa3c6e6f0657e.tar.bz2
mitmproxy-40bf42f14a7ec386024a8925502fa3c6e6f0657e.zip
merge flow classes. current status: basic mitmdump working
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r--libmproxy/proxy.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index a7ee9a7b..e43c811b 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -5,7 +5,6 @@ import utils, flow, version, platform, controller
TRANSPARENT_SSL_PORTS = [443, 8443]
-KILL = 0
class ProxyError(Exception):
@@ -15,10 +14,6 @@ class ProxyError(Exception):
def __str__(self):
return "ProxyError(%s, %s)" % (self.code, self.msg)
-
-import protocol
-
-
class Log:
def __init__(self, msg):
self.msg = msg
@@ -39,7 +34,7 @@ class ProxyConfig:
self.certstore = certutils.CertStore()
-class ClientConnection(tcp.BaseHandler):
+class ClientConnection(tcp.BaseHandler, flow.SimpleStateObject):
def __init__(self, client_connection, address, server):
tcp.BaseHandler.__init__(self, client_connection, address, server)
@@ -47,6 +42,13 @@ class ClientConnection(tcp.BaseHandler):
self.timestamp_end = None
self.timestamp_ssl_setup = None
+ _stateobject_attributes = dict(
+ timestamp_start=float,
+ timestamp_end=float,
+ timestamp_ssl_setup=float,
+ # FIXME: Add missing attributes
+ )
+
def convert_to_ssl(self, *args, **kwargs):
tcp.BaseHandler.convert_to_ssl(self, *args, **kwargs)
self.timestamp_ssl_setup = utils.timestamp()
@@ -56,7 +58,7 @@ class ClientConnection(tcp.BaseHandler):
self.timestamp_end = utils.timestamp()
-class ServerConnection(tcp.TCPClient):
+class ServerConnection(tcp.TCPClient, flow.SimpleStateObject):
def __init__(self, address):
tcp.TCPClient.__init__(self, address)
@@ -66,6 +68,15 @@ class ServerConnection(tcp.TCPClient):
self.timestamp_tcp_setup = None
self.timestamp_ssl_setup = None
+ _stateobject_attributes = dict(
+ peername=tuple,
+ timestamp_start=float,
+ timestamp_end=float,
+ timestamp_tcp_setup=float,
+ timestamp_ssl_setup=float,
+ # FIXME: Add missing attributes
+ )
+
def connect(self):
self.timestamp_start = utils.timestamp()
tcp.TCPClient.connect(self)
@@ -119,6 +130,8 @@ class RequestReplayThread(threading.Thread):
"""
+import protocol
+
class ConnectionHandler:
def __init__(self, config, client_connection, client_address, server, channel, server_version):
self.config = config
@@ -180,6 +193,8 @@ class ConnectionHandler:
protocol.handle_error(self.conntype, self, e)
except Exception, e:
self.log(e.__class__)
+ import traceback
+ self.log(traceback.format_exc())
self.log(str(e))
self.del_server_connection()