コード例 #1
0
ファイル: Form1.cs プロジェクト: ardenboy/AdminVPNsetup
        private void DisconnectButton_Click(object sender, EventArgs e)
        {
            if (Data.SettingName == null)
            {
                MessageBox.Show("I am not connected anywhere! R u Blind?"); return;
            }
            ;
            _cmd _cD = new _cmd();

            _cD.Execmd("localhost:5555", "server", " CascadeOffline ", Data.SettingName, " /AdminHub:Bridge /Password:pirkon12");
            Thread.Sleep(2000);
            _cascadeStatus();
            if (!Data._cscdC)
            {
                NetworkConnection.Text        = " ";
                inter_ip.Text                 = " ";
                textBox2.BackColor            = Color.Red;
                ConnectButoon.Enabled         = true;
                DisconnectButton.Enabled      = false;
                menuToolStripMenuItem.Enabled = true;
                //  Protocols._cmd_enable_bindings();
                //   Protocols._cmd_enable_all();
                NicInfo.SetDHCP(Data._bridgeWindowsname);
                //  NicInfo._startwithDhcpON();

                Thread.Sleep(3000);
                MessageBox.Show("The program is closing. Thanks for using it");
                System.Environment.Exit(0);
            }
            else
            {
                textBox2.BackColor       = Color.Green;
                ConnectButoon.Enabled    = false;
                DisconnectButton.Enabled = true;
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: ardenboy/AdminVPNsetup
        private void ConnectButton_Click(object sender, EventArgs e)
        {
            Data._localbridgevpnmask = "255.255.255.0";
            NicInfo._brdgeNicName();
            NetworkConnection.Text = Data._bridgeWindowsname;
            if (UserNameBox.Text.EndsWith("D"))
            {
                Data.DhcpMode = true;
                MessageBox.Show("You are in DHCP mode. Please make sure to give a" + "\n" + "free IP of your network to remote connecting party");
                inter_ip.Enabled = true;
            }
            else
            {
                Data._localbridgevpnmask = "255.255.0.0";
                inter_ip.Enabled         = true;
            }
            //if (inter_ip.Text != null)
            //{
            //    NicInfo._brdgeNicName();
            //    NetworkConnection.Text = Data._bridgeWindowsname;
            //    if (Data.netnamefound)
            //    {
            //        NetworkConnection.Text = Data._bridgeWindowsname;
            //        if (inter_ip.Text.Contains("169.254"))
            //        { Data._localbridgevpnmask = "255.255.0.0"; }
            //        else
            //        { Data._localbridgevpnmask = "255.255.255.0"; }
            //        Data._localbridgevpnip = inter_ip.Text;
            //        //     NicInfo._startwithDhcpON();
            //    }
            //    else
            //    {
            //        MessageBox.Show("This network  card is not supported at the moment." + "\n" +
            //                        "Please enter IP & Subnet Manualy after connection!" + "\n" +
            //                        "   " + inter_ip.Text + "  " + Data._localbridgevpnmask);
            //    }
            //    if (UserNameBox.Text.EndsWith("D"))
            //    {
            //        Data.DhcpMode = true;
            //        MessageBox.Show("You are in DHCP mode. Please make sure to give a" + "\n" + "free IP of your network to remote connecting party");
            //    }
            //if (Data.DhcpMode)
            //{
            //    Protocols._cmd_disable_all();
            //    Protocols._cmd_enable_vpn();
            //}
            //  }
            _cmd _cc1 = new _cmd();

            _cc1.Execmd("localhost:5555", "server", "CascadeOnline ", Data.SettingName, " /AdminHub:Bridge /Password:pirkon12");;
            Thread.Sleep(1000);
            Data._localbridgevpnip = inter_ip.Text;
            if (String.IsNullOrEmpty(Data._localbridgevpnip))
            {
                NicInfo.SetDHCP(Data._bridgeWindowsname);
            }
            else
            {
                NicInfo.SetIpAddress(Data._bridgeWindowsname, Data._localbridgevpnip, Data._localbridgevpnmask);
            }
            // NicInfo.SetIpAddress(Data._bridgeWindowsname, Data._localbridgevpnip, Data._localbridgevpnmask);
            Thread.Sleep(1000);
            // NicInfo._setLocalBridgeStatic();
            _cascadeStatus();
            if (Data._cscdC)
            {
                textBox2.BackColor            = Color.Green;
                ConnectButoon.Enabled         = false;
                menuToolStripMenuItem.Enabled = false;
                DisconnectButton.Enabled      = true;
                if (inter_ip.Text != null)
                {
                    Data._localbridgeIP = inter_ip.Text;
                }
            }
            else
            {
                textBox2.BackColor       = Color.Red;
                ConnectButoon.Enabled    = true;
                DisconnectButton.Enabled = false;
            }
        }