aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/proxy
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-03 17:01:25 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-03 17:01:25 +0200
commitf4272de5ec77fb57723e2274e4ddc50d73489e1e (patch)
tree2f7ad35411c29c15199f2498bb43571047c0d066 /libmproxy/proxy
parent1f6d05f89fada5fe360aa79abfa80a3c91ce54da (diff)
downloadmitmproxy-f4272de5ec77fb57723e2274e4ddc50d73489e1e.tar.gz
mitmproxy-f4272de5ec77fb57723e2274e4ddc50d73489e1e.tar.bz2
mitmproxy-f4272de5ec77fb57723e2274e4ddc50d73489e1e.zip
remove ServerConnectionMixin.reconnect
Diffstat (limited to 'libmproxy/proxy')
-rw-r--r--libmproxy/proxy/__init__.py2
-rw-r--r--libmproxy/proxy/modes/http_proxy.py4
-rw-r--r--libmproxy/proxy/modes/reverse_proxy.py2
-rw-r--r--libmproxy/proxy/modes/socks_proxy.py2
-rw-r--r--libmproxy/proxy/modes/transparent_proxy.py2
-rw-r--r--libmproxy/proxy/root_context.py19
-rw-r--r--libmproxy/proxy/server.py4
7 files changed, 28 insertions, 7 deletions
diff --git a/libmproxy/proxy/__init__.py b/libmproxy/proxy/__init__.py
index d5297cb1..be7f5207 100644
--- a/libmproxy/proxy/__init__.py
+++ b/libmproxy/proxy/__init__.py
@@ -2,8 +2,10 @@ from __future__ import (absolute_import, print_function, division)
from .server import ProxyServer, DummyServer
from .config import ProxyConfig
+from .root_context import RootContext, Log
__all__ = [
"ProxyServer", "DummyServer",
"ProxyConfig",
+ "RootContext", "Log",
]
diff --git a/libmproxy/proxy/modes/http_proxy.py b/libmproxy/proxy/modes/http_proxy.py
index 90c54cc6..c7502c24 100644
--- a/libmproxy/proxy/modes/http_proxy.py
+++ b/libmproxy/proxy/modes/http_proxy.py
@@ -10,7 +10,7 @@ class HttpProxy(Layer, ServerConnectionMixin):
layer()
finally:
if self.server_conn:
- self._disconnect()
+ self.disconnect()
class HttpUpstreamProxy(Layer, ServerConnectionMixin):
@@ -23,4 +23,4 @@ class HttpUpstreamProxy(Layer, ServerConnectionMixin):
layer()
finally:
if self.server_conn:
- self._disconnect()
+ self.disconnect()
diff --git a/libmproxy/proxy/modes/reverse_proxy.py b/libmproxy/proxy/modes/reverse_proxy.py
index b57ac5eb..28f4e6f8 100644
--- a/libmproxy/proxy/modes/reverse_proxy.py
+++ b/libmproxy/proxy/modes/reverse_proxy.py
@@ -14,4 +14,4 @@ class ReverseProxy(Layer, ServerConnectionMixin):
layer()
finally:
if self.server_conn:
- self._disconnect()
+ self.disconnect()
diff --git a/libmproxy/proxy/modes/socks_proxy.py b/libmproxy/proxy/modes/socks_proxy.py
index ebaf939e..0efeab67 100644
--- a/libmproxy/proxy/modes/socks_proxy.py
+++ b/libmproxy/proxy/modes/socks_proxy.py
@@ -57,4 +57,4 @@ class Socks5Proxy(Layer, ServerConnectionMixin):
layer()
finally:
if self.server_conn:
- self._disconnect()
+ self.disconnect()
diff --git a/libmproxy/proxy/modes/transparent_proxy.py b/libmproxy/proxy/modes/transparent_proxy.py
index 96ad86c4..d99485c9 100644
--- a/libmproxy/proxy/modes/transparent_proxy.py
+++ b/libmproxy/proxy/modes/transparent_proxy.py
@@ -21,4 +21,4 @@ class TransparentProxy(Layer, ServerConnectionMixin):
layer()
finally:
if self.server_conn:
- self._disconnect()
+ self.disconnect()
diff --git a/libmproxy/proxy/root_context.py b/libmproxy/proxy/root_context.py
index 35909612..88df8e47 100644
--- a/libmproxy/proxy/root_context.py
+++ b/libmproxy/proxy/root_context.py
@@ -85,9 +85,28 @@ class RootContext(object):
# d = top_layer.client_conn.rfile.peek(len(HTTP2Protocol.CLIENT_CONNECTION_PREFACE))
# is_http2_magic = (d == HTTP2Protocol.CLIENT_CONNECTION_PREFACE)
+ def log(self, msg, level, subs=()):
+ """
+ Send a log message to the master.
+ """
+
+ full_msg = [
+ "{}: {}".format(repr(self.client_conn.address), msg)
+ ]
+ for i in subs:
+ full_msg.append(" -> " + i)
+ full_msg = "\n".join(full_msg)
+ self.channel.tell("log", Log(full_msg, level))
+
@property
def layers(self):
return []
def __repr__(self):
return "RootContext"
+
+
+class Log(object):
+ def __init__(self, msg, level="info"):
+ self.msg = msg
+ self.level = level \ No newline at end of file
diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py
index e9e8df09..5d067b45 100644
--- a/libmproxy/proxy/server.py
+++ b/libmproxy/proxy/server.py
@@ -8,10 +8,10 @@ from netlib import tcp
from netlib.http.http1 import HTTP1Protocol
from netlib.tcp import NetLibError
from ..exceptions import ProtocolException, ServerException
-from ..protocol import Log, Kill
+from ..protocol import Kill
from ..models import ClientConnection, make_error_response
from .modes import HttpUpstreamProxy, HttpProxy, ReverseProxy, TransparentProxy, Socks5Proxy
-from .root_context import RootContext
+from .root_context import RootContext, Log
class DummyServer: