diff --git a/Application/Application.csproj b/Application/Application.csproj
index b19b95ee..80fd7921 100644
--- a/Application/Application.csproj
+++ b/Application/Application.csproj
@@ -6,7 +6,7 @@
2.1.5
false
RaidMax.IW4MAdmin.Application
- 2.2
+ 2.2.1.0
RaidMax
Forever None
IW4MAdmin
@@ -31,8 +31,8 @@
true
true
- 2.2.0.0
- 2.2.0.0
+ 2.2.1.0
+ 2.2.1.0
diff --git a/Application/Main.cs b/Application/Main.cs
index 701a67cb..6ea5b216 100644
--- a/Application/Main.cs
+++ b/Application/Main.cs
@@ -39,6 +39,8 @@ namespace IW4MAdmin.Application
try
{
+ ServerManager = ApplicationManager.GetInstance();
+ Localization.Configure.Initialize(ServerManager.GetApplicationSettings().Configuration()?.CustomLocale);
loc = Utilities.CurrentLocalization.LocalizationIndex;
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey);
@@ -47,10 +49,6 @@ namespace IW4MAdmin.Application
// todo: move out
ConfigurationMigration.MoveConfigFolder10518(null);
- ServerManager = ApplicationManager.GetInstance();
- Localization.Configure.Initialize(ServerManager.GetApplicationSettings().Configuration()?.CustomLocale);
-
-
ServerManager.Logger.WriteInfo($"Version is {Version}");
var api = API.Master.Endpoint.Get();
diff --git a/Application/Server.cs b/Application/Server.cs
index 2c66df61..facabb9c 100644
--- a/Application/Server.cs
+++ b/Application/Server.cs
@@ -54,7 +54,7 @@ namespace IW4MAdmin
else
{
- int id = HashCode.Combine(IP, Port);
+ int id = HashCode.Combine(IP, Port);
return id < 0 ? Math.Abs(id) : id;
}
}
@@ -589,7 +589,11 @@ namespace IW4MAdmin
var now = DateTime.Now;
#endif
var currentClients = GetPlayersAsList();
- var polledClients = await this.GetStatusAsync();
+ var polledClients = (await this.GetStatusAsync()).AsEnumerable();
+ if (this.Manager.GetApplicationSettings().Configuration().IgnoreBots)
+ {
+ polledClients = polledClients.Where(c => !c.IsBot);
+ }
#if DEBUG
Logger.WriteInfo($"Polling players took {(DateTime.Now - now).TotalMilliseconds}ms");
#endif
@@ -855,7 +859,7 @@ namespace IW4MAdmin
CustomCallback = await ScriptLoaded();
string mainPath = EventParser.GetGameDir();
#if DEBUG
- // basepath.Value = @"D:\";
+ // basepath.Value = @"D:\";
#endif
string logPath = string.Empty;
diff --git a/Plugins/Login/Plugin.cs b/Plugins/Login/Plugin.cs
index e28a3f7b..738a74d7 100644
--- a/Plugins/Login/Plugin.cs
+++ b/Plugins/Login/Plugin.cs
@@ -28,6 +28,7 @@ namespace IW4MAdmin.Plugins.Login
if (E.Type == GameEvent.EventType.Connect)
{
AuthorizedClients.TryAdd(E.Origin.ClientId, false);
+ E.Origin.SetAdditionalProperty("IsLoggedIn", false);
}
if (E.Type == GameEvent.EventType.Disconnect)
@@ -51,7 +52,14 @@ namespace IW4MAdmin.Plugins.Login
return Task.CompletedTask;
if (!AuthorizedClients[E.Origin.ClientId])
+ {
throw new AuthorizationException(Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_LOGIN_AUTH"]);
+ }
+
+ else
+ {
+ E.Origin.SetAdditionalProperty("IsLoggedIn", true);
+ }
}
return Task.CompletedTask;
diff --git a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs
index 5124995e..94b65566 100644
--- a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs
+++ b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs
@@ -21,6 +21,7 @@ namespace SharedLibraryCore.Configuration
public string DatabaseProvider { get; set; } = "sqlite";
public string ConnectionString { get; set; }
public int RConPollRate { get; set; } = 5000;
+ public bool IgnoreBots { get; set; }
public string Id { get; set; }
public List Servers { get; set; }
public int AutoMessagePeriod { get; set; }
diff --git a/SharedLibraryCore/Objects/Player.cs b/SharedLibraryCore/Objects/Player.cs
index 95580392..5e4a10c0 100644
--- a/SharedLibraryCore/Objects/Player.cs
+++ b/SharedLibraryCore/Objects/Player.cs
@@ -402,7 +402,9 @@ namespace SharedLibraryCore.Objects
[NotMapped]
Dictionary _additionalProperties;
- public T GetAdditionalProperty(string name) => (T)_additionalProperties[name];
+
+ public T GetAdditionalProperty(string name) => _additionalProperties.ContainsKey(name) ? (T)_additionalProperties[name] : default(T);
+
public void SetAdditionalProperty(string name, object value)
{
if (_additionalProperties.ContainsKey(name))
diff --git a/WebfrontCore/Controllers/API/GscApiController.cs b/WebfrontCore/Controllers/API/GscApiController.cs
new file mode 100644
index 00000000..e5fd07b7
--- /dev/null
+++ b/WebfrontCore/Controllers/API/GscApiController.cs
@@ -0,0 +1,36 @@
+using Microsoft.AspNetCore.Mvc;
+using SharedLibraryCore;
+using SharedLibraryCore.Objects;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WebfrontCore.Controllers.API
+{
+ [Route("api/gsc/[action]")]
+ public class GscApiController : ApiController
+ {
+ [HttpGet("{networkId}")]
+ public IActionResult ClientInfo(string networkId)
+ {
+ var clientInfo = Manager.GetActiveClients()
+ .FirstOrDefault(c => c.NetworkId == networkId.ConvertLong());
+
+ if (clientInfo != null)
+ {
+ var sb = new StringBuilder();
+ sb.AppendLine($"admin={clientInfo.IsPrivileged()}");
+ sb.AppendLine($"level={(int)clientInfo.Level}");
+ sb.AppendLine($"levelstring={clientInfo.Level.ToLocalizedLevelName()}");
+ sb.AppendLine($"connections={clientInfo.Connections}");
+ sb.AppendLine($"authenticated={clientInfo.GetAdditionalProperty("IsLoggedIn") == true}");
+
+ return Content(sb.ToString());
+ }
+
+ return Content("");
+ }
+ }
+}