From 8afd420e447627c0341ea7861342efeaa3cc2bcb Mon Sep 17 00:00:00 2001 From: Jesse Nicholson Date: Fri, 10 Nov 2017 02:25:11 -0500 Subject: [PATCH] Fixes response handling The callbacks for directing the next action are mangled in such a way that: Requesting response inspection will never result in a response inspection callback. Request headers are sent to the callbacks for the response messages. We completely ignore the proxy next action directive on responses. All issues fixed here. Fixes #11 --- CitadelCore/CitadelCore/CitadelCore.csproj | 8 ++++---- .../CitadelCore/Net/Handlers/FilterHttpResponseHandler.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CitadelCore/CitadelCore/CitadelCore.csproj b/CitadelCore/CitadelCore/CitadelCore.csproj index 6439771..e4734d6 100644 --- a/CitadelCore/CitadelCore/CitadelCore.csproj +++ b/CitadelCore/CitadelCore/CitadelCore.csproj @@ -12,11 +12,11 @@ https://github.com/TechnikEmpire/CitadelCore proxy filtering content-filtering transparent-proxy - Fixes several issues. See github release for more details. + Fixes issues with classification and next action directives regarding http responses. Transparent filtering HTTP/S and Websocket/WebsocketSecure proxy. - 1.2.12 - 1.2.12.0 - 1.2.12.0 + 1.2.13 + 1.2.13.0 + 1.2.13.0 diff --git a/CitadelCore/CitadelCore/Net/Handlers/FilterHttpResponseHandler.cs b/CitadelCore/CitadelCore/Net/Handlers/FilterHttpResponseHandler.cs index f09227e..f9efe9a 100644 --- a/CitadelCore/CitadelCore/Net/Handlers/FilterHttpResponseHandler.cs +++ b/CitadelCore/CitadelCore/Net/Handlers/FilterHttpResponseHandler.cs @@ -300,9 +300,9 @@ public override async Task Handle(HttpContext context) string responseBlockResponseContentType = string.Empty; byte[] responseBlockResponse = null; - m_msgBeginCb?.Invoke(reqUrl, resHeaderBuilder.ToString(), m_nullBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Request, out responseNextAction, out responseBlockResponseContentType, out responseBlockResponse); + m_msgBeginCb?.Invoke(reqUrl, resHeaderBuilder.ToString(), m_nullBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Response, out responseNextAction, out responseBlockResponseContentType, out responseBlockResponse); - if(requestNextAction == ProxyNextAction.DropConnection) + if(responseNextAction == ProxyNextAction.DropConnection) { if(responseBlockResponse != null) { @@ -318,7 +318,7 @@ public override async Task Handle(HttpContext context) } } - if(requestNextAction == ProxyNextAction.AllowButRequestContentInspection) + if(responseNextAction == ProxyNextAction.AllowButRequestContentInspection) { using(var upstreamResponseStream = await response.Content.ReadAsStreamAsync()) { @@ -337,7 +337,7 @@ public override async Task Handle(HttpContext context) bool shouldBlockResponse = false; responseBlockResponseContentType = string.Empty; responseBlockResponse = null; - m_msgEndCb?.Invoke(reqUrl, reqHeaderBuilder.ToString(), responseBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Request, out shouldBlockResponse, out responseBlockResponseContentType, out responseBlockResponse); + m_msgEndCb?.Invoke(reqUrl, resHeaderBuilder.ToString(), responseBody, context.Request.IsHttps ? MessageType.Https : MessageType.Http, MessageDirection.Response, out shouldBlockResponse, out responseBlockResponseContentType, out responseBlockResponse); if(shouldBlockResponse) {