예제 #1
0
        private void Loop()
        {
            try
            {
                TcpListener listener = new TcpListener(IPAddress.Any,
                                                       main.Connection2.Port);

                listener.Start();

                TcpClient client, dest;

                while (main.Status == 1)
                {
                    Log.Write(Enums.LogType.Info, "Waiting for clients ...");
                    client = listener.AcceptTcpClient();
                    Log.Write(Enums.LogType.Info, "New client from " +
                              ((IPEndPoint)client.Client.RemoteEndPoint)
                              .Address.ToString());

                    dest = new TcpClient(main.Connection1.Host,
                                         main.Connection1.Port);

                    Tunnel tunnel = new Tunnel();
                    tunnel.Start(client, dest, main);
                }
            }
            catch
            {
                Log.Write(Enums.LogType.Error, "Can't start PortTunnel");
            }
        }
예제 #2
0
        private void Loop()
        {
            try
            {
                TcpListener controlListener = new TcpListener(
                    IPAddress.Any, main.ControlPort);

                controlListener.Start();

                TcpClient controlClient =
                    controlListener.AcceptTcpClient();

                while (true)
                {
                    if (controlClient.Available > 0)
                    {
                        if (controlClient.GetStream().ReadByte()
                            == (byte)'c')
                        {
                            break;
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                }

                TcpListener mainListener = new TcpListener(
                    IPAddress.Any, main.Connection1.Port);
                mainListener.Start();

                TcpListener tunnelListener = new TcpListener(
                    IPAddress.Any, main.Connection2.Port);
                tunnelListener.Start();

                while (main.Status == 1)
                {
                    TcpClient client = mainListener.AcceptTcpClient();

                    controlClient.GetStream().WriteByte((byte)'n');

                    TcpClient tunnelClient =
                        tunnelListener.AcceptTcpClient();

                    Tunnel tunnel = new Tunnel();
                    tunnel.Start(client, tunnelClient, main);
                }
            }
            catch
            {
                Log.Write(Enums.LogType.Error,
                          "Can't start PortTunnel");
            }
        }
예제 #3
0
        private void Loop()
        {
            try
            {
                TcpClient controlClient = new TcpClient(
                    main.Connection2.Host, main.ControlPort);

                Log.Write(Enums.LogType.Info, "Connected to PortTunnel Server");

                Thread.Sleep(2);

                controlClient.GetStream().WriteByte((byte)'c');

                Thread.Sleep(2);

                while (main.Status == 1)
                {
                    if (controlClient.Available > 0)
                    {
                        if (controlClient.GetStream().ReadByte()
                            == (byte)'n')
                        {
                            TcpClient cl1 = new TcpClient(
                                main.Connection2.Host, main.Connection2.Port);

                            TcpClient tunnelClient = new TcpClient(
                                main.Connection1.Host, main.Connection1.Port);

                            Tunnel tunnel = new Tunnel();
                            tunnel.Start(cl1, tunnelClient, main);
                        }
                    }
                }
            }
            catch
            {
                Log.Write(Enums.LogType.Error,
                          "Can't start PortTunnel");
            }
        }