1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 07:13:58 -05:00

fix reading PT6 having signed decimal GUID in log

fix  alternative encoding character converting
allow more paths for game log server
add localization for unknown ips in welcome plugin
add gamelog server uri to support game log server on games that must supply manual log path
misc fixes
This commit is contained in:
RaidMax
2019-02-09 15:35:13 -06:00
parent 2714f5069d
commit a2ce19117b
15 changed files with 81 additions and 67 deletions

View File

@ -16,6 +16,7 @@ namespace SharedLibraryCore.Configuration
public string RConParserVersion { get; set; }
public string EventParserVersion { get; set; }
public int ReservedSlotNumber { get; set; }
public Uri GameLogServerUrl { get; set; }
private readonly IList<IRConParser> rconParsers;
private readonly IList<IEventParser> eventParsers;

View File

@ -78,16 +78,14 @@ namespace SharedLibraryCore.RCon
byte[] payload = null;
bool waitForResponse = Config.WaitForResponse;
string converterEncoding(string text)
{
var destinationEncoding = Encoding.GetEncoding("windows-1252");
byte[] originalEncodedBytes = Utilities.EncodingType.GetBytes(text);
byte[] convertedBytes = Encoding.Convert(Utilities.EncodingType, destinationEncoding, originalEncodedBytes);
return destinationEncoding.GetString(convertedBytes);
string convertEncoding(string text)
{
byte[] convertedBytes = Utilities.EncodingType.GetBytes(text);
return Utilities.EncodingType.GetString(convertedBytes);
}
string convertedRConPassword = converterEncoding(RConPassword);
string convertedParameters = converterEncoding(parameters);
string convertedRConPassword = convertEncoding(RConPassword);
string convertedParameters = convertEncoding(parameters);
switch (type)
{
@ -109,6 +107,10 @@ namespace SharedLibraryCore.RCon
waitForResponse |= true;
payload = (Config.CommandPrefixes.RConGetInfo + '\0').Select(Convert.ToByte).ToArray();
break;
case StaticHelpers.QueryType.COMMAND_STATUS:
waitForResponse |= true;
payload = string.Format(Config.CommandPrefixes.RConCommand, convertedRConPassword, "status\0").Select(Convert.ToByte).ToArray();
break;
}
byte[] response = null;

View File

@ -35,6 +35,11 @@ namespace SharedLibraryCore.RCon
/// RCon password is required
/// </summary>
COMMAND,
/// <summary>
/// get the full server command information
/// RCon password is required
/// </summary>
COMMAND_STATUS
}
/// <summary>

View File

@ -266,11 +266,16 @@ namespace SharedLibraryCore
public static long ConvertLong(this string str)
{
str = str.Substring(0, Math.Min(str.Length, 16));
if (Int64.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out long id))
if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out long id))
{
return id;
}
if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
{
return (uint)id;
}
var bot = Regex.Match(str, @"bot[0-9]+").Value;
if (!string.IsNullOrEmpty(bot))
{
@ -640,6 +645,13 @@ namespace SharedLibraryCore
return cmdLine.Length > 1 ? cmdLine[1] : cmdLine[0];
}
/// <summary>
/// indicates if the given log path is a remote (http) uri
/// </summary>
/// <param name="log"></param>
/// <returns></returns>
public static bool IsRemoteLog(this string log) => (log ?? "").StartsWith("http");
public static string ToBase64UrlSafeString(this string src)
{
return Convert.ToBase64String(src.Select(c => Convert.ToByte(c)).ToArray()).Replace('+', '-').Replace('/', '_');