This commit is contained in:
Samoilenko Roman 2018-01-14 22:54:09 +02:00 committed by Maximilian Hils
parent 9a43ff5da1
commit 6b22da6a34
2 changed files with 12 additions and 3 deletions

View File

@ -114,9 +114,9 @@ class ConnectionHandler:
def handle(self):
self.log("clientconnect", "info")
root_layer = self._create_root_layer()
root_layer = None
try:
root_layer = self._create_root_layer()
root_layer = self.channel.ask("clientconnect", root_layer)
root_layer()
except exceptions.Kill:
@ -151,7 +151,8 @@ class ConnectionHandler:
print("Please lodge a bug report at: https://github.com/mitmproxy/mitmproxy", file=sys.stderr)
self.log("clientdisconnect", "info")
self.channel.tell("clientdisconnect", root_layer)
if root_layer is not None:
self.channel.tell("clientdisconnect", root_layer)
self.client_conn.finish()
def log(self, msg, level):

View File

@ -511,6 +511,14 @@ class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
req = self.master.state.flows[0].request
assert req.host_header == "127.0.0.1"
def test_selfconnection(self):
self.options.mode = "reverse:http://127.0.0.1:0"
p = self.pathoc()
with p.connect():
p.request("get:/")
assert self.master.has_log("The proxy shall not connect to itself.")
class TestReverseSSL(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
reverse = True