示例#1
0
        public static void UsingArgs(string[] args)
        {
            PortTunnel tunnel = new PortTunnel(args);

            tunnel.Start();
            Console.ReadLine();
        }
示例#2
0
        private void BtnStart_Click(object sender, System.EventArgs e)
        {
            try
            {
                string h1 = etH1.Text;
                string h2 = etH2.Text;

                int p1 = int.Parse(etP1.Text);
                int p2 = int.Parse(etP2.Text);

                int cp = int.Parse(etCP.Text);
                int to = int.Parse(etTo.Text);

                ISharedPreferences       preferences = GetSharedPreferences("SETUP", FileCreationMode.Private);
                ISharedPreferencesEditor editor      = preferences.Edit();

                editor.PutString("H1", h1);
                editor.PutString("H2", h2);

                editor.PutInt("P1", p1);
                editor.PutInt("P2", p2);
                editor.PutInt("CP", cp);
                editor.PutInt("TO", to);

                editor.PutBoolean("HTTP", cbHttp.Checked);
                editor.PutBoolean("SSL", cbSsl.Checked);

                editor.Commit();

                Connection c1 = new Connection(h1, p1);
                Connection c2 = new Connection(h2, p2);

                tunnel = new PortTunnel(c1, c2, to, cp)
                {
                    HttpProtocol = cbHttp.Checked,
                    DestIsSsl    = cbSsl.Checked
                };

                tunnel.NewLogOutput += (sen, text) =>
                {
                    try
                    {
                        log.Text += text;

                        activeConnections.Text = ((PortTunnel)tunnel).ActiveConnections.ToString();
                    }
                    catch { }
                };

                tunnel.NewStreamLogCompleted += (sen, content) => {
                };

                BlockInputs();

                tunnel.Start();
            }
            catch { }
        }
示例#3
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     try
     {
         pt.Stop();
     }
     catch { }
     try
     {
         PortTunnel.ExitEnvironment();
     }
     catch { }
 }
示例#4
0
        private void BtnStop_Click(object sender, System.EventArgs e)
        {
            try
            {
                tunnel.Stop();
            }
            catch { }

            try
            {
                PortTunnel.ExitEnvironment();
            }
            catch { }
        }
示例#5
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (!intPort1.Text.Equals("") && !intPort2.Text.Equals(""))
            {
                Connection c1 = null, c2 = null;

                try
                {
                    int p1 = int.Parse(intPort1.Text);
                    int p2 = int.Parse(intPort2.Text);

                    int cp = 0;

                    if (selectSC.Checked)
                    {
                        string h1 = txtHost1.Text;

                        c1 = new Connection(h1, p1);
                        c2 = new Connection(p2);

                        this.Text = "PortTunnel ServerClient";
                    }
                    else if (selectCC.Checked)
                    {
                        string h1 = txtHost1.Text;
                        string h2 = txtHost2.Text;

                        c1 = new Connection(h1, p1);
                        c2 = new Connection(h2, p2);

                        cp = int.Parse(intCP.Text);

                        this.Text = "PortTunnel Client";
                    }
                    else if (selectSS.Checked)
                    {
                        c1 = new Connection(p1);
                        c2 = new Connection(p2);

                        cp = int.Parse(intCP.Text);

                        this.Text = "PortTunnel Server";
                    }

                    pt = new PortTunnel(c1, c2, int.Parse(intTimeout.Text), cp);

                    pt.NewLogOutput += (sen, text) =>
                    {
                        MethodInvoker invoker = new MethodInvoker(delegate
                        {
                            txtLog.Text += text;

                            Console.Write(text);

                            txtActiveConnections.Text = ((PortTunnel)sen).ActiveConnections.ToString();
                        });
                        this.Invoke(invoker);
                    };

                    if (cbStreamLog.Checked)
                    {
                        pt.NewStreamLogCompleted += (sen, text) =>
                        {
                            string filename = ((string)text).Split('\r')[0]
                                              .Replace(' ', '-').Replace(":", "-Port-") + ".txt";

                            if (!Directory.Exists("Log"))
                            {
                                Directory.CreateDirectory("Log");
                            }

                            File.WriteAllText("Log/" + filename, (string)text);
                        };
                    }

                    pt.HttpProtocol = cbHttp.Checked;
                    pt.DestIsSsl    = cbSsl.Checked;

                    BlockInputs();

                    pt.Start();
                }
                catch { }
            }
        }