Ejemplo n.º 1
0
        void TestServer()
        {
            if (testing == false)
            {
                this.Dispatcher.Invoke(() =>
                {
                    txtStatus.Text       = "TEST";
                    txtStatus.Background = new SolidColorBrush(Color.FromRgb(0xff, 0xff, 0x00));
                });

                testing = true;
                try
                {
                    Socks5Client.Socks5Client p = new Socks5Client.Socks5Client("localhost", 80, "www.baidu.com", 80, "lemur", "bison");
                    // p.OnConnected += p_OnConnected;
                    if (p.Connect())
                    {
                        DoLog("====       TEST OK       ====");
                        this.Dispatcher.Invoke(() =>
                        {
                            txtStatus.Text       = "OK";
                            txtStatus.Background = new SolidColorBrush(Color.FromRgb(0x00, 0xff, 0x00));
                        });
                        p.Disconnect();
                    }
                    else
                    {
                        DoLog("====        CHK NET        ====");
                        this.Dispatcher.Invoke(() =>
                        {
                            txtStatus.Text       = "LOCAL";
                            txtStatus.Background = new SolidColorBrush(Color.FromRgb(0xff, 0x88, 0x00));
                        });
                    }


                    //p.Send(new byte[] {0x11, 0x21});
                }
                catch (Exception ex)
                {
                    DoLog("####     TEST FAIL    ####");
                    this.Dispatcher.Invoke(() =>
                    {
                        txtStatus.Text       = "OFF";
                        txtStatus.Background = new SolidColorBrush(Color.FromRgb(0xff, 0x00, 0x00));
                    });
                    btnResetSrv_Click(null, null);
                }
                finally
                {
                    testing = false;
                }
            }
        }
Ejemplo n.º 2
0
        void TestServer()
        {
            if (testing == false)
            {
                this.Dispatcher.Invoke(() =>
                {
                    txtStatus.Text = "TEST";
                    txtStatus.Background = new SolidColorBrush(Color.FromRgb(0xff, 0xff, 0x00));
                });

                testing = true;
                try
                {

                    Socks5Client.Socks5Client p = new Socks5Client.Socks5Client("localhost", 80, "www.baidu.com", 80, "lemur", "bison");
                    // p.OnConnected += p_OnConnected;
                    if (p.Connect())
                    {
                        DoLog("====       TEST OK       ====");
                        this.Dispatcher.Invoke(() =>
                        {
                            txtStatus.Text = "OK";
                            txtStatus.Background = new SolidColorBrush(Color.FromRgb(0x00, 0xff, 0x00));
                        });
                        p.Disconnect();
                    }
                    else
                    {
                        DoLog("====        CHK NET        ====");
                        this.Dispatcher.Invoke(() =>
                        {
                            txtStatus.Text = "LOCAL";
                            txtStatus.Background = new SolidColorBrush(Color.FromRgb(0xff, 0x88, 0x00));
                        });
                    }

                    //p.Send(new byte[] {0x11, 0x21});

                }
                catch (Exception ex)
                {
                    DoLog("####     TEST FAIL    ####");
                    this.Dispatcher.Invoke(() =>
                    {
                        txtStatus.Text = "OFF";
                        txtStatus.Background = new SolidColorBrush(Color.FromRgb(0xff, 0x00, 0x00));
                    });
                    btnResetSrv_Click(null, null);
                }
                finally
                {
                    testing = false;
                }
            }
        }