diff --git a/Plugins/ScriptPlugins/ParserCoD4x.js b/Plugins/ScriptPlugins/ParserCoD4x.js index 813962c72..d4fbf0747 100644 --- a/Plugins/ScriptPlugins/ParserCoD4x.js +++ b/Plugins/ScriptPlugins/ParserCoD4x.js @@ -15,7 +15,7 @@ var plugin = { eventParser = manager.GenerateDynamicEventParser(this.name); rconParser.Configuration.StatusHeader.Pattern = 'num +score +ping +playerid +steamid +name +lastmsg +address +qport +rate *'; - rconParser.Configuration.Status.Pattern = '^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){16,32}|(?:[a-z]|[0-9]){32}|bot[0-9]+) ([0-9+]) *(.{0,32}) +([0-9]+) +(\\d+\\.\\d+\\.\\d+.\\d+\\:-*\\d{1,5}|0+.0+:-*\\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$' + rconParser.Configuration.Status.Pattern = '^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]{16,32})|bot[0-9]+) ([0-9]+) +(.{0,32}) +([0-9]+) +(\\d+\\.\\d+\\.\\d+.\\d+\\:-*\\d{1,5}|0+.0+:-*\\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$'; rconParser.Configuration.Status.AddMapping(104, 6); // RConName rconParser.Configuration.Status.AddMapping(105, 8); // RConIPAddress diff --git a/WebfrontCore/Controllers/ActionController.cs b/WebfrontCore/Controllers/ActionController.cs index 533473b33..9d70d3e2a 100644 --- a/WebfrontCore/Controllers/ActionController.cs +++ b/WebfrontCore/Controllers/ActionController.cs @@ -329,5 +329,48 @@ namespace WebfrontCore.Controllers command = $"!unflag @{targetId} {reason}" })); } + + public IActionResult KickForm(int id) + { + var info = new ActionInfo() + { + ActionButtonLabel = Localization["WEBFRONT_ACTION_KICK_NAME"], + Name = "Kick", + Inputs = new List() + { + new InputInfo() + { + Name = "reason", + Label = Localization["WEBFRONT_ACTION_LABEL_REASON"], + }, + new InputInfo() + { + Name = "targetId", + Type = "hidden", + Value = id.ToString() + } + }, + Action = "KickAsync", + ShouldRefresh = true + }; + + return View("_ActionForm", info); + } + + public async Task KickAsync(int targetId, string reason) + { + var client = Manager.GetActiveClients().FirstOrDefault(_client => _client.ClientId == targetId); + + if (client == null) + { + return BadRequest(Localization["WEBFRONT_ACTION_KICK_DISCONNECT"]); + } + + return await Task.FromResult(RedirectToAction("ExecuteAsync", "Console", new + { + serverId = client.CurrentServer.EndPoint, + command = $"!kick {client.ClientNumber} {reason}" + })); + } } } diff --git a/WebfrontCore/Controllers/ConsoleController.cs b/WebfrontCore/Controllers/ConsoleController.cs index 15547ef35..50b6c08eb 100644 --- a/WebfrontCore/Controllers/ConsoleController.cs +++ b/WebfrontCore/Controllers/ConsoleController.cs @@ -57,26 +57,16 @@ namespace WebfrontCore.Controllers }; Manager.AddEvent(remoteEvent); - List response = null; + CommandResponseInfo[] response = null; try { - var completedEvent = await remoteEvent.WaitAsync(Utilities.DefaultCommandTimeout, server.Manager.CancellationToken); // wait for the event to process - if (!completedEvent.Failed) + var completedEvent = await remoteEvent.WaitAsync(Utilities.DefaultCommandTimeout, server.Manager.CancellationToken); + + if (completedEvent.FailReason == GameEvent.EventFailReason.Timeout) { - response = server.CommandResult.Where(c => c.ClientId == client.ClientId).ToList(); - - // remove the added command response - for (int i = 0; i < response.Count; i++) - { - server.CommandResult.Remove(response[i]); - } - } - - else if (completedEvent.FailReason == GameEvent.EventFailReason.Timeout) - { - response = new List() + response = new[] { new CommandResponseInfo() { @@ -85,11 +75,22 @@ namespace WebfrontCore.Controllers } }; } + + else + { + response = response = server.CommandResult.Where(c => c.ClientId == client.ClientId).ToArray(); + } + + // remove the added command response + for (int i = 0; i < response?.Length; i++) + { + server.CommandResult.Remove(response[i]); + } } catch (System.OperationCanceledException) { - response = new List() + response = new[] { new CommandResponseInfo() { diff --git a/WebfrontCore/Views/Console/_Response.cshtml b/WebfrontCore/Views/Console/_Response.cshtml index 639a37687..884be7697 100644 --- a/WebfrontCore/Views/Console/_Response.cshtml +++ b/WebfrontCore/Views/Console/_Response.cshtml @@ -1,4 +1,4 @@ -@model List +@model IEnumerable @{ Layout = null; } diff --git a/WebfrontCore/Views/Server/_ClientActivity.cshtml b/WebfrontCore/Views/Server/_ClientActivity.cshtml index 1536d1d5f..b63196e71 100644 --- a/WebfrontCore/Views/Server/_ClientActivity.cshtml +++ b/WebfrontCore/Views/Server/_ClientActivity.cshtml @@ -52,10 +52,19 @@ { continue; } + + if (ViewBag.Authorized) + { + + } string levelColorClass = !ViewBag.Authorized ? "" : $"level-color-{Model.Players[i].LevelInt}"; + if (ViewBag.Authorized) + { + + }
} } @@ -68,10 +77,15 @@ { continue; } + string levelColorClass = !ViewBag.Authorized ? "" : $"level-color-{Model.Players[i].LevelInt}"; + if (ViewBag.Authorized) + { + + }
} } @@ -112,8 +126,9 @@ - — - + + — +
} } diff --git a/WebfrontCore/wwwroot/js/action.js b/WebfrontCore/wwwroot/js/action.js index d0061e95a..6e05163a7 100644 --- a/WebfrontCore/wwwroot/js/action.js +++ b/WebfrontCore/wwwroot/js/action.js @@ -30,7 +30,8 @@ $(document).ready(function () { /* * handle action modal */ - $('.profile-action').click(function (e) { + $(document).off('click', '.profile-action'); + $(document).on('click', '.profile-action', function (e) { const actionType = $(this).data('action'); const actionId = $(this).data('action-id'); const actionIdKey = actionId === undefined ? '' : '?id=' + actionId; @@ -43,7 +44,7 @@ $(document).ready(function () { }) .fail(function (jqxhr, textStatus, error) { $('#actionModal .modal-body-content').html(''); - $('#actionModal .modal-message').text('Error — ' + error); + $('#actionModal .modal-message').text(_localization['GLOBAL_ERROR'] + ' — ' + jqxhr.responseText); $('#actionModal').modal(); $('#actionModal .modal-message').fadeIn('fast'); }); @@ -78,10 +79,10 @@ $(document).ready(function () { $('#actionModal .modal-message').fadeOut('fast'); } if (jqxhr.status === 401) { - $('#actionModal .modal-message').text('Invalid login credentials'); + $('#actionModal .modal-message').text(_localization['WEBFRONT_ACTION_CREDENTIALS']); } else { - $('#actionModal .modal-message').text('Error — ' + error); + $('#actionModal .modal-message').text(_localization['GLOBAL_ERROR'] + ' — ' + jqxhr.responseText); } $('#actionModal .modal-message').fadeIn('fast'); });