2015-03-08 17:20:10 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2015-03-09 16:11:09 -04:00
|
|
|
|
using System.Threading;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2015-03-09 00:28:57 -04:00
|
|
|
|
static String IP;
|
|
|
|
|
static int Port;
|
|
|
|
|
static String RCON;
|
2015-03-30 01:04:10 -04:00
|
|
|
|
static public double Version = 0.8;
|
2015-03-09 21:28:37 -04:00
|
|
|
|
static public double latestVersion;
|
2015-04-11 01:35:07 -04:00
|
|
|
|
static public List<Server> Servers;//
|
2015-03-09 00:28:57 -04:00
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
2015-03-09 21:28:37 -04:00
|
|
|
|
double.TryParse(checkUpdate(), out latestVersion);
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-03-09 16:11:09 -04:00
|
|
|
|
Console.WriteLine(" IW4M ADMIN");
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine(" by RaidMax ");
|
2015-03-09 21:28:37 -04:00
|
|
|
|
if (latestVersion != 0)
|
|
|
|
|
Console.WriteLine(" Version " + Version + " (latest " + latestVersion + ")");
|
2015-03-09 16:11:09 -04:00
|
|
|
|
else
|
|
|
|
|
Console.WriteLine(" Version " + Version + " (unable to retrieve latest)");
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2015-04-10 00:02:12 -04:00
|
|
|
|
Servers = checkConfig();
|
|
|
|
|
foreach (Server IW4M in Servers)
|
2015-03-10 16:45:20 -04:00
|
|
|
|
{
|
|
|
|
|
//Threading seems best here
|
2015-03-23 23:01:05 -04:00
|
|
|
|
Server SV = IW4M;
|
|
|
|
|
Thread monitorThread = new Thread(new ThreadStart(SV.Monitor));
|
2015-03-10 16:45:20 -04:00
|
|
|
|
monitorThread.Start();
|
2015-03-09 00:28:57 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-03-30 01:04:10 -04:00
|
|
|
|
IW4MAdmin_Web.WebFront WebStuff = new IW4MAdmin_Web.WebFront();
|
2015-04-10 00:02:12 -04:00
|
|
|
|
|
2015-03-30 01:04:10 -04:00
|
|
|
|
Thread webFrontThread = new Thread( new ThreadStart(WebStuff.Init));
|
|
|
|
|
webFrontThread.Start();
|
|
|
|
|
|
|
|
|
|
Utilities.Wait(3);
|
|
|
|
|
Console.WriteLine("IW4M Now Initialized! Visit http://127.0.0.1:1624 for server overview.");
|
2015-03-10 16:45:20 -04:00
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
2015-03-09 00:28:57 -04:00
|
|
|
|
|
|
|
|
|
static void setupConfig()
|
|
|
|
|
{
|
2015-03-10 16:45:20 -04:00
|
|
|
|
bool validPort = false;
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("Hey there, it looks like you haven't set up a server yet. Let's get started!");
|
2015-03-10 16:45:20 -04:00
|
|
|
|
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.Write("Please enter the IP: ");
|
|
|
|
|
IP = Console.ReadLine();
|
2015-03-10 16:45:20 -04:00
|
|
|
|
|
|
|
|
|
while (!validPort)
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Please enter the Port: ");
|
|
|
|
|
int.TryParse(Console.ReadLine(), out Port);
|
|
|
|
|
if (Port != 0)
|
|
|
|
|
validPort = true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.Write("Please enter the RCON password: ");
|
|
|
|
|
RCON = Console.ReadLine();
|
|
|
|
|
file Config = new file("config\\servers.cfg", true);
|
|
|
|
|
Console.WriteLine("Great! Let's go ahead and start 'er up.");
|
|
|
|
|
}
|
2015-03-09 16:11:09 -04:00
|
|
|
|
|
|
|
|
|
static String checkUpdate()
|
|
|
|
|
{
|
2015-03-09 21:28:37 -04:00
|
|
|
|
Connection Ver = new Connection("http://raidmax.org/IW4M/Admin/version.php");
|
2015-03-09 16:11:09 -04:00
|
|
|
|
return Ver.Read();
|
|
|
|
|
}
|
2015-03-10 16:45:20 -04:00
|
|
|
|
|
|
|
|
|
static List<Server> checkConfig()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
file Config = new file("config\\servers.cfg");
|
|
|
|
|
String[] SV_CONF = Config.readAll();
|
|
|
|
|
List<Server> Servers = new List<Server>();
|
2015-03-10 17:56:01 -04:00
|
|
|
|
Config.Close();
|
2015-03-10 16:45:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (SV_CONF == null || SV_CONF.Length < 1 || SV_CONF[0] == String.Empty)
|
|
|
|
|
{
|
|
|
|
|
setupConfig(); // get our first time server
|
2015-03-10 17:56:01 -04:00
|
|
|
|
Config = new file("config\\servers.cfg", true);
|
2015-03-10 16:45:20 -04:00
|
|
|
|
Config.Write(IP + ':' + Port + ':' + RCON);
|
2015-03-10 17:56:01 -04:00
|
|
|
|
Config.Close();
|
2015-03-10 16:45:20 -04:00
|
|
|
|
Servers.Add(new Server(IP, Port, RCON));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (String L in SV_CONF)
|
|
|
|
|
{
|
|
|
|
|
String[] server_line = L.Split(':');
|
|
|
|
|
int newPort;
|
|
|
|
|
if (server_line.Length < 3 || !int.TryParse(server_line[1], out newPort))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("You have an error in your server.cfg");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Servers.Add(new Server(server_line[0], newPort, server_line[2]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Servers;
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|