コード例 #1
0
        private void CmdSuperuserRemove()
        {
            //Ensure session
            if (!EnsureSessionExists())
            {
                return;
            }

            //Prompt username + password
            string username = CLITools.PromptFormTextInput("Remove Superuser - Username", "Type the username of the superuser you want to remove.");

            //Find
            DeltaAdminAccount account = null;

            foreach (var u in cfg.admin_credentials)
            {
                if (u.username == username)
                {
                    account = u;
                }
            }

            //Remove
            if (account != null)
            {
                cfg.admin_credentials.Remove(account);
                unsaved = true;
                CLITools.PrintText($"Removed user \"{username}\".", ConsoleColor.Green);
            }
            else
            {
                CLITools.PrintText("Could not find that user. No superusers were removed.", ConsoleColor.Red);
            }
        }
コード例 #2
0
        private void CmdLoadConfig()
        {
            //Prompt install location
            string installPath = CLITools.PromptFormTextInput("Load Config - Specify Path", "Type the filename to load.");

            //Verify
            if (!File.Exists(installPath))
            {
                CLITools.PrintText("ERROR: The file path you specified already exists.", ConsoleColor.Red);
                return;
            }

            //Load
            cfg     = DeltaConfig.OpenConfig(installPath);
            unsaved = false;

            //Write ack
            CLITools.PrintText("Configuration was successfully loaded.", ConsoleColor.Green);
        }
コード例 #3
0
        private void CmdSuperuserAdd()
        {
            //Ensure session
            if (!EnsureSessionExists())
            {
                return;
            }

            //Prompt username + password
            string username = CLITools.PromptFormTextInput("Add Superuser - Username", "Superusers have full access to the admin control panel. Type the username.");
            string password = CLITools.PromptFormTextInput("Add Superuser - Password", "Type the password to the account. This will be salted+hashed and stored locally.");

            //Make sure we don't already have a user with this
            foreach (var u in cfg.admin_credentials)
            {
                if (u.username == username)
                {
                    CLITools.PrintText("ERROR: A user already exists with that username.", ConsoleColor.Red);
                    return;
                }
            }

            //Generate
            CLITools.PrintText("Generating...");
            byte[] hash = PasswordTool.HashPassword(password, out byte[] salt);

            //Add
            cfg.admin_credentials.Add(new DeltaAdminAccount
            {
                username     = username,
                passwordSalt = Convert.ToBase64String(salt),
                passwordHash = Convert.ToBase64String(hash),
                addedAt      = DateTime.UtcNow
            });
            unsaved = true;

            //Ack
            CLITools.PrintText($"Added user \"{username}\"!", ConsoleColor.Green);
        }
コード例 #4
0
        private void CfgEditConfig()
        {
            //Prompt various
            cfg.general.enviornment                = CLITools.PromptFormTextInput("Make Config - Enviornment", "Type an enviornment label. Database collections will have this name.", "prod");
            cfg.general.mongodb_connection         = CLITools.PromptFormTextInput("Make Config - MongoDB Connection", "Type the MongoDB connection string. It will begin with \"mongodb://\".");
            cfg.general.steam_api_token            = CLITools.PromptFormTextInput("Make Config - Steam API Key", "Type your Steam API key. You can obtain it at https://steamcommunity.com/dev/apikey.");
            cfg.general.steam_cache_expire_minutes = CLITools.PromptFormIntInput("Make Config - Steam API Cache Time", "This is the amount of time, in minutes, to cache Steam profiles.", "512");
            cfg.general.firebase_uc_bucket         = CLITools.PromptFormTextInput("Make Config - Firebase UC Bucket", "Type the name of your Firebase bucket that you will use for storing user content.");
            cfg.general.log = CLITools.PromptFormSelect("Make Config - Enable Logging", "Would you like to enable logging? This may slow down the program.", "DISABLED", "ENABLED") == "ENABLED";
            cfg.general.public_serving_port       = CLITools.PromptFormIntInput("Make Config - Serving Port", "This is the port that manager servers will connect on. This should be open.", "43199");
            cfg.general.public_serving_ip         = CLITools.PromptFormTextInput("Make Config - Serving IP", "This is the address that manager servers will connect on. This should be open.", "10.0.1.13");
            cfg.general.admin_session_expire_time = CLITools.PromptFormIntInput("Make Config - Admin Session Time", "This is how long, in minutes, admin sessions are valid for.", "15");
            cfg.general.admin_interface_port      = CLITools.PromptFormIntInput("Make Config - Admin Web Interface Port", "Select a port to run the admin interface on. This should be public facing.", "80");
            cfg.general.sub_configs_directory     = CLITools.PromptFormTextInput("Make Config - Sub Configs Directory", "Choose a directory to load sub-configs from. This could be empty. End with a slash.", "");

            //Prompt hosts
            cfg.hosts.master      = CLITools.PromptFormTextInput("Make Config - Hosts - Master API", "Type the hostname of the master API.", "https://deltamap.net");
            cfg.hosts.echo        = CLITools.PromptFormTextInput("Make Config - Hosts - Echo API", "Type the hostname of the Echo API.", "https://echo-content.deltamap.net");
            cfg.hosts.assets_icon = CLITools.PromptFormTextInput("Make Config - Hosts - Icon Assets API", "Type the hostname of the icon assets API.", "https://icon-assets.deltamap.net");
            cfg.hosts.packages    = CLITools.PromptFormTextInput("Make Config - Hosts - Packages API", "Type the hostname of the packages API.", "https://charlie-packages.deltamap.net");

            //Update
            unsaved = true;
        }
コード例 #5
0
        private void CmdNewConfig()
        {
            //Prompt install location
            string installPath = CLITools.PromptFormTextInput("New Config - Specify Path", "Type the filename to save as. This will be a JSON file.");

            //Verify
            if (!Path.IsPathFullyQualified(installPath))
            {
                CLITools.PrintText("ERROR: The install path you specified is invalid.", ConsoleColor.Red);
                return;
            }
            if (File.Exists(installPath))
            {
                CLITools.PrintText("ERROR: The file path you specified already exists.", ConsoleColor.Red);
                return;
            }

            //Make
            cfg     = DeltaConfig.NewConfig(installPath);
            unsaved = true;

            //Write ack
            CLITools.PrintText("Configuration was successfully created.", ConsoleColor.Green);
        }