mitmproxy/libmproxy/protocol2/reverse_proxy.py

20 lines
644 B
Python
Raw Normal View History

2015-08-06 10:32:33 +00:00
from __future__ import (absolute_import, print_function, division)
from .layer import Layer, ServerConnectionMixin
from .tls import TlsLayer
2015-08-06 10:32:33 +00:00
class ReverseProxy(Layer, ServerConnectionMixin):
def __init__(self, ctx, server_address, client_tls, server_tls):
2015-08-06 10:32:33 +00:00
super(ReverseProxy, self).__init__(ctx)
self.server_address = server_address
self._client_tls = client_tls
self._server_tls = server_tls
2015-08-06 10:32:33 +00:00
def __call__(self):
layer = TlsLayer(self, self._client_tls, self._server_tls)
2015-08-06 10:32:33 +00:00
for message in layer():
if not self._handle_server_message(message):
yield message