Esempio n. 1
0
        /// <summary>
        /// Executes the "configure login" command.
        /// </summary>
        public void OnExecute()
        {
            var loginServerConfiguration = ConfigurationHelper.Load <LoginConfiguration>(ConfigurationFile, ConfigurationConstants.LoginServer);
            var coreServerConfiguration  = ConfigurationHelper.Load <CoreConfiguration>(ConfigurationFile, ConfigurationConstants.CoreServer);
            var loginConfiguration       = new ObjectConfigurationFiller <LoginConfiguration>(loginServerConfiguration);
            var coreConfiguration        = new ObjectConfigurationFiller <CoreConfiguration>(coreServerConfiguration);

            Console.WriteLine("----- Login Server -----");
            loginConfiguration.Fill();
            Console.WriteLine("----- Core Server -----");
            coreConfiguration.Fill();
            coreConfiguration.Value.Password = MD5.GetMD5Hash(coreConfiguration.Value.Password);

            Console.WriteLine("##### Configuration review #####");
            loginConfiguration.Show("Login Server configuration");
            coreConfiguration.Show("Core server configuration");

            bool response = _consoleHelper.AskConfirmation("Save this configuration?");

            if (!response)
            {
                return;
            }

            ConfigurationHelper.Save(ConfigurationFile, new LoginServerConfigurationModel
            {
                CoreConfiguration  = coreConfiguration.Value,
                LoginConfiguration = loginConfiguration.Value
            });
            Console.WriteLine($"Login Server configuration saved in {ConfigurationFile}!");
        }
Esempio n. 2
0
        /// <summary>
        /// Executes the "configure cluster" command.
        /// </summary>
        public void OnExecute()
        {
            var clusterServerConfiguration = ConfigurationHelper.Load <ClusterConfiguration>(ConfigurationFile, ConfigurationConstants.ClusterServer);
            var coreServerConfiguratinon   = ConfigurationHelper.Load <CoreConfiguration>(ConfigurationFile, ConfigurationConstants.CoreServer);
            var clusterConfiguration       = new ObjectConfigurationFiller <ClusterConfiguration>(clusterServerConfiguration);
            var coreConfiguration          = new ObjectConfigurationFiller <CoreConfiguration>(coreServerConfiguratinon);

            Console.WriteLine("----- Cluster Server -----");
            clusterConfiguration.Fill();
            Console.WriteLine("----- Core Server -----");
            coreConfiguration.Fill();
            coreConfiguration.Value.Password = MD5.GetMD5Hash(coreConfiguration.Value.Password);

            Console.WriteLine("##### Configuration review #####");
            clusterConfiguration.Show("Cluster Server configuration");
            coreConfiguration.Show("Core server configuration");

            bool response = _consoleHelper.AskConfirmation("Save this configuration?");

            if (response)
            {
                var configuration = new Dictionary <string, object>
                {
                    { ConfigurationConstants.ClusterServer, clusterConfiguration.Value },
                    { ConfigurationConstants.CoreServer, coreConfiguration.Value }
                };

                ConfigurationHelper.Save(ConfigurationFile, configuration);
                Console.WriteLine($"Cluster Server configuration saved in {ConfigurationFile}!");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Executes the "database configure" command.
        /// </summary>
        public void OnExecute()
        {
            if (string.IsNullOrEmpty(DatabaseConfigurationFile))
            {
                DatabaseConfigurationFile = ConfigurationConstants.DatabasePath;
            }

            var databaseConfiguration = ConfigurationHelper.Load <DatabaseConfiguration>(DatabaseConfigurationFile, ConfigurationConstants.DatabaseConfiguration);
            var dbConfiguration       = new ObjectConfigurationFiller <DatabaseConfiguration>(databaseConfiguration);

            dbConfiguration.Fill();

            if (dbConfiguration.Value.UseEncryption)
            {
                if (string.IsNullOrEmpty(dbConfiguration.Value.EncryptionKey))
                {
                    dbConfiguration.Value.EncryptionKey = Convert.ToBase64String(AesProvider.GenerateKey(AesKeySize.AES256Bits).Key);
                }
                else
                {
                    Console.WriteLine("Warning: your database configuration already contains an encryption key.");
                }
            }

            dbConfiguration.Show("Database configuration");
            Console.WriteLine($"Encryption key: {dbConfiguration.Value.EncryptionKey}");

            bool response = _consoleHelper.AskConfirmation("Save this configuration?");

            if (response)
            {
                ConfigurationHelper.Save(DatabaseConfigurationFile, new DatabaseConfigurationModel()
                {
                    DatabaseConfiguration = dbConfiguration.Value
                });
                Console.WriteLine($"Database configuration saved in '{DatabaseConfigurationFile}'.");
            }
        }
        /// <summary>
        /// Executes the "configure world" command.
        /// </summary>
        public void OnExecute()
        {
            var worldServerConfiguration = ConfigurationHelper.Load <WorldConfiguration>(ConfigurationFile, ConfigurationConstants.WorldServer);
            var coreServerConfiguratinon = ConfigurationHelper.Load <CoreConfiguration>(ConfigurationFile, ConfigurationConstants.CoreServer);
            var worldConfiguration       = new ObjectConfigurationFiller <WorldConfiguration>(worldServerConfiguration);
            var coreConfiguration        = new ObjectConfigurationFiller <CoreConfiguration>(coreServerConfiguratinon);

            Console.WriteLine("----- World Server -----");
            worldConfiguration.Fill();
            worldConfiguration.Value.Maps = new List <string>
            {
                "WI_WORLD_MADRIGAL",
                "WI_DUNGEON_FL_MAS"
            };

            Console.WriteLine("----- Core Server -----");
            coreConfiguration.Fill();
            coreConfiguration.Value.Password = MD5.GetMD5Hash(coreConfiguration.Value.Password);

            Console.WriteLine("##### Configuration review #####");
            worldConfiguration.Show("World Server configuration");
            coreConfiguration.Show("Core server configuration");

            bool response = _consoleHelper.AskConfirmation("Save this configuration?");

            if (response)
            {
                var configuration = new Dictionary <string, object>
                {
                    { ConfigurationConstants.WorldServer, worldConfiguration.Value },
                    { ConfigurationConstants.CoreServer, coreConfiguration.Value }
                };

                ConfigurationHelper.Save(ConfigurationFile, configuration);
                Console.WriteLine($"World Server configuration saved in {ConfigurationFile}!");
            }
        }