mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 07:13:58 -05:00
fixed issue with status response erroring when incorrect length
view angle vector parse fail is now a handled exception change local host check to byte array to make it faster than comparing string kick command now requires moderator level or higher tempban now requires administrator level or higher hopefully fixed negative SPM bug pipelined the events and consolidated them to run through GameEventHandler uniform console colors
This commit is contained in:
@ -16,24 +16,37 @@ namespace WebfrontCore.Controllers
|
||||
protected IManager Manager;
|
||||
protected readonly DatabaseContext Context;
|
||||
protected bool Authorized { get; private set; }
|
||||
protected EFClient User { get; private set; }
|
||||
protected EFClient Client { get; private set; }
|
||||
private static byte[] LocalHost = { 127, 0, 0, 1 };
|
||||
private static string DiscordLink;
|
||||
|
||||
public BaseController()
|
||||
{
|
||||
var Manager = Program.Manager;
|
||||
if (Manager.GetApplicationSettings().Configuration().EnableDiscordLink)
|
||||
{
|
||||
string inviteLink = Manager.GetApplicationSettings().Configuration().DiscordInviteCode;
|
||||
if (inviteLink != null)
|
||||
DiscordLink = inviteLink.Contains("https") ? inviteLink : $"https://discordapp.com/invite/{inviteLink}";
|
||||
else
|
||||
DiscordLink = "";
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
Manager = Program.Manager;
|
||||
|
||||
User = User ?? new EFClient()
|
||||
Client = Client ?? new EFClient()
|
||||
{
|
||||
ClientId = -1
|
||||
};
|
||||
|
||||
if (HttpContext.Connection.RemoteIpAddress.ToString() != "127.0.0.1")
|
||||
if (!HttpContext.Connection.RemoteIpAddress.GetAddressBytes().SequenceEqual(LocalHost))
|
||||
{
|
||||
try
|
||||
{
|
||||
User.ClientId = Convert.ToInt32(base.User.Claims.First(c => c.Type == ClaimTypes.Sid).Value);
|
||||
User.Level = (Player.Permission)Enum.Parse(typeof(Player.Permission), base.User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
|
||||
User.CurrentAlias = new EFAlias() { Name = base.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
|
||||
Client.ClientId = Convert.ToInt32(base.User.Claims.First(c => c.Type == ClaimTypes.Sid).Value);
|
||||
Client.Level = (Player.Permission)Enum.Parse(typeof(Player.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
|
||||
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
|
||||
}
|
||||
|
||||
catch (InvalidOperationException)
|
||||
@ -44,24 +57,17 @@ namespace WebfrontCore.Controllers
|
||||
|
||||
else
|
||||
{
|
||||
User.ClientId = 1;
|
||||
User.Level = Player.Permission.Console;
|
||||
User.CurrentAlias = new EFAlias() { Name = "IW4MAdmin" };
|
||||
Client.ClientId = 1;
|
||||
Client.Level = Player.Permission.Console;
|
||||
Client.CurrentAlias = new EFAlias() { Name = "IW4MAdmin" };
|
||||
}
|
||||
|
||||
Authorized = User.ClientId >= 0;
|
||||
Authorized = Client.ClientId >= 0;
|
||||
ViewBag.Authorized = Authorized;
|
||||
ViewBag.Url = Startup.Configuration["Web:Address"];
|
||||
ViewBag.User = User;
|
||||
ViewBag.User = Client;
|
||||
ViewBag.DiscordLink = DiscordLink;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,10 @@ namespace WebfrontCore.Controllers
|
||||
var server = Manager.GetServers().First(s => s.GetHashCode() == serverId);
|
||||
var client = new Player()
|
||||
{
|
||||
ClientId = User.ClientId,
|
||||
Level = User.Level,
|
||||
ClientId = Client.ClientId,
|
||||
Level = Client.Level,
|
||||
CurrentServer = server,
|
||||
CurrentAlias = new Alias() { Name = User.Name }
|
||||
CurrentAlias = new Alias() { Name = Client.Name }
|
||||
};
|
||||
var remoteEvent = new GameEvent()
|
||||
{
|
||||
@ -46,8 +46,9 @@ namespace WebfrontCore.Controllers
|
||||
Remote = true
|
||||
};
|
||||
|
||||
await server.ExecuteEvent(remoteEvent);
|
||||
|
||||
Manager.GetEventHandler().AddEvent(remoteEvent);
|
||||
// wait for the event to process
|
||||
remoteEvent.OnProcessed.Wait();
|
||||
var response = server.CommandResult.Where(c => c.ClientId == client.ClientId).ToList();
|
||||
|
||||
// remove the added command response
|
||||
|
Reference in New Issue
Block a user