Exemple #1
0
 public Router(string ip, UpdateProgressMaxValueDelegate UPMVDel, UpdateProgressValueDelegate UPVDel)
 {
     RouterIP         = ip;
     TunnelsQuantity  = 0;
     TunnelInfoStruct = new TunnelInfo[20];
     client           = new SshClient(ip, Router.Username, Router.Password);
     UpdateProgressMaxValueDelegateObj = UPMVDel;
     UpdateProgressValueDelegateObj    = UPVDel;
 }
Exemple #2
0
        public void ThreadChangeTunnelsJob()
        {
            try
            {
                Router.Username = Username.Text;
                Router.Password = Password.Text;

                //                int a = (3 * 9) / 7;
                UpdateProgressMaxValueDelegate UPMVDeleg = new UpdateProgressMaxValueDelegate(UpdateProgressMaxValue);
                UpdateProgressValueDelegate    UPVDeleg  = new UpdateProgressValueDelegate(UpdateProgressValue);

                Invoke(new Action(() =>
                {
                    OverallProgress.Maximum = (int)RouterAddressEnd.Value - (int)RouterAddressStart.Value + 1;
                }));



                for (int i = (int)RouterAddressStart.Value; i <= (int)RouterAddressEnd.Value; i++)
                {
                    Invoke(new Action(() =>
                    {
                        OverallProgressInfo.Text = string.Concat("Processing router 10.99.0.", i.ToString());
                        RouterProgress.Maximum   = 4;
                    }));


                    Router router = new Router(string.Concat("10.99.0.", i.ToString()), UPMVDeleg, UPVDeleg);
                    Invoke(new Action(() =>
                    {
                        RouterProgressInfo.Text = string.Concat("Connecting to 10.99.0.", i.ToString(), "...");
                        RouterProgress.Maximum  = 4;
                    }));
                    try
                    {
                        router.Connect();
                    }
                    catch (Exception ex)
                    {
                        router.WriteLog(ex.ToString());
                    }
                    if (router.client.IsConnected)
                    {
                        Invoke(new Action(() =>
                        {
                            RouterProgressInfo.Text = "Separating Tunnel Numbers";
                        }));
                        router.SeparateTunnelNumbers(router.GetLocalTunnelNumberInfo());
                        Invoke(new Action(() =>
                        {
                            RouterProgress.Value = 1;
                        }));
                        if (router.TunnelsQuantity > 0)
                        {
                            switch (ComboBoxSelectedIndex)
                            {
                            case 0:
                                router.Connect("10.99.0.1", Router.Username, Router.Password);
                                router.GetEdgeTunnelInfo();
                                router.OpenShellStreamSession();
                                router.SyncTunnelInfo();
                                router.RemoveUnnecessaryCryptoKeys();
                                router.Disconnect("edge");
                                break;

                            case 1:
                                router.OpenShellStreamSession();
                                router.SetNetflowLines();
                                break;

                            default:
                                MessageBox.Show("Job is not selected");
                                break;
                            }
                        }

                        router.Disconnect();
                    }


                    Invoke(new Action(() =>
                    {
                        OverallProgress.Value += 1;
                    }));
                }
                MessageBox.Show("Job is complete");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message + " Stack: " + ex.StackTrace + " Source: " + ex.Source + " Hres: " + ex.HResult + " InnerEx: " + ex.InnerException);
            }
        }