Ejemplo n.º 1
0
        private static string GetTraversalPath(string hostAndPort)
        {
            Type requiredType = typeof(IConfigurationSecureDelegator);

            ClientCredentials creds = new ClientCredentials(
                Guid.NewGuid().ToString().Substring(0, 8), Guid.NewGuid().ToString().Substring(0, 8));

            IConfigurationSecureDelegator remoteObj =
                (IConfigurationSecureDelegator)Activator.GetObject
                    (requiredType, "tcp://" + hostAndPort + "/TrackIt.Core.ConfigurationService");
            DeploymentValues values = remoteObj.GetProductDeploymentValues();

            string fileStorageDir = values.FileStorageDataDirectory.ToString();
            string webDataDir     = values.TrackItWebDataCacheDirectory.ToString();

            if (fileStorageDir == null || webDataDir == null)
            {
                Console.WriteLine("Could not calculate traversal path, falling back to the default");
                return("..\\..\\..\\..\\..\\Track-It! Web\\Web\\Installers\\");
            }
            else
            {
                string traversalPath = CalculateTraversal(webDataDir, fileStorageDir);
                Console.WriteLine("Calculated traversal path " + traversalPath);
                return(traversalPath);
            }
        }
Ejemplo n.º 2
0
        public static void GetPasswords(string hostAndPort, string filename)
        {
            string databaseType       = "DatabaseType";
            string databaseServerName = "DatabaseServerName";
            string databaseName       = "DatabaseName";
            string schemaOwner        = "SchemaOwnerDatabaseUser";
            string databasePw         = "EncryptedSystemDatabasePassword";
            string domainAdminName    = "DomainAdminUserName";
            string domainAdminPw      = "DomainAdminEncryptedPassword";

            Type requiredType = typeof(IConfigurationSecureDelegator);

            ClientCredentials creds = new ClientCredentials(
                Guid.NewGuid().ToString().Substring(0, 8), Guid.NewGuid().ToString().Substring(0, 8));

            IConfigurationSecureDelegator remoteObj =
                (IConfigurationSecureDelegator)Activator.GetObject
                    (requiredType, "tcp://" + hostAndPort + "/TrackIt.Core.ConfigurationService");
            DeploymentValues values = remoteObj.GetProductDeploymentValues();

            using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write))
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    if (values.DatabaseType.ToString() != null)
                    {
                        sw.WriteLine(databaseType + ": " + values.DatabaseType.ToString());
                    }
                    if (values.DatabaseServerName != null)
                    {
                        sw.WriteLine(databaseServerName + " " + values.DatabaseServerName);
                    }
                    if (values.DatabaseName != null)
                    {
                        sw.WriteLine(databaseName + " " + values.DatabaseName);
                    }
                    if (values.SchemaOwnerDatabaseUser != null)
                    {
                        sw.WriteLine(schemaOwner + " " + values.SchemaOwnerDatabaseUser);
                    }
                    if (values.EncryptedSystemDatabasePassword != String.Empty &&
                        values.EncryptedSystemDatabasePassword != null)
                    {
                        sw.WriteLine(databasePw + " " + DecryptString(values.EncryptedSystemDatabasePassword));
                    }
                    if (values.DomainAdminUserName != null)
                    {
                        sw.WriteLine(domainAdminName + " " + values.DomainAdminUserName);
                    }
                    if (values.DomainAdminEncryptedPassword != String.Empty &&
                        values.DomainAdminEncryptedPassword != null)
                    {
                        sw.WriteLine(domainAdminPw + " " + DecryptString(values.DomainAdminEncryptedPassword));
                    }
                }
            Console.WriteLine("Done. Credentials have been written to " + filename);
        }
Ejemplo n.º 3
0
        private void serverStoreInMemory()
        {
            //Create the GameServerObject
            GameServerObject deployConfiguredServer = new GameServerObject();

            //Assign Data to the GameServerObject
            //Server-based Properties
            deployConfiguredServer.SERVER_name_friendly    = txtServerGivenName.Text;
            deployConfiguredServer.SERVER_type             = _currentDeploymentValues.SERVER_type;
            deployConfiguredServer.SERVER_launch_arguments = _currentDeploymentValues.SERVER_launch_arguments;
            deployConfiguredServer.SERVER_executable       = _currentDeploymentValues.SERVER_executable;
            deployConfiguredServer.SERVER_port             = "";

            //Game-based properties
            deployConfiguredServer.GAME_maxplayers = 6; //Defalt middle value
            deployConfiguredServer.GAME_map        = "NONE";

            //Directory-based Properties
            deployConfiguredServer.DIR_install_location    = _currentDeploymentValues.DIR_install_location;
            deployConfiguredServer.DIR_root                = _currentDeploymentValues.DIR_root;
            deployConfiguredServer.DIR_maps                = _currentDeploymentValues.DIR_maps;
            deployConfiguredServer.DIR_maps_file_extension = _currentDeploymentValues.DIR_maps_file_extension;
            deployConfiguredServer.DIR_mods                = _currentDeploymentValues.DIR_mods;
            deployConfiguredServer.DIR_config              = _currentDeploymentValues.DIR_config;

            //Steam-based Properties
            deployConfiguredServer.STEAM_authrequired      = _currentDeploymentValues.STEAM_authrequired;
            deployConfiguredServer.STEAM_steamcmd_required = _currentDeploymentValues.STEAM_steamcmd_required;
            deployConfiguredServer.STEAM_workshop_enabled  = _currentDeploymentValues.STEAM_workshop_enabled;

            //Miscellanious Properties
            deployConfiguredServer.ENGINE_type             = _currentDeploymentValues.ENGINE_type;
            deployConfiguredServer.bsm_integration         = _currentDeploymentValues.bsm_integration;
            deployConfiguredServer.bsm_custominstallfolder = _currentDeploymentValues.bsm_custominstallfolder;

            //Store that newly assigned and JSON-filled server into the GameServerObject Collection
            GameServerManagement.ServerCollection.Add(deployConfiguredServer);

            //Redundantly write the data to disk in the event of a crash.
            GameServerManagement.ConfigWrite();

            btnCancelDeployGameserver.Visible = false;
            btnDeployGameserver.Enabled       = true;
            _currentDeploymentValues          = null;
        }
Ejemplo n.º 4
0
 private void btnCancelDeployGameserver_Click(object sender, EventArgs e)
 {
     if (_currentDeploymentValues.STEAM_steamcmd_required)
     {
         Execute(@"C:\Windows\System32\taskkill", "/F /IM steamcmd.exe", true);
         btnCancelDeployGameserver.Visible = false;
     }
     else
     {
         //Kill program being used to deploy a server.
     }
     btnDeployGameserver.Enabled = true;
     progressbarDownloadProgressOverall.Value = 0;
     _currentDeploymentValues        = null;
     lblDownloadProgress.Text        = "Download / Installation Progress:";
     lblDownloadProgressDetails.Text = "Status: Deployment Cancelled";
     lblVerifyIntegrity.Visible      = true;
     chkVerifyIntegrity.Visible      = true;
 }
Ejemplo n.º 5
0
        private void btnDeployGameserver_Click(object sender, EventArgs e)
        {
            //Pull all gameserver data from gameservers.json, split all json strings into a list, iterate through that list for specific data.
            if (GameServerManagement.ServerCollection != null)
            {
                foreach (GameServerObject gameserver in GameServerManagement.ServerCollection)
                {
                    if (txtServerGivenName.Text == gameserver.SERVER_name_friendly)
                    {
                        MetroMessageBox.Show(ActiveForm, "Unfortunately, you must give unique names to every server you deploy, using the exact same name would cause several issues.", "Identical gameserver name already exists.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return; //Break gracefully out of the entire void function.
                    }
                }
            }

            //Query specific appID for all required data.
            var gameserverType          = (GameserverType)dropdownServerSelection.SelectedItem;
            GameServerObject gameServer = ServerAPI.QUERY_DATA(gameserverType.Id);

            //Retrieve the data that was just stored into the deployment server list.
            var deploymentValues = new DeploymentValues
            {
                SERVER_type             = gameServer.SERVER_type,
                SERVER_launch_arguments = gameServer.SERVER_launch_arguments,
                SERVER_executable       = gameServer.SERVER_executable,
                DIR_root = gameServer.DIR_root,
                DIR_maps = gameServer.DIR_maps,
                DIR_maps_file_extension = gameServer.DIR_maps_file_extension,
                DIR_mods                = gameServer.DIR_mods,
                DIR_config              = gameServer.DIR_config,
                STEAM_authrequired      = gameServer.STEAM_authrequired,
                STEAM_steamcmd_required = gameServer.STEAM_steamcmd_required,
                STEAM_workshop_enabled  = gameServer.STEAM_workshop_enabled,
                ENGINE_type             = gameServer.ENGINE_type,
                bsm_integration         = gameServer.bsm_integration,
                bsm_custominstallfolder = gameServer.bsm_custominstallfolder
            };

            //Determine where to deploy the server based on user input.
            if (txtboxDestinationFolder.Text == "")
            {
                deploymentValues.DIR_install_location    = Environment.CurrentDirectory;
                deploymentValues.bsm_custominstallfolder = false;
            }
            else
            {
                deploymentValues.DIR_install_location    = txtboxDestinationFolder.Text;
                deploymentValues.bsm_custominstallfolder = true;
            }

            //Determine whether or not to verify integrity of the installation.
            if (chkVerifyIntegrity.Value)
            {
                deploymentValues.verify_integrity = " +validate";
            }
            else
            {
                deploymentValues.verify_integrity = "";
            }

            DialogResult result;

            switch (deploymentValues.bsm_integration)
            {
            case "none":
                result = MetroMessageBox.Show(ActiveForm,
                                              "Type of GameServer: [" + dropdownServerSelection.Text + "]\n" + "Deploy to: [" +
                                              deploymentValues.DIR_install_location + "]" +
                                              "\n\nWARNING: This gameserver currently has NO BSM support.\nYou can deploy it, and launch it, but BSM cannot configure it at this time.",
                                              "Deploy GameServer?", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
                break;

            case "partial":
                result = MetroMessageBox.Show(ActiveForm,
                                              "Type of GameServer: [" + dropdownServerSelection.Text + "]\n" + "Deploy to: [" +
                                              deploymentValues.DIR_install_location + "]" +
                                              "\n\nWARNING: This gameserver currently has PARTIAL BSM support.\nYou can deploy it, and launch it, and have experimental control over it directly through BSM.",
                                              "Deploy GameServer?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                break;

            case "full":
                result = MetroMessageBox.Show(ActiveForm,
                                              "Type of GameServer: [" + dropdownServerSelection.Text + "]\n" + "Deploy to: [" +
                                              deploymentValues.DIR_install_location + "]", "Deploy GameServer?", MessageBoxButtons.YesNo,
                                              MessageBoxIcon.Question);
                break;

            default:
                result = DialogResult.Yes;
                break;
            }

            if (result == DialogResult.Yes)
            {
                btnCancelDeployGameserver.Visible = true;
                btnDeployGameserver.Enabled       = false;
                serverDeploy(deploymentValues);
                lblDownloadProgress.Text   = "Download / Installation Progress:";
                lblVerifyIntegrity.Visible = false;
                chkVerifyIntegrity.Visible = false;
            }
        }
Ejemplo n.º 6
0
        //Method to deploy gameservers given values from the DeploymentValues class
        private void serverDeploy(DeploymentValues deploymentValues)
        {
            _currentDeploymentValues = deploymentValues;

            //Enable cancel button to terminate deployment process if needed.
            lblDownloadProgressDetails.Text = "Status: Downloading " + dropdownServerSelection.Text + "...";

            switch (deploymentValues.STEAM_steamcmd_required)
            {
            case true:
            {
                lblDownloadProgressDetails.Text = "Status: Downloading / Initializing SteamCMD...";
                SteamCMD.DownloadSteamCMD();
                switch (deploymentValues.STEAM_authrequired)
                {
                case true:
                    if (txtSteamUsername.Text == "" || txtSteamPassword.Text == "")
                    {
                        MetroMessageBox.Show(ActiveForm, "Please fill out your Steam username and password.", "Steam Credentials Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    SteamGuardProcess.StartInfo.Arguments = string.Format(@"+login {0} {1} +force_install_dir {2} +app_update {3} {4} +quit",
                                                                          txtSteamUsername.Text,
                                                                          txtSteamPassword.Text,
                                                                          deploymentValues.DIR_install_location,
                                                                          ServerAPI.QUERY_STEAM_APPID(dropdownServerSelection.Text),
                                                                          deploymentValues.verify_integrity);

                    SteamGuardProcess.StartInfo.FileName               = Environment.CurrentDirectory + @"\steamcmd.exe";
                    SteamGuardProcess.StartInfo.UseShellExecute        = false;
                    SteamGuardProcess.StartInfo.RedirectStandardOutput = true;
                    SteamGuardProcess.StartInfo.RedirectStandardInput  = true;
                    SteamGuardProcess.StartInfo.RedirectStandardError  = true;
                    SteamGuardProcess.EnableRaisingEvents              = true;
                    SteamGuardProcess.StartInfo.CreateNoWindow         = true;
                    SteamGuardProcess.ErrorDataReceived  += proc_DataReceived;
                    SteamGuardProcess.OutputDataReceived += proc_DataReceived;
                    SteamGuardProcess.Start();
                    SteamGuardProcess.BeginErrorReadLine();
                    SteamGuardProcess.BeginOutputReadLine();
                    break;

                case false:
                    try
                    {
                        Execute(Environment.CurrentDirectory + @"\steamcmd.exe",
                                string.Format(@"+login anonymous +force_install_dir {0} +app_update {1} {2} +quit",
                                              deploymentValues.DIR_install_location,
                                              ServerAPI.QUERY_STEAM_APPID(dropdownServerSelection.Text),
                                              deploymentValues.verify_integrity), true);
                    }
                    catch (Exception)
                    {
                        MetroMessageBox.Show(ActiveForm, "We cannot find the required executable to deploy the server!  Either it is missing, or the server configuration for this gameserver is corrupted.", "Error Deploying GameServer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;
                }
            }
            break;

            case false:
            {
                //RUN OTHER CODE TO DEPLOY THE NON-STEAMCMD GAMESERVER
            }
            break;
            }
        }