예제 #1
0
        public void NoServerTest()
        {
            new WindowsModule().RegisterPlatform();

            NoServer clientServer = new NoServer();

            ProxyController client = new ProxyController(clientServer, IPAddress.Loopback, 0)
            {
                IsAutoConfigEnable =
                    false
            };

            client.TestServer();
            if (!client.Start())
            {
                throw new Exception("Failed to start the client");
            }

            WebProxy proxy = CommonMethods.CreateProxy(client.Ip, client.Port);

            CommonMethods.StringDownloadTest(proxy);
            CommonMethods.SmallFileDownloadTest(proxy);
            CommonMethods.BigFileDownloadTest(proxy);
            CommonMethods.UploadStringTest(proxy);
            client.Stop();
        }
예제 #2
0
파일: Socks.cs 프로젝트: orf53975/PeaRoxy
        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);
                }
            }
        }
예제 #3
0
        public ProxyController InitClient()
        {
            new WindowsModule().RegisterPlatform();

            NoServer clientServer = new NoServer();

            ProxyController client = new ProxyController(clientServer, IPAddress.Loopback, 0)
            {
                IsAutoConfigEnable =
                    false
            };

            client.TestServer();
            if (!client.Start())
            {
                throw new Exception("Failed to start the client");
            }
            return(client);
        }
예제 #4
0
파일: Http.cs 프로젝트: orf53975/PeaRoxy
        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);
                    });
                }
            }
        }