fix duplicate bot welcomes
fix prompt bool incorrect default value rename GameEvent.Remote to GameEvent.IsRemote include NetworkId in webfront claims fix non descript error message appearing when something fails and localization is not initialized
This commit is contained in:
parent
aaf9eb09b6
commit
08c883e0ff
@ -6,7 +6,7 @@
|
|||||||
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
|
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
|
||||||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
||||||
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
||||||
<Version>2.2.3.1</Version>
|
<Version>2.2.3.2</Version>
|
||||||
<Authors>RaidMax</Authors>
|
<Authors>RaidMax</Authors>
|
||||||
<Company>Forever None</Company>
|
<Company>Forever None</Company>
|
||||||
<Product>IW4MAdmin</Product>
|
<Product>IW4MAdmin</Product>
|
||||||
@ -31,8 +31,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
<TieredCompilation>true</TieredCompilation>
|
<TieredCompilation>true</TieredCompilation>
|
||||||
<AssemblyVersion>2.2.3.1</AssemblyVersion>
|
<AssemblyVersion>2.2.3.2</AssemblyVersion>
|
||||||
<FileVersion>2.2.3.1</FileVersion>
|
<FileVersion>2.2.3.2</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -449,7 +449,7 @@ namespace IW4MAdmin
|
|||||||
client.Score = origin.Score;
|
client.Score = origin.Score;
|
||||||
|
|
||||||
// update their IP if it hasn't been set yet
|
// update their IP if it hasn't been set yet
|
||||||
if (client.IPAddress == null)
|
if (client.IPAddress == null && !client.IsBot)
|
||||||
{
|
{
|
||||||
return client.OnJoin(origin.IPAddress);
|
return client.OnJoin(origin.IPAddress);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace IW4MAdmin.Application.Localization
|
|||||||
{
|
{
|
||||||
public class Configure
|
public class Configure
|
||||||
{
|
{
|
||||||
public static void Initialize(string customLocale)
|
public static void Initialize(string customLocale = null)
|
||||||
{
|
{
|
||||||
string currentLocale = string.IsNullOrEmpty(customLocale) ? CultureInfo.CurrentCulture.Name : customLocale;
|
string currentLocale = string.IsNullOrEmpty(customLocale) ? CultureInfo.CurrentCulture.Name : customLocale;
|
||||||
string[] localizationFiles = Directory.GetFiles(Path.Join(Utilities.OperatingDirectory, "Localization"), $"*.{currentLocale}.json");
|
string[] localizationFiles = Directory.GetFiles(Path.Join(Utilities.OperatingDirectory, "Localization"), $"*.{currentLocale}.json");
|
||||||
|
@ -10,6 +10,7 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using SharedLibraryCore.Localization;
|
using SharedLibraryCore.Localization;
|
||||||
using IW4MAdmin.Application.Migration;
|
using IW4MAdmin.Application.Migration;
|
||||||
|
using SharedLibraryCore.Exceptions;
|
||||||
|
|
||||||
namespace IW4MAdmin.Application
|
namespace IW4MAdmin.Application
|
||||||
{
|
{
|
||||||
@ -38,7 +39,15 @@ namespace IW4MAdmin.Application
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerManager = ApplicationManager.GetInstance();
|
ServerManager = ApplicationManager.GetInstance();
|
||||||
Localization.Configure.Initialize(ServerManager.GetApplicationSettings().Configuration()?.CustomLocale);
|
try
|
||||||
|
{
|
||||||
|
Localization.Configure.Initialize(ServerManager.GetApplicationSettings().Configuration().CustomLocale);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (ServerException)
|
||||||
|
{
|
||||||
|
Localization.Configure.Initialize();
|
||||||
|
}
|
||||||
loc = Utilities.CurrentLocalization.LocalizationIndex;
|
loc = Utilities.CurrentLocalization.LocalizationIndex;
|
||||||
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey);
|
Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCancelKey);
|
||||||
|
|
||||||
@ -107,7 +116,7 @@ namespace IW4MAdmin.Application
|
|||||||
|
|
||||||
var consoleTask = Task.Run(async () =>
|
var consoleTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
String userInput;
|
string userInput;
|
||||||
var Origin = Utilities.IW4MAdminClient(ServerManager.Servers[0]);
|
var Origin = Utilities.IW4MAdminClient(ServerManager.Servers[0]);
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -144,13 +153,16 @@ namespace IW4MAdmin.Application
|
|||||||
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(loc["MANAGER_INIT_FAIL"]);
|
string failMessage = loc == null ? "Failed to initalize IW4MAdmin" : loc["MANAGER_INIT_FAIL"];
|
||||||
|
string exitMessage = loc == null ? "Press any key to exit..." : loc["MANAGER_EXIT"];
|
||||||
|
|
||||||
|
Console.WriteLine(failMessage);
|
||||||
while (e.InnerException != null)
|
while (e.InnerException != null)
|
||||||
{
|
{
|
||||||
e = e.InnerException;
|
e = e.InnerException;
|
||||||
}
|
}
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
Console.WriteLine(loc["MANAGER_EXIT"]);
|
Console.WriteLine(exitMessage);
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,8 @@ namespace IW4MAdmin.Application
|
|||||||
Running = true;
|
Running = true;
|
||||||
|
|
||||||
#region DATABASE
|
#region DATABASE
|
||||||
using (var db = new DatabaseContext(GetApplicationSettings().Configuration()?.ConnectionString, GetApplicationSettings().Configuration()?.DatabaseProvider))
|
using (var db = new DatabaseContext(GetApplicationSettings().Configuration()?.ConnectionString,
|
||||||
|
GetApplicationSettings().Configuration()?.DatabaseProvider))
|
||||||
{
|
{
|
||||||
await new ContextSeed(db).Seed();
|
await new ContextSeed(db).Seed();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ using SharedLibraryCore.Configuration;
|
|||||||
using SharedLibraryCore.Database.Models;
|
using SharedLibraryCore.Database.Models;
|
||||||
using SharedLibraryCore.Exceptions;
|
using SharedLibraryCore.Exceptions;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using SharedLibraryCore.Objects;
|
|
||||||
|
|
||||||
namespace IW4MAdmin.Plugins.Login
|
namespace IW4MAdmin.Plugins.Login
|
||||||
{
|
{
|
||||||
@ -23,7 +22,7 @@ namespace IW4MAdmin.Plugins.Login
|
|||||||
|
|
||||||
public Task OnEventAsync(GameEvent E, Server S)
|
public Task OnEventAsync(GameEvent E, Server S)
|
||||||
{
|
{
|
||||||
if (E.Remote || Config.RequirePrivilegedClientLogin == false)
|
if (E.IsRemote || Config.RequirePrivilegedClientLogin == false)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
if (E.Type == GameEvent.EventType.Connect)
|
if (E.Type == GameEvent.EventType.Connect)
|
||||||
|
@ -188,7 +188,7 @@ namespace SharedLibraryCore
|
|||||||
public EFClient Origin;
|
public EFClient Origin;
|
||||||
public EFClient Target;
|
public EFClient Target;
|
||||||
public Server Owner;
|
public Server Owner;
|
||||||
public Boolean Remote = false;
|
public bool IsRemote { get; set; } = false;
|
||||||
public object Extra { get; set; }
|
public object Extra { get; set; }
|
||||||
public ManualResetEventSlim OnProcessed { get; set; }
|
public ManualResetEventSlim OnProcessed { get; set; }
|
||||||
public DateTime Time { get; set; }
|
public DateTime Time { get; set; }
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using SharedLibraryCore.Exceptions;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -40,7 +41,7 @@ namespace SharedLibraryCore.Configuration
|
|||||||
return File.WriteAllTextAsync(Path.Join(Utilities.OperatingDirectory, "Configuration", $"{Filename}.json"), appConfigJSON);
|
return File.WriteAllTextAsync(Path.Join(Utilities.OperatingDirectory, "Configuration", $"{Filename}.json"), appConfigJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Configuration() => _configuration;
|
public T Configuration() => _configuration == null ? throw new ServerException("Configuration is null") : _configuration;
|
||||||
|
|
||||||
public void Set(T config)
|
public void Set(T config)
|
||||||
{
|
{
|
||||||
|
@ -53,13 +53,6 @@ namespace SharedLibraryCore.Services
|
|||||||
private async Task UpdateAlias(string name, int? ip, EFClient entity, DatabaseContext context)
|
private async Task UpdateAlias(string name, int? ip, EFClient entity, DatabaseContext context)
|
||||||
{
|
{
|
||||||
// entity is the tracked db context item
|
// entity is the tracked db context item
|
||||||
// todo: move this out
|
|
||||||
#if DEBUG == false
|
|
||||||
if (entity.IsBot)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// get all aliases by IP address and LinkId
|
// get all aliases by IP address and LinkId
|
||||||
var iqAliases = context.Aliases
|
var iqAliases = context.Aliases
|
||||||
.Include(a => a.Link)
|
.Include(a => a.Link)
|
||||||
@ -377,7 +370,8 @@ namespace SharedLibraryCore.Services
|
|||||||
ClientId = client.ClientId,
|
ClientId = client.ClientId,
|
||||||
Level = client.Level,
|
Level = client.Level,
|
||||||
Password = client.Password,
|
Password = client.Password,
|
||||||
PasswordSalt = client.PasswordSalt
|
PasswordSalt = client.PasswordSalt,
|
||||||
|
NetworkId = client.NetworkId
|
||||||
};
|
};
|
||||||
|
|
||||||
#if DEBUG == true
|
#if DEBUG == true
|
||||||
|
@ -212,7 +212,7 @@ namespace SharedLibraryCore
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input">Shorthand gametype reported from server</param>
|
/// <param name="input">Shorthand gametype reported from server</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static String GetLocalizedGametype(String input)
|
public static string GetLocalizedGametype(String input)
|
||||||
{
|
{
|
||||||
switch (input)
|
switch (input)
|
||||||
{
|
{
|
||||||
@ -294,12 +294,12 @@ namespace SharedLibraryCore
|
|||||||
return !ip.HasValue ? "" : new System.Net.IPAddress(BitConverter.GetBytes(ip.Value)).ToString();
|
return !ip.HasValue ? "" : new System.Net.IPAddress(BitConverter.GetBytes(ip.Value)).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String GetTimePassed(DateTime start)
|
public static string GetTimePassed(DateTime start)
|
||||||
{
|
{
|
||||||
return GetTimePassed(start, true);
|
return GetTimePassed(start, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String GetTimePassed(DateTime start, bool includeAgo)
|
public static string GetTimePassed(DateTime start, bool includeAgo)
|
||||||
{
|
{
|
||||||
TimeSpan Elapsed = DateTime.UtcNow - start;
|
TimeSpan Elapsed = DateTime.UtcNow - start;
|
||||||
string ago = includeAgo ? $" {CurrentLocalization.LocalizationIndex["WEBFRONT_PENALTY_TEMPLATE_AGO"]}" : "";
|
string ago = includeAgo ? $" {CurrentLocalization.LocalizationIndex["WEBFRONT_PENALTY_TEMPLATE_AGO"]}" : "";
|
||||||
@ -480,10 +480,11 @@ namespace SharedLibraryCore
|
|||||||
/// <param name="description">description of the question's value</param>
|
/// <param name="description">description of the question's value</param>
|
||||||
/// <param name="defaultValue">default value to set if no input is entered</param>
|
/// <param name="defaultValue">default value to set if no input is entered</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool PromptBool(string question, string description = null, char? defaultValue = 'y')
|
public static bool PromptBool(string question, string description = null, bool defaultValue = true)
|
||||||
{
|
{
|
||||||
Console.Write($"{question}?{(string.IsNullOrEmpty(description) ? "" : $" ({description}) ")}[y/n]: ");
|
Console.Write($"{question}?{(string.IsNullOrEmpty(description) ? "" : $" ({description}) ")}[y/n]: ");
|
||||||
return (Console.ReadLine().ToLower().FirstOrDefault() as char? ?? defaultValue) == 'y';
|
char response = Console.ReadLine().ToLower().FirstOrDefault();
|
||||||
|
return response != 0 ? response == 'y' : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -28,7 +28,8 @@ namespace WebfrontCore.Controllers
|
|||||||
{
|
{
|
||||||
new Claim(ClaimTypes.NameIdentifier, client.Name),
|
new Claim(ClaimTypes.NameIdentifier, client.Name),
|
||||||
new Claim(ClaimTypes.Role, client.Level.ToString()),
|
new Claim(ClaimTypes.Role, client.Level.ToString()),
|
||||||
new Claim(ClaimTypes.Sid, client.ClientId.ToString())
|
new Claim(ClaimTypes.Sid, client.ClientId.ToString()),
|
||||||
|
new Claim(ClaimTypes.PrimarySid, client.NetworkId.ToString())
|
||||||
};
|
};
|
||||||
|
|
||||||
var claimsIdentity = new ClaimsIdentity(claims, "login");
|
var claimsIdentity = new ClaimsIdentity(claims, "login");
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using SharedLibraryCore;
|
||||||
using SharedLibraryCore.Database;
|
using SharedLibraryCore.Database;
|
||||||
using SharedLibraryCore.Database.Models;
|
using SharedLibraryCore.Database.Models;
|
||||||
using SharedLibraryCore.Interfaces;
|
using SharedLibraryCore.Interfaces;
|
||||||
using SharedLibraryCore.Objects;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
using WebfrontCore.ViewModels;
|
using WebfrontCore.ViewModels;
|
||||||
|
|
||||||
namespace WebfrontCore.Controllers
|
namespace WebfrontCore.Controllers
|
||||||
@ -23,14 +23,19 @@ namespace WebfrontCore.Controllers
|
|||||||
private static readonly byte[] LocalHost = { 127, 0, 0, 1 };
|
private static readonly byte[] LocalHost = { 127, 0, 0, 1 };
|
||||||
private static string SocialLink;
|
private static string SocialLink;
|
||||||
private static string SocialTitle;
|
private static string SocialTitle;
|
||||||
|
protected List<Page> Pages;
|
||||||
|
|
||||||
public BaseController()
|
public BaseController()
|
||||||
{
|
{
|
||||||
if (Manager == null)
|
if (Manager == null)
|
||||||
|
{
|
||||||
Manager = Program.Manager;
|
Manager = Program.Manager;
|
||||||
|
}
|
||||||
|
|
||||||
if (Localization == null)
|
if (Localization == null)
|
||||||
Localization = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex;
|
{
|
||||||
|
Localization = Utilities.CurrentLocalization.LocalizationIndex;
|
||||||
|
}
|
||||||
|
|
||||||
if (Manager.GetApplicationSettings().Configuration().EnableSocialLink && SocialLink == null)
|
if (Manager.GetApplicationSettings().Configuration().EnableSocialLink && SocialLink == null)
|
||||||
{
|
{
|
||||||
@ -38,6 +43,13 @@ namespace WebfrontCore.Controllers
|
|||||||
SocialTitle = Manager.GetApplicationSettings().Configuration().SocialLinkTitle;
|
SocialTitle = Manager.GetApplicationSettings().Configuration().SocialLinkTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pages = Manager.GetPageList().Pages
|
||||||
|
.Select(page => new Page
|
||||||
|
{
|
||||||
|
Name = page.Key,
|
||||||
|
Location = page.Value
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
ViewBag.Version = Manager.Version;
|
ViewBag.Version = Manager.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +67,7 @@ namespace WebfrontCore.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Client.ClientId = Convert.ToInt32(base.User.Claims.First(c => c.Type == ClaimTypes.Sid).Value);
|
Client.ClientId = Convert.ToInt32(base.User.Claims.First(c => c.Type == ClaimTypes.Sid).Value);
|
||||||
|
Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertLong();
|
||||||
Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
|
Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
|
||||||
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
|
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
|
||||||
}
|
}
|
||||||
@ -82,18 +95,11 @@ namespace WebfrontCore.Controllers
|
|||||||
|
|
||||||
Authorized = Client.ClientId >= 0;
|
Authorized = Client.ClientId >= 0;
|
||||||
ViewBag.Authorized = Authorized;
|
ViewBag.Authorized = Authorized;
|
||||||
ViewBag.Url = Manager.GetApplicationSettings().Configuration().WebfrontBindUrl;
|
ViewBag.Url = Manager.GetApplicationSettings().Configuration().WebfrontUrl;
|
||||||
ViewBag.User = Client;
|
ViewBag.User = Client;
|
||||||
ViewBag.SocialLink = SocialLink ?? "";
|
ViewBag.SocialLink = SocialLink ?? "";
|
||||||
ViewBag.SocialTitle = SocialTitle;
|
ViewBag.SocialTitle = SocialTitle;
|
||||||
|
ViewBag.Pages = Pages;
|
||||||
// grab the pages from plugins
|
|
||||||
ViewBag.Pages = Manager.GetPageList().Pages
|
|
||||||
.Select(page => new Page
|
|
||||||
{
|
|
||||||
Name = page.Key,
|
|
||||||
Location = page.Value
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
base.OnActionExecuting(context);
|
base.OnActionExecuting(context);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ namespace WebfrontCore.Controllers
|
|||||||
{
|
{
|
||||||
ClientId = Client.ClientId,
|
ClientId = Client.ClientId,
|
||||||
Level = Client.Level,
|
Level = Client.Level,
|
||||||
|
NetworkId = Client.NetworkId,
|
||||||
CurrentServer = server,
|
CurrentServer = server,
|
||||||
CurrentAlias = new EFAlias()
|
CurrentAlias = new EFAlias()
|
||||||
{
|
{
|
||||||
@ -46,7 +47,7 @@ namespace WebfrontCore.Controllers
|
|||||||
Data = command,
|
Data = command,
|
||||||
Origin = client,
|
Origin = client,
|
||||||
Owner = server,
|
Owner = server,
|
||||||
Remote = true
|
IsRemote = true
|
||||||
};
|
};
|
||||||
|
|
||||||
Manager.GetEventHandler().AddEvent(remoteEvent);
|
Manager.GetEventHandler().AddEvent(remoteEvent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user