2018-03-14 01:36:25 -04:00
|
|
|
|
using SharedLibrary;
|
|
|
|
|
using SharedLibrary.Configuration;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin
|
|
|
|
|
{
|
|
|
|
|
class ConfigurationGenerator
|
|
|
|
|
{
|
|
|
|
|
public static List<ServerConfiguration> GenerateServerConfig(List<ServerConfiguration> configList)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var newConfig = new ServerConfiguration();
|
|
|
|
|
|
|
|
|
|
while (string.IsNullOrEmpty(newConfig.IPAddress))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Enter server IP Address: ");
|
|
|
|
|
string input = Console.ReadLine();
|
|
|
|
|
IPAddress.Parse(input);
|
|
|
|
|
newConfig.IPAddress = input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (newConfig.Port == 0)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Enter server port: ");
|
|
|
|
|
newConfig.Port = Int16.Parse(Console.ReadLine());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.Write("Enter server RCON password: ");
|
|
|
|
|
newConfig.Password = Console.ReadLine();
|
2018-03-18 22:25:11 -04:00
|
|
|
|
newConfig.AutoMessages = new List<string>();
|
|
|
|
|
newConfig.Rules = new List<string>();
|
2018-03-14 01:36:25 -04:00
|
|
|
|
|
|
|
|
|
configList.Add(newConfig);
|
|
|
|
|
|
|
|
|
|
Console.Write("Configuration saved, add another? [y/n]:");
|
|
|
|
|
if (Console.ReadLine().ToLower().First() == 'y')
|
|
|
|
|
GenerateServerConfig(configList);
|
|
|
|
|
|
|
|
|
|
return configList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|