1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

final changes for 2.0 release

This commit is contained in:
RaidMax
2018-04-21 17:18:20 -05:00
parent a515d9688c
commit c7b4706e78
20 changed files with 230 additions and 87 deletions

View File

@ -214,11 +214,11 @@ namespace SharedLibraryCore.Commands
public class CUnban : Command
{
public CUnban() :
base("unban", "unban player by database id", "ub", Player.Permission.SeniorAdmin, true, new CommandArgument[]
base("unban", "unban player by client id", "ub", Player.Permission.SeniorAdmin, true, new CommandArgument[]
{
new CommandArgument()
{
Name = "databaseID",
Name = "client id",
Required = true,
},
new CommandArgument()
@ -576,6 +576,12 @@ namespace SharedLibraryCore.Commands
public override async Task ExecuteAsync(GameEvent E)
{
if (E.Data.Length < 3)
{
await E.Origin.Tell("Please enter at least 3 characters");
return;
}
IList<EFClient> db_players = (await (E.Owner.Manager.GetClientService() as ClientService)
.GetClientByName(E.Data))
.OrderByDescending(p => p.LastConnection)

View File

@ -17,6 +17,7 @@ namespace SharedLibraryCore.Configuration
public string DiscordInviteCode { get; set; }
public string IPHubAPIKey { get; set; }
public string WebfrontBindUrl { get; set; }
public string CustomParserEncoding { get; set; }
public string Id { get; set; }
public List<ServerConfiguration> Servers { get; set; }
public int AutoMessagePeriod { get; set; }
@ -32,6 +33,10 @@ namespace SharedLibraryCore.Configuration
EnableSteppedHierarchy = Utilities.PromptBool("Enable stepped privilege hierarchy");
EnableCustomSayName = Utilities.PromptBool("Enable custom say name");
bool useCustomParserEncoding = Utilities.PromptBool("Use custom encoding parser");
CustomParserEncoding = useCustomParserEncoding ? Utilities.PromptString("Enter encoding string") : "windows-1252";
WebfrontBindUrl = "http://127.0.0.1:1624";
if (EnableCustomSayName)

View File

@ -39,7 +39,7 @@ namespace SharedLibraryCore
if (fileName != string.Empty)
{
Name = fileName;
Handle = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, true), Encoding.UTF8);
Handle = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, true), Utilities.EncodingType);
sze = Handle.BaseStream.Length;
}

View File

@ -130,7 +130,7 @@ namespace SharedLibraryCore.RCon
#if DEBUG
Log.WriteDebug($"Received {bytesRead} bytes from {ServerConnection.RemoteEndPoint}");
#endif
connectionState.ResponseString.Append(Encoding.UTF7.GetString(connectionState.Buffer, 0, bytesRead).TrimEnd('\0') + '\n');
connectionState.ResponseString.Append(Utilities.EncodingType.GetString(connectionState.Buffer, 0, bytesRead).TrimEnd('\0') + '\n');
if (!connectionState.Buffer.Take(4).ToArray().SequenceEqual(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }))
throw new NetworkException("Unexpected packet received");

View File

@ -226,6 +226,9 @@ namespace SharedLibraryCore.Services
public async Task<IList<EFClient>> GetClientByName(string name)
{
if (name.Length < 3)
return new List<EFClient>();
using (var context = new DatabaseContext())
{
var iqClients = (from alias in context.Aliases

View File

@ -20,6 +20,7 @@ namespace SharedLibraryCore
{
public static string OperatingDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
public static readonly Task CompletedTask = Task.FromResult(false);
public static Encoding EncodingType;
//Get string with specified number of spaces -- really only for visual output
public static String GetSpaces(int Num)
@ -197,15 +198,9 @@ namespace SharedLibraryCore
public static int ConvertToIP(this string str)
{
try
{
return BitConverter.ToInt32(System.Net.IPAddress.Parse(str).GetAddressBytes(), 0);
}
System.Net.IPAddress.TryParse(str, out System.Net.IPAddress ip);
catch (FormatException)
{
return 0;
}
return ip == null ? 0 : BitConverter.ToInt32(ip.GetAddressBytes(), 0);
}
public static string ConvertIPtoString(this int ip)