Exemplo n.º 1
0
    // Awake is always called before any Start function
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            // If you want to use a GNS3 located on the local machine

            /*
             * this.projectHandler = new GNS3sharp.GNS3sharp(
             *  GNS3sharp.ServerProjects.GetProjectIDByName("GameNet")
             * );
             */
            // If you use another machine with IP 192.168.1.157
            this.projectHandler = new GNS3sharp.GNS3sharp(
                ServerProjects.GetProjectIDByName("GameNet", host: "192.168.1.157"),
                _host: "192.168.1.157"
                );
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 2
0
 private void btnFind_Click(object sender, EventArgs e)
 {
     try
     {
         btnStartStop.Text = StartText;
         lstNodes.Items.Clear();
         var projectName = txtProjectName.Text;
         var host        = txtHost.Text;
         var textPort    = txtPort.Text;
         var user        = txtUserName.Text;
         var password    = txtPassword.Text;
         if (string.IsNullOrEmpty(projectName.Trim()))
         {
             MessageBox.Show("Project name field cannot be empty!");
             return;
         }
         if (!ushort.TryParse(textPort, out ushort port))
         {
             MessageBox.Show("Port must be numeric and in range [0; 65535]!");
             return;
         }
         GNS3sharp.SetCredentials(user, password);
         var projectId = ServerProjects.GetProjectIDByName(projectName, host, port);
         if (string.IsNullOrEmpty(projectId))
         {
             MessageBox.Show($"Project with name {projectName} isn't found!");
             return;
         }
         bwoGNS.SetGns3Data(projectName, projectId, host, port);
         bwGNS3_API.RunWorkerAsync(sender);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Internal error occur! Check log file.");
         LoggingHelper.LogEntry(SystemCategories.GeneralError, $"{ex.Message} {ex.StackTrace}");
     }
 }