mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
tweaked rcon throttle rate/made async
increased cutoff for server overview messages dont print message if timed out
This commit is contained in:
@ -25,7 +25,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
private List<Server> _servers;
|
||||
public List<Server> Servers => _servers.OrderByDescending(s => s.ClientNum).ToList();
|
||||
public Dictionary<int, int> PrivilegedClients { get; set; }
|
||||
public Dictionary<int, Player> PrivilegedClients { get; set; }
|
||||
public ILogger Logger { get; private set; }
|
||||
public bool Running { get; private set; }
|
||||
public EventHandler<Event> ServerEventOccurred { get; private set; }
|
||||
@ -54,7 +54,7 @@ namespace IW4MAdmin
|
||||
ClientSvc = new ClientService();
|
||||
AliasSvc = new AliasService();
|
||||
PenaltySvc = new PenaltyService();
|
||||
PrivilegedClients = new Dictionary<int, int>();
|
||||
PrivilegedClients = new Dictionary<int, Player>();
|
||||
ServerEventOccurred += EventAPI.OnServerEventOccurred;
|
||||
ConfigHandler = new BaseConfigurationHandler<ApplicationConfiguration>("IW4MAdminSettings");
|
||||
}
|
||||
@ -78,13 +78,17 @@ namespace IW4MAdmin
|
||||
{
|
||||
#region DATABASE
|
||||
var ipList = (await ClientSvc.Find(c => c.Level > Player.Permission.Trusted))
|
||||
.Select(c => new { c.IPAddress, c.ClientId });
|
||||
.Select(c => new { c.IPAddress, c.ClientId, c.Level });
|
||||
|
||||
foreach (var a in ipList)
|
||||
{
|
||||
try
|
||||
{
|
||||
PrivilegedClients.Add(a.IPAddress, a.ClientId);
|
||||
PrivilegedClients.Add(a.IPAddress, new Player()
|
||||
{
|
||||
ClientId = a.ClientId,
|
||||
Level = a.Level
|
||||
});
|
||||
}
|
||||
|
||||
catch (ArgumentException)
|
||||
@ -208,7 +212,7 @@ namespace IW4MAdmin
|
||||
Commands.Add(new CIP());
|
||||
Commands.Add(new CMask());
|
||||
Commands.Add(new CPruneAdmins());
|
||||
Commands.Add(new CRestartServer());
|
||||
Commands.Add(new CKillServer());
|
||||
|
||||
foreach (Command C in SharedLibrary.Plugins.PluginImporter.ActiveCommands)
|
||||
Commands.Add(C);
|
||||
@ -238,7 +242,7 @@ namespace IW4MAdmin
|
||||
else
|
||||
{
|
||||
Status.Update(new Task<bool>(() => { return (Status.Dependant as Server).ProcessUpdatesAsync(Status.GetToken()).Result; }));
|
||||
if (Status.RunAverage > 1000 + UPDATE_FREQUENCY)
|
||||
if (Status.RunAverage > 1000 + UPDATE_FREQUENCY && !(Status.Dependant as Server).Throttled)
|
||||
Logger.WriteWarning($"Update task average execution is longer than desired for {(Status.Dependant as Server)} [{Status.RunAverage}ms]");
|
||||
}
|
||||
}
|
||||
|
@ -4,18 +4,18 @@ using System.Threading;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using SharedLibrary;
|
||||
using SharedLibrary.Network;
|
||||
using SharedLibrary.Interfaces;
|
||||
using SharedLibrary.Objects;
|
||||
using System.Text.RegularExpressions;
|
||||
using SharedLibrary.Services;
|
||||
using SharedLibrary.Database.Models;
|
||||
using SharedLibrary.Dtos;
|
||||
using WebfrontCore.Application.Misc;
|
||||
using SharedLibrary.Configuration;
|
||||
|
||||
using WebfrontCore.Application.Misc;
|
||||
|
||||
namespace IW4MAdmin
|
||||
{
|
||||
public class IW4MServer : Server
|
||||
@ -386,7 +386,19 @@ namespace IW4MAdmin
|
||||
async Task<int> PollPlayersAsync()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var CurrentPlayers = await this.GetStatusAsync();
|
||||
|
||||
List<Player> CurrentPlayers = null;
|
||||
try
|
||||
{
|
||||
CurrentPlayers = await this.GetStatusAsync();
|
||||
}
|
||||
|
||||
// when the server has lost connection
|
||||
catch (SharedLibrary.Exceptions.NetworkException)
|
||||
{
|
||||
Throttled = true;
|
||||
return ClientNum;
|
||||
}
|
||||
#if DEBUG
|
||||
Logger.WriteInfo($"Polling players took {(DateTime.Now - now).TotalMilliseconds}ms");
|
||||
#endif
|
||||
@ -659,7 +671,7 @@ namespace IW4MAdmin
|
||||
//#else
|
||||
}
|
||||
#if DEBUG
|
||||
LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
|
||||
//LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
|
||||
#endif
|
||||
Logger.WriteInfo($"Log file is {logPath}");
|
||||
#if !DEBUG
|
||||
@ -776,16 +788,20 @@ namespace IW4MAdmin
|
||||
CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, Name = mapname };
|
||||
|
||||
// todo: make this more efficient
|
||||
((ApplicationManager)(Manager)).PrivilegedClients = new Dictionary<int, int>();
|
||||
((ApplicationManager)(Manager)).PrivilegedClients = new Dictionary<int, Player>();
|
||||
var ClientSvc = new ClientService();
|
||||
var ipList = (await ClientSvc.Find(c => c.Level > Player.Permission.Trusted))
|
||||
.Select(c => new { c.IPAddress, c.ClientId });
|
||||
.Select(c => new { c.IPAddress, c.ClientId, c.Level });
|
||||
|
||||
foreach (var a in ipList)
|
||||
{
|
||||
try
|
||||
{
|
||||
((ApplicationManager)(Manager)).PrivilegedClients.Add(a.IPAddress, a.ClientId);
|
||||
((ApplicationManager)(Manager)).PrivilegedClients.Add(a.IPAddress, new Player()
|
||||
{
|
||||
ClientId = a.ClientId,
|
||||
Level = a.Level
|
||||
});
|
||||
}
|
||||
|
||||
catch (ArgumentException)
|
||||
|
@ -24,7 +24,9 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
User.ClientId = Manager.PrivilegedClients[context.HttpContext.Connection.RemoteIpAddress.ToString().ConvertToIP()];
|
||||
var client = Manager.PrivilegedClients[context.HttpContext.Connection.RemoteIpAddress.ToString().ConvertToIP()];
|
||||
User.ClientId = client.ClientId;
|
||||
User.Level = client.Level;
|
||||
}
|
||||
|
||||
catch (KeyNotFoundException)
|
||||
@ -36,11 +38,16 @@ namespace WebfrontCore.Controllers
|
||||
User.ClientId >= 0;
|
||||
ViewBag.Authorized = Authorized;
|
||||
ViewBag.Url = Startup.Configuration["Web:Address"];
|
||||
string inviteLink = Manager.GetApplicationSettings().Configuration().DiscordInviteCode;
|
||||
if (inviteLink != null)
|
||||
ViewBag.DiscordLink = inviteLink.Contains("https") ? inviteLink : $"https://discordapp.com/invite/{inviteLink}";
|
||||
else
|
||||
ViewBag.DiscordLink = "";
|
||||
ViewBag.User = User;
|
||||
|
||||
if (Manager.GetApplicationSettings().Configuration().EnableDiscordLink)
|
||||
{
|
||||
string inviteLink = Manager.GetApplicationSettings().Configuration().DiscordInviteCode;
|
||||
if (inviteLink != null)
|
||||
ViewBag.DiscordLink = inviteLink.Contains("https") ? inviteLink : $"https://discordapp.com/invite/{inviteLink}";
|
||||
else
|
||||
ViewBag.DiscordLink = "";
|
||||
}
|
||||
base.OnActionExecuting(context);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
Name = client.Name,
|
||||
Level = client.Level.ToString(),
|
||||
LevelInt = (int)client.Level,
|
||||
ClientId = client.ClientId,
|
||||
IPAddress = client.IPAddressString,
|
||||
NetworkId = client.NetworkId,
|
||||
@ -54,6 +55,17 @@ namespace WebfrontCore.Controllers
|
||||
When = DateTime.MinValue
|
||||
});
|
||||
|
||||
if (Authorized)
|
||||
{
|
||||
clientDto.Meta.AddRange(client.AliasLink.Children.Select(a => new ProfileMeta()
|
||||
{
|
||||
Key = "AliasEvent",
|
||||
Value = $"Connected with name {a.Name}",
|
||||
Sensitive = true,
|
||||
When = a.DateAdded
|
||||
}));
|
||||
}
|
||||
|
||||
clientDto.Meta.AddRange(Authorized ? meta : meta.Where(m => !m.Sensitive));
|
||||
clientDto.Meta.AddRange(Authorized ? penaltyMeta : penaltyMeta.Where(m => !m.Sensitive));
|
||||
clientDto.Meta.AddRange(Authorized ? administeredPenaltiesMeta : administeredPenaltiesMeta.Where(m => !m.Sensitive));
|
||||
@ -105,6 +117,7 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
Name = c.Name,
|
||||
Level = c.Level.ToString(),
|
||||
LevelInt = (int)c.Level,
|
||||
ClientId = c.ClientId,
|
||||
LastSeen = Utilities.GetTimePassed(c.LastConnection, false)
|
||||
})
|
||||
|
@ -31,7 +31,8 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
Name = p.Name,
|
||||
ClientId = p.ClientId,
|
||||
Level = p.Level.ToString()
|
||||
Level = p.Level.ToString(),
|
||||
LevelInt = (int)p.Level
|
||||
}).ToList(),
|
||||
ChatHistory = s.ChatHistory.OrderBy(c => c.Time).Take((int)Math.Ceiling(s.ClientNum / 2.0)).ToArray(),
|
||||
PlayerHistory = s.PlayerHistory.ToArray()
|
||||
|
@ -27,7 +27,8 @@ namespace WebfrontCore.ViewComponents
|
||||
{
|
||||
Name = p.Name,
|
||||
ClientId = p.ClientId,
|
||||
Level = p.Level.ToString()
|
||||
Level = p.Level.ToString(),
|
||||
LevelInt = (int)p.Level
|
||||
}).ToList(),
|
||||
ChatHistory = s.ChatHistory.ToArray()
|
||||
}).ToList();
|
||||
|
@ -2,7 +2,6 @@
|
||||
@{
|
||||
string match = System.Text.RegularExpressions.Regex.Match(Model.Name.ToUpper(), "[A-Z]").Value;
|
||||
string shortCode = match == string.Empty ? "?" : match;
|
||||
string marginClass = Model.Aliases.Count > 0 ? "mr-4" : "";
|
||||
}
|
||||
<div id="profile_wrapper" class="row d-flex d-sm-inline-flex justify-content-center justify-content-left pb-3">
|
||||
<div class="mr-auto ml-auto ml-sm-0 mr-sm-0">
|
||||
@ -12,49 +11,46 @@
|
||||
</div>
|
||||
<div id="profile_info" class="text-center text-sm-left pr-3 pl-3">
|
||||
<div id="profile_name">
|
||||
<h1>
|
||||
<span class="client-name @marginClass">
|
||||
@Model.Name
|
||||
@if (Model.Aliases.Count > 0 || ViewBag.Authorized)
|
||||
{
|
||||
<span id="profile_aliases_btn" class="oi oi-caret-bottom pl-2"></span>
|
||||
}
|
||||
|
||||
@{
|
||||
if (ViewBag.Authorized)
|
||||
{
|
||||
if (Model.Level == SharedLibrary.Objects.Player.Permission.User.ToString())
|
||||
{
|
||||
|
||||
<span id="profile_action_ban_btn" class="profile-action oi oi-ban text-danger" title="Ban Client" data-action="ban" aria-hidden="true"></span>
|
||||
}
|
||||
|
||||
if (Model.Level == SharedLibrary.Objects.Player.Permission.Banned.ToString())
|
||||
{
|
||||
<span id="profile_action_unban_btn" class="profile-action oi oi-action-undo text-success" title="carriage return" data-action="unban" aria-hidden="true"></span>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</span>
|
||||
</h1>
|
||||
<div id="profile_aliases" class="pr-0 pr-sm-4 pb-2 mb-2 text-muted">
|
||||
@{
|
||||
foreach (string alias in Model.Aliases)
|
||||
{
|
||||
@alias <br />
|
||||
}
|
||||
|
||||
if (ViewBag.Authorized)
|
||||
{
|
||||
foreach (string ip in Model.IPs)
|
||||
{
|
||||
<a class="ip-locate-link" href="#" data-ip="@ip">@ip</a><br />
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
<div class="client-name h1 d-flex d-inline-flex">
|
||||
@Model.Name
|
||||
</div>
|
||||
@{
|
||||
if (ViewBag.Authorized)
|
||||
{
|
||||
<div class="d-flex d-md-inline-flex justify-content-center order-1">
|
||||
<div id="profile_aliases_btn" class="oi oi-caret-bottom h3 ml-0 ml-md-2"></div>
|
||||
|
||||
@if (Model.LevelInt < (int)ViewBag.User.Level &&
|
||||
(SharedLibrary.Objects.Player.Permission)Model.LevelInt != SharedLibrary.Objects.Player.Permission.Banned)
|
||||
{
|
||||
<div id="profile_action_ban_btn" class="profile-action oi oi-ban text-danger h3 ml-2" title="Ban Client" data-action="ban" aria-hidden="true"></div>
|
||||
}
|
||||
|
||||
@if (Model.LevelInt < (int)ViewBag.User.Level &&
|
||||
(SharedLibrary.Objects.Player.Permission)Model.LevelInt == SharedLibrary.Objects.Player.Permission.Banned)
|
||||
{
|
||||
<div id="profile_action_unban_btn" class="profile-action oi oi-action-undo text-success h3 ml-2" title="Unban Client" data-action="unban" aria-hidden="true"></div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div id="profile_aliases" class="pr-0 pr-sm-4 pb-2 mb-2 text-muted order-0">
|
||||
@{
|
||||
foreach (string alias in Model.Aliases)
|
||||
{
|
||||
@alias <br />
|
||||
}
|
||||
|
||||
if (ViewBag.Authorized)
|
||||
{
|
||||
foreach (string ip in Model.IPs)
|
||||
{
|
||||
<a class="ip-locate-link" href="#" data-ip="@ip">@ip</a><br />
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div id="profile_level" class="text-muted mb-2">
|
||||
<h5><span class="level-color-@Model.Level.ToLower()"><strong>@Model.Level</strong></span></h5>
|
||||
|
@ -20,7 +20,7 @@
|
||||
}
|
||||
if (Model.ChatHistory[i].Message != "CONNECTED" && Model.ChatHistory[i].Message != "DISCONNECTED")
|
||||
{
|
||||
<span class="text-light">@Model.ChatHistory[i].Name</span><span> — @message.Substring(0, Math.Min(50, message.Length)) </span><br />
|
||||
<span class="text-light">@Model.ChatHistory[i].Name</span><span> — @message.Substring(0, Math.Min(65, message.Length)) </span><br />
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,9 +96,6 @@
|
||||
}
|
||||
|
||||
#profile_aliases_btn {
|
||||
position: relative;
|
||||
top: -2px;
|
||||
font-size: 0.5em;
|
||||
color: rgb(0, 122, 204);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ $(document).ready(function () {
|
||||
const aliases = $('#profile_aliases').text().trim();
|
||||
if (aliases && aliases.length !== 0) {
|
||||
$('#profile_aliases').slideToggle(150);
|
||||
$(this).toggleClass('oi-caret-top');
|
||||
}
|
||||
});
|
||||
|
||||
@ -177,6 +178,9 @@ function loadMeta(meta) {
|
||||
eventString = `<div><span class="penalties-color-${meta.value.type.toLowerCase()}">${penaltyToName(meta.value.type)} </span> <span class="text-highlight"><a class="link-inverse" href="${meta.value.offenderId}"> ${meta.value.offenderName}</a></span > for <span style="color: white; ">${meta.value.offense}</span></div>`;
|
||||
}
|
||||
}
|
||||
else if (meta.key.includes("Alias")) {
|
||||
eventString = `<div><span class="text-primary">${meta.value}</span></div>`;
|
||||
}
|
||||
// it's a message
|
||||
else if (meta.key.includes("Event")) {
|
||||
eventString = `<div><span style="color:white;">></span><span class="text-muted"> ${meta.value}</span></div>`;
|
||||
|
Reference in New Issue
Block a user