public ServerServer(PortTunnel main)
 {
     this.main = main;
 }
Example #2
0
 public ClientClient(PortTunnel main)
 {
     this.main = main;
 }
Example #3
0
 public ServerClient(PortTunnel main)
 {
     this.main             = main;
     main.Connection2.Host = null;
 }
Example #4
0
        public void Start(TcpClient client1, TcpClient client2,
                          PortTunnel main)
        {
            this.client1 = client1;
            this.client2 = client2;
            ep1          = client1.Client.RemoteEndPoint;
            ep2          = client2.Client.RemoteEndPoint;
            this.main    = main;

            main.ActiveConnections++;

            if (main.HttpProtocol)
            {
                if (main.Connection1.Host != null && main.Connection2.Host != null)
                {
                    httpHostReplacement = new byte[main.Connection1.Host.Length];

                    int i = 0;
                    foreach (char c in main.Connection1.Host.ToCharArray())
                    {
                        httpHostReplacement[i] = (byte)c;
                        i++;
                    }
                }
                else if (main.Connection1.Host != null && main.Connection2.Host == null)
                {
                    httpHostReplacement = new byte[main.Connection1.Host.Length];

                    int i = 0;
                    foreach (char c in main.Connection1.Host.ToCharArray())
                    {
                        httpHostReplacement[i] = (byte)c;
                        i++;
                    }
                }
            }

            httpHostHeaderLine = new byte[6] {
                (byte)'H',
                (byte)'o',
                (byte)'s',
                (byte)'t',
                (byte)':',
                (byte)' '
            };

            if (main.DestIsSsl &&
                ((main.Connection1.Type == Enums.ConnectionType.Client &&
                  main.Connection2.Type == Enums.ConnectionType.Client) ||
                 (main.Connection1.Type == Enums.ConnectionType.Client &&
                  main.Connection2.Type == Enums.ConnectionType.Server)))
            {
                ThreadPool.QueueUserWorkItem(ThreadLoopSsl);
            }
            else
            {
                ThreadPool.QueueUserWorkItem(ThreadLoop);
            }

            Log.Write(Enums.LogType.Info, "Tunnel started");
        }