aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol2/layer.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-08-06 11:09:01 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-08-11 20:32:11 +0200
commitc46e3f90bbc38080a41a278340aaad27d8881fd9 (patch)
tree7ab8e5959e1fd2ef501799db3cfb84fb29641e93 /libmproxy/protocol2/layer.py
parent531ca4a35684a83e57d4655922e9817814de41f6 (diff)
downloadmitmproxy-c46e3f90bbc38080a41a278340aaad27d8881fd9.tar.gz
mitmproxy-c46e3f90bbc38080a41a278340aaad27d8881fd9.tar.bz2
mitmproxy-c46e3f90bbc38080a41a278340aaad27d8881fd9.zip
apply fixes from proxy-refactor-cb branch
Diffstat (limited to 'libmproxy/protocol2/layer.py')
-rw-r--r--libmproxy/protocol2/layer.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/libmproxy/protocol2/layer.py b/libmproxy/protocol2/layer.py
index 1cc8df70..30aed350 100644
--- a/libmproxy/protocol2/layer.py
+++ b/libmproxy/protocol2/layer.py
@@ -31,7 +31,7 @@ Further goals:
- Upstream connections should be established as late as possible;
inline scripts shall have a chance to handle everything locally.
"""
-from __future__ import (absolute_import, print_function, division, unicode_literals)
+from __future__ import (absolute_import, print_function, division)
from netlib import tcp
from ..proxy import ProxyError2, Log
from ..proxy.connection import ServerConnection
@@ -49,12 +49,6 @@ class RootContext(object):
self.channel = channel # provides .ask() method to communicate with FlowMaster
self.config = config # Proxy Configuration
- def __getattr__(self, name):
- """
- Accessing a nonexisting attribute does not throw an error but returns None instead.
- """
- return None
-
class _LayerCodeCompletion(object):
"""
@@ -113,7 +107,7 @@ class ServerConnectionMixin(object):
"""
def __init__(self):
- self.server_address = None
+ self._server_address = None
self.server_conn = None
def _handle_server_message(self, message):
@@ -128,6 +122,16 @@ class ServerConnectionMixin(object):
raise NotImplementedError
return False
+ @property
+ def server_address(self):
+ return self._server_address
+
+ @server_address.setter
+ def server_address(self, address):
+ self._server_address = tcp.Address.wrap(address)
+ self.log("Set new server address: " + repr(self.server_address), "debug")
+
+
def _disconnect(self):
"""
Deletes (and closes) an existing server connection.
@@ -145,8 +149,3 @@ class ServerConnectionMixin(object):
self.server_conn.connect()
except tcp.NetLibError as e:
raise ProxyError2("Server connection to '%s' failed: %s" % (self.server_address, e), e)
-
- def _set_address(self, address):
- a = tcp.Address.wrap(address)
- self.log("Set new server address: " + repr(a), "debug")
- self.server_address = address