This commit is contained in:
Maximilian Hils 2014-10-22 14:03:19 +02:00
commit c79bdeb4e5
2 changed files with 16 additions and 1 deletions

View File

@ -618,6 +618,11 @@ class FlowMaster(controller.Master):
""" """
Loads a flow, and returns a new flow object. Loads a flow, and returns a new flow object.
""" """
if self.server and self.server.config.mode == "reverse":
f.request.host, f.request.port = self.server.config.mode.dst[2:]
f.request.scheme = "https" if self.server.config.mode.dst[1] else "http"
f.reply = controller.DummyReply() f.reply = controller.DummyReply()
if f.request: if f.request:
self.handle_request(f) self.handle_request(f)

View File

@ -5,8 +5,10 @@ import mock
from libmproxy import filt, protocol, controller, utils, tnetstring, flow from libmproxy import filt, protocol, controller, utils, tnetstring, flow
from libmproxy.protocol.primitives import Error, Flow from libmproxy.protocol.primitives import Error, Flow
from libmproxy.protocol.http import decoded, CONTENT_MISSING from libmproxy.protocol.http import decoded, CONTENT_MISSING
from libmproxy.proxy.connection import ClientConnection
from libmproxy.proxy.config import HostMatcher from libmproxy.proxy.config import HostMatcher
from libmproxy.proxy import ProxyConfig
from libmproxy.proxy.server import DummyServer
from libmproxy.proxy.connection import ClientConnection
import tutils import tutils
@ -531,6 +533,14 @@ class TestSerialize:
fm.load_flows(r) fm.load_flows(r)
assert len(s._flow_list) == 6 assert len(s._flow_list) == 6
def test_load_flows_reverse(self):
r = self._treader()
s = flow.State()
conf = ProxyConfig(mode="reverse", upstream_server=[True,True,"use-this-domain",80])
fm = flow.FlowMaster(DummyServer(conf), s)
fm.load_flows(r)
assert s._flow_list[0].request.host == "use-this-domain"
def test_filter(self): def test_filter(self):
sio = StringIO() sio = StringIO()
fl = filt.parse("~c 200") fl = filt.parse("~c 200")