public static void DirectHandle( ProxyClient client, string clientConnectionAddress, ushort clientConnectionPort, byte[] firstResponse) { if (client.IsSmartForwarderEnable && client.Controller.SmartPear.ForwarderHttpsEnable && client.Controller.SmartPear.ForwarderSocksEnable) { // Is Forwarder is Enable and Client need to be forwarded by NoServer ServerType ac = new NoServer { NoDataTimeout = client.Controller.ActiveServer.NoDataTimeout }; if (client.Controller.SmartPear.DetectorTimeoutEnable) { // If we have Timeout Detector then let change timeout ac.NoDataTimeout = client.Controller.SmartPear.DetectorTimeout; } client.SmartDataSentCallbackForDirectConnections(firstResponse, true); ac.Establish( clientConnectionAddress, clientConnectionPort, client, firstResponse, (ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) => thisclient.SmartDataSentCallbackForDirectConnections(data, true), (ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) => thisclient.SmartDataReceivedCallbackForDirrectConnections(ref data, thisactiveServer, true), (success, thisactiveServer, thisclient) => thisclient.SmartStatusCallbackForDirectConnections(thisactiveServer, success, true)); } else { // Forwarder is Disable or Client is in proxy connection mode ServerType ac = client.Controller.ActiveServer.Clone(); if (client.Controller.SmartPear.ForwarderHttpsEnable && client.Controller.SmartPear.ForwarderSocksEnable) { // If we have forwarding enable then we need to have the receive callback ac.Establish( clientConnectionAddress, clientConnectionPort, client, firstResponse, null, (ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) => thisclient.SmartDataReceivedCallbackForDirrectConnections(ref data, thisactiveServer, true)); } else { // If we don't so SmartPear is disabled ac.Establish(clientConnectionAddress, clientConnectionPort, client, firstResponse); } } }
public static void DirectHandle( ProxyClient client, string clientConnectionAddress, ushort clientConnectionPort, byte[] firstResponse) { if (client.Controller.SmartPear.ForwarderHttpEnable && client.IsSmartForwarderEnable) { ServerType ac = new NoServer(); if (client.Controller.SmartPear.DetectorHttpCheckEnable) { ac.NoDataTimeout = client.Controller.ActiveServer.NoDataTimeout; if (client.Controller.SmartPear.DetectorTimeoutEnable) { // If we have Timeout Detector then let change timeout ac.NoDataTimeout = client.Controller.SmartPear.DetectorTimeout; } client.SmartDataSentCallbackForHttpConnections(firstResponse); ac.Establish( clientConnectionAddress, clientConnectionPort, client, firstResponse, delegate(ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) { if (IsHttp(data, true)) { thisclient.SmartCleanTheForwarder(); Handle(data, thisclient, true); return(false); } return(thisclient.SmartDataSentCallbackForHttpConnections(data)); }, (ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) => thisclient.SmartDataReceivedCallbackForHttpConnections(ref data, thisactiveServer), (success, thisactiveServer, thisclient) => thisclient.SmartStatusCallbackForHttpConnections(thisactiveServer, success)); } else { ac.NoDataTimeout = client.Controller.ActiveServer.NoDataTimeout; if (client.Controller.SmartPear.DetectorTimeoutEnable) { // If we have Timeout Detector then let change timeout ac.NoDataTimeout = client.Controller.SmartPear.DetectorTimeout; } client.SmartDataSentCallbackForHttpConnections(firstResponse); ac.Establish( clientConnectionAddress, clientConnectionPort, client, firstResponse, delegate(ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) { if (IsHttp(data, true)) { Handle(data, thisclient, true); return(false); } return(thisclient.SmartDataSentCallbackForHttpConnections(data)); }, (ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) => thisclient.SmartDataReceivedCallbackForHttpConnections(ref data, thisactiveServer), (success, thisactiveServer, thisclient) => thisclient.SmartStatusCallbackForHttpConnections(thisactiveServer, success)); } } else { ServerType ac = client.Controller.ActiveServer.Clone(); if (!client.IsSmartForwarderEnable && client.Controller.SmartPear.ForwarderHttpEnable && (client.Controller.SmartPear.DetectorHttpCheckEnable || client.Controller.SmartPear.DetectorDnsPoisoningEnable)) { ac.Establish( clientConnectionAddress, clientConnectionPort, client, firstResponse, delegate(ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) { if (IsHttp(data, true)) { if (client.Controller.SmartPear.ForwarderHttpEnable && !client.IsSmartForwarderEnable) { thisclient.SmartCleanTheForwarder(); } Handle(data, thisclient, true); return(false); } return(true); }, (ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) => thisclient.SmartDataReceivedCallbackForHttpConnections(ref data, thisactiveServer)); } else { ac.Establish( clientConnectionAddress, clientConnectionPort, client, firstResponse, delegate(ref byte[] data, ServerType thisactiveServer, ProxyClient thisclient) { if (IsHttp(data, true)) { if (client.Controller.SmartPear.ForwarderHttpEnable && !client.IsSmartForwarderEnable) { thisclient.SmartCleanTheForwarder(); } Handle(data, thisclient, true); return(false); } return(true); }); } } }