mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
vpn check updates, fixed some issues,
"masked" status is now sensitive discord link in webfront if configured
This commit is contained in:
@ -1,2 +0,0 @@
|
||||
127.0.0.1
|
||||
80
|
@ -12,8 +12,6 @@ namespace IW4MAdmin
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool AllocConsole();
|
||||
static public double Version { get; private set; }
|
||||
static public ApplicationManager ServerManager = ApplicationManager.GetInstance();
|
||||
public static string OperatingDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
|
||||
@ -33,15 +31,20 @@ namespace IW4MAdmin
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
/*var v1 = SharedLibrary.Helpers.Vector3.Parse("(737, 1117, 268)");
|
||||
var v2 = SharedLibrary.Helpers.Vector3.Parse("(1510, 672.98, -228.66)");
|
||||
double angleBetween = v1.AngleBetween(v2);*/
|
||||
|
||||
|
||||
CheckDirectories();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
ServerManager = ApplicationManager.GetInstance();
|
||||
SharedLibrary.Database.Repair.Run(ServerManager.Logger);
|
||||
await ServerManager.Init();
|
||||
ServerManager.Start();
|
||||
});
|
||||
|
||||
|
||||
ServerManager = ApplicationManager.GetInstance();
|
||||
SharedLibrary.Database.Repair.Run(ServerManager.Logger);
|
||||
ServerManager.Init().Wait();
|
||||
Task.Run(() => ServerManager.Start());
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
@ -95,9 +98,6 @@ namespace IW4MAdmin
|
||||
if (!Directory.Exists($"{curDirectory}Logs"))
|
||||
Directory.CreateDirectory($"{curDirectory}Logs");
|
||||
|
||||
if (!Directory.Exists($"{curDirectory}Database"))
|
||||
Directory.CreateDirectory($"{curDirectory}Database");
|
||||
|
||||
if (!Directory.Exists($"{curDirectory}Plugins"))
|
||||
Directory.CreateDirectory($"{curDirectory}Plugins");
|
||||
}
|
||||
|
@ -104,40 +104,38 @@ namespace IW4MAdmin
|
||||
{
|
||||
var Conf = ServerConfiguration.Read(file);
|
||||
|
||||
Task.Run(async () =>
|
||||
try
|
||||
{
|
||||
try
|
||||
var ServerInstance = new IW4MServer(this, Conf);
|
||||
await ServerInstance.Initialize();
|
||||
|
||||
lock (_servers)
|
||||
{
|
||||
var ServerInstance = new IW4MServer(this, Conf);
|
||||
await ServerInstance.Initialize();
|
||||
|
||||
lock (_servers)
|
||||
{
|
||||
_servers.Add(ServerInstance);
|
||||
}
|
||||
|
||||
Logger.WriteVerbose($"Now monitoring {ServerInstance.Hostname}");
|
||||
|
||||
// this way we can keep track of execution time and see if problems arise.
|
||||
var Status = new AsyncStatus(ServerInstance, UPDATE_FREQUENCY);
|
||||
lock (TaskStatuses)
|
||||
{
|
||||
TaskStatuses.Add(Status);
|
||||
}
|
||||
_servers.Add(ServerInstance);
|
||||
}
|
||||
|
||||
catch (ServerException e)
|
||||
Logger.WriteVerbose($"Now monitoring {ServerInstance.Hostname}");
|
||||
|
||||
// this way we can keep track of execution time and see if problems arise.
|
||||
var Status = new AsyncStatus(ServerInstance, UPDATE_FREQUENCY);
|
||||
lock (TaskStatuses)
|
||||
{
|
||||
Logger.WriteError($"Not monitoring server {Conf.IP}:{Conf.Port} due to uncorrectable errors");
|
||||
if (e.GetType() == typeof(DvarException))
|
||||
Logger.WriteDebug($"Could not get the dvar value for {(e as DvarException).Data["dvar_name"]} (ensure the server has a map loaded)");
|
||||
else if (e.GetType() == typeof(NetworkException))
|
||||
{
|
||||
Logger.WriteDebug(e.Message);
|
||||
Logger.WriteDebug($"Internal Exception: {e.Data["internal_exception"]}");
|
||||
}
|
||||
TaskStatuses.Add(Status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
catch (ServerException e)
|
||||
{
|
||||
Logger.WriteError($"Not monitoring server {Conf.IP}:{Conf.Port} due to uncorrectable errors");
|
||||
if (e.GetType() == typeof(DvarException))
|
||||
Logger.WriteDebug($"Could not get the dvar value for {(e as DvarException).Data["dvar_name"]} (ensure the server has a map loaded)");
|
||||
else if (e.GetType() == typeof(NetworkException))
|
||||
{
|
||||
Logger.WriteDebug(e.Message);
|
||||
Logger.WriteDebug($"Internal Exception: {e.Data["internal_exception"]}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -9,13 +11,18 @@ namespace WebfrontCore.Application.Misc
|
||||
{
|
||||
public static async Task<bool> UsingVPN(string ip)
|
||||
{
|
||||
#if DEBUG
|
||||
return false;
|
||||
#endif
|
||||
try
|
||||
{
|
||||
using (var RequestClient = new System.Net.Http.HttpClient())
|
||||
{
|
||||
string response = await RequestClient.GetStringAsync($"http://check.getipintel.net/check.php?ip={ip}&contact=raidmax@live.com");
|
||||
double probability = Convert.ToDouble(response);
|
||||
return probability > 0.9;
|
||||
RequestClient.DefaultRequestHeaders.Add("X-Key", Startup.Configuration["VPN:APIKey"]);
|
||||
string response = await RequestClient.GetStringAsync($"http://v2.api.iphub.info/ip/{ip}");
|
||||
var responseJson = JsonConvert.DeserializeObject<JObject>(response);
|
||||
int blockType = Convert.ToInt32(responseJson["block"]);
|
||||
return blockType == 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ namespace IW4MAdmin
|
||||
if (existingAlias == null)
|
||||
{
|
||||
Logger.WriteDebug($"Client {polledPlayer} has connected previously under a different ip/name");
|
||||
client.CurrentAlias = new SharedLibrary.Database.Models.EFAlias()
|
||||
client.CurrentAlias = new EFAlias()
|
||||
{
|
||||
IPAddress = polledPlayer.IPAddress,
|
||||
Name = polledPlayer.Name,
|
||||
@ -143,7 +143,7 @@ namespace IW4MAdmin
|
||||
await ExecuteEvent(new Event(Event.GType.Connect, "", player, null, this));
|
||||
|
||||
|
||||
if (await VPNCheck.UsingVPN(player.IPAddressString))
|
||||
if (Config.AllowClientVpn && await VPNCheck.UsingVPN(player.IPAddressString))
|
||||
{
|
||||
await player.Kick("VPNs are not allowed on this server", new Player() { ClientId = 1 });
|
||||
}
|
||||
@ -288,10 +288,9 @@ namespace IW4MAdmin
|
||||
{
|
||||
E.Target = matchingPlayers.First();
|
||||
E.Data = Regex.Replace(E.Data, Regex.Escape($"\"{E.Target.Name}\""), "", RegexOptions.IgnoreCase).Trim();
|
||||
E.Data = Regex.Replace(E.Data, Regex.Escape($"{E.Target.Name}"), "", RegexOptions.IgnoreCase).Trim();
|
||||
|
||||
if ((E.Data.ToLower().Trim() == E.Target.Name.ToLower().Trim() ||
|
||||
E.Data == String.Empty) &&
|
||||
C.RequiresTarget)
|
||||
if (E.Data.Length == 0 && C.RequiredArgumentCount > 1)
|
||||
{
|
||||
await E.Origin.Tell($"Not enough arguments supplied!");
|
||||
await E.Origin.Tell(C.Syntax);
|
||||
@ -375,7 +374,7 @@ namespace IW4MAdmin
|
||||
#if DEBUG
|
||||
Logger.WriteInfo($"Polling players took {(DateTime.Now - now).TotalMilliseconds}ms");
|
||||
#endif
|
||||
|
||||
Throttled = false;
|
||||
for (int i = 0; i < Players.Count; i++)
|
||||
{
|
||||
if (CurrentPlayers.Find(p => p.ClientNumber == i) == null && Players[i] != null)
|
||||
@ -561,7 +560,20 @@ namespace IW4MAdmin
|
||||
|
||||
DVAR<int> onelog = null;
|
||||
if (GameName == Game.IW4)
|
||||
onelog = await this.GetDvarAsync<int>("iw4x_onelog");
|
||||
{
|
||||
try
|
||||
{
|
||||
onelog = await this.GetDvarAsync<int>("iw4x_onelog");
|
||||
}
|
||||
|
||||
catch (Exception)
|
||||
{
|
||||
onelog = new DVAR<int>("iw4x_onelog")
|
||||
{
|
||||
Value = -1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@ -580,8 +592,10 @@ namespace IW4MAdmin
|
||||
this.FSGame = game.Value;
|
||||
|
||||
await this.SetDvarAsync("sv_kickbantime", 60);
|
||||
await this.SetDvarAsync("sv_network_fps", 1000);
|
||||
await this.SetDvarAsync("com_maxfps", 1000);
|
||||
|
||||
// I don't think this belongs in an admin tool
|
||||
/*await this.SetDvarAsync("sv_network_fps", 1000);
|
||||
await this.SetDvarAsync("com_maxfps", 1000);*/
|
||||
|
||||
if (logsync.Value == 0 || logfile.Value == string.Empty)
|
||||
{
|
||||
@ -603,7 +617,7 @@ namespace IW4MAdmin
|
||||
}
|
||||
|
||||
#endif
|
||||
string mainPath = (GameName == Game.IW4) ? "userraw" : "main";
|
||||
string mainPath = (GameName == Game.IW4 && onelog.Value >=0) ? "userraw" : "main";
|
||||
|
||||
string logPath = (game.Value == "" || onelog?.Value == 1) ?
|
||||
$"{ basepath.Value.Replace("\\", "/")}/{mainPath}/{logfile.Value}" :
|
||||
@ -626,8 +640,8 @@ namespace IW4MAdmin
|
||||
//#endif
|
||||
Logger.WriteInfo($"Log file is {logPath}");
|
||||
#if !DEBUG
|
||||
await Broadcast("IW4M Admin is now ^2ONLINE");
|
||||
|
||||
await Broadcast("IW4M Admin is now ^2ONLINE");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ namespace IW4MAdmin
|
||||
string Password;
|
||||
bool AllowMultipleOwners;
|
||||
bool AllowTrustedRank;
|
||||
bool AntiCheat;
|
||||
bool AllowVpns;
|
||||
|
||||
while (IP == String.Empty)
|
||||
{
|
||||
@ -57,13 +59,23 @@ namespace IW4MAdmin
|
||||
Console.Write("Allow trusted rank? [y/n]: ");
|
||||
AllowTrustedRank = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y';
|
||||
|
||||
Console.Write("Allow server-side anti-cheat [y/n]: ");
|
||||
AntiCheat = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y';
|
||||
|
||||
Console.Write("Allow client VPNS [y/n]: ");
|
||||
AllowVpns = (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y';
|
||||
|
||||
var config = new ServerConfiguration()
|
||||
{
|
||||
IP = IP,
|
||||
Password = Password,
|
||||
Port = Port,
|
||||
AllowMultipleOwners = AllowMultipleOwners,
|
||||
AllowTrustedRank = AllowTrustedRank
|
||||
AllowTrustedRank = AllowTrustedRank,
|
||||
RestartPassword = "",
|
||||
RestartUsername = "",
|
||||
EnableAntiCheat = AntiCheat,
|
||||
AllowClientVpn = AllowVpns
|
||||
};
|
||||
|
||||
config.Write();
|
||||
|
Reference in New Issue
Block a user