2017-06-19 13:58:01 -04:00
|
|
|
|
using SharedLibrary;
|
|
|
|
|
using System;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
2017-06-19 13:58:01 -04:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin
|
|
|
|
|
{
|
2017-06-19 13:58:01 -04:00
|
|
|
|
class ServerConfigurationGenerator
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
2017-06-19 13:58:01 -04:00
|
|
|
|
public static ServerConfiguration Generate()
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
|
|
|
|
string IP = String.Empty;
|
|
|
|
|
int Port = 0;
|
|
|
|
|
string Password;
|
2017-06-19 13:58:01 -04:00
|
|
|
|
bool AllowMultipleOwners;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
while (IP == String.Empty)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Enter server IP: ");
|
|
|
|
|
string input = Console.ReadLine();
|
|
|
|
|
IPAddress.Parse(input);
|
|
|
|
|
IP = input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
while (Port == 0)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Enter server port: ");
|
|
|
|
|
Port = Int32.Parse(Console.ReadLine());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.Write("Enter server RCON password: ");
|
|
|
|
|
Password = Console.ReadLine();
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Console.Write("Allow multiple owners? [y/n]: ");
|
|
|
|
|
AllowMultipleOwners = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y';
|
|
|
|
|
|
|
|
|
|
var config = new ServerConfiguration() { IP = IP, Password = Password, Port = Port, AllowMultipleOwners = AllowMultipleOwners };
|
2017-05-26 18:49:27 -04:00
|
|
|
|
config.Write();
|
|
|
|
|
|
2017-06-19 13:58:01 -04:00
|
|
|
|
Console.Write("Configuration saved, add another? [y/n]:");
|
2017-05-26 18:49:27 -04:00
|
|
|
|
if (Console.ReadLine().ToLower().First() == 'y')
|
|
|
|
|
Generate();
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|