prevent partial client updates from setting things they shouldn't be *cough* mask *cough*

setup shared library for NuGet package
fix a couple things with offset detection calc
get cod4x working again
This commit is contained in:
RaidMax 2019-06-13 19:10:08 -05:00
parent 10829b32ad
commit 4645bd84e8
8 changed files with 43 additions and 28 deletions

View File

@ -36,7 +36,7 @@ namespace IW4MAdmin.Application.EventParsers
Configuration.Join.AddMapping(ParserRegex.GroupType.OriginClientNumber, 3); Configuration.Join.AddMapping(ParserRegex.GroupType.OriginClientNumber, 3);
Configuration.Join.AddMapping(ParserRegex.GroupType.OriginName, 4); Configuration.Join.AddMapping(ParserRegex.GroupType.OriginName, 4);
Configuration.Damage.Pattern = @"^(D);(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+);(-?[0-9]+);(axis|allies|world);(.{1,24});(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+)?;-?([0-9]+);(axis|allies|world);(.{1,24})?;((?:[0-9]+|[a-z]+|_)+);([0-9]+);((?:[A-Z]|_)+);((?:[a-z]|_)+)$"; Configuration.Damage.Pattern = @"^(D);(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+);(-?[0-9]+);(axis|allies|world)?;(.{1,24});(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+)?;-?([0-9]+);(axis|allies|world)?;(.{1,24})?;((?:[0-9]+|[a-z]+|_)+);([0-9]+);((?:[A-Z]|_)+);((?:[a-z]|_)+)$";
Configuration.Damage.AddMapping(ParserRegex.GroupType.EventType, 1); Configuration.Damage.AddMapping(ParserRegex.GroupType.EventType, 1);
Configuration.Damage.AddMapping(ParserRegex.GroupType.TargetNetworkId, 2); Configuration.Damage.AddMapping(ParserRegex.GroupType.TargetNetworkId, 2);
Configuration.Damage.AddMapping(ParserRegex.GroupType.TargetClientNumber, 3); Configuration.Damage.AddMapping(ParserRegex.GroupType.TargetClientNumber, 3);
@ -51,7 +51,7 @@ namespace IW4MAdmin.Application.EventParsers
Configuration.Damage.AddMapping(ParserRegex.GroupType.MeansOfDeath, 12); Configuration.Damage.AddMapping(ParserRegex.GroupType.MeansOfDeath, 12);
Configuration.Damage.AddMapping(ParserRegex.GroupType.HitLocation, 13); Configuration.Damage.AddMapping(ParserRegex.GroupType.HitLocation, 13);
Configuration.Kill.Pattern = @"^(K);(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+);(-?[0-9]+);(axis|allies|world);(.{1,24});(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+)?;-?([0-9]+);(axis|allies|world);(.{1,24})?;((?:[0-9]+|[a-z]+|_)+);([0-9]+);((?:[A-Z]|_)+);((?:[a-z]|_)+)$"; Configuration.Kill.Pattern = @"^(K);(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+);(-?[0-9]+);(axis|allies|world)?;(.{1,24});(-?[A-Fa-f0-9_]{1,32}|bot[0-9]+)?;-?([0-9]+);(axis|allies|world)?;(.{1,24})?;((?:[0-9]+|[a-z]+|_)+);([0-9]+);((?:[A-Z]|_)+);((?:[a-z]|_)+)$";
Configuration.Kill.AddMapping(ParserRegex.GroupType.EventType, 1); Configuration.Kill.AddMapping(ParserRegex.GroupType.EventType, 1);
Configuration.Kill.AddMapping(ParserRegex.GroupType.TargetNetworkId, 2); Configuration.Kill.AddMapping(ParserRegex.GroupType.TargetNetworkId, 2);
Configuration.Kill.AddMapping(ParserRegex.GroupType.TargetClientNumber, 3); Configuration.Kill.AddMapping(ParserRegex.GroupType.TargetClientNumber, 3);

View File

@ -3,7 +3,7 @@ var eventParser;
var plugin = { var plugin = {
author: 'FrenchFry, RaidMax', author: 'FrenchFry, RaidMax',
version: 0.4, version: 0.5,
name: 'CoD4x Parser', name: 'CoD4x Parser',
isParser: true, isParser: true,
@ -21,11 +21,11 @@ var plugin = {
rconParser.Configuration.Dvar.Pattern = '^"(.+)" is: "(.+)?" default: "(.+)?" info: "(.+)?"$'; rconParser.Configuration.Dvar.Pattern = '^"(.+)" is: "(.+)?" default: "(.+)?" info: "(.+)?"$';
rconParser.Configuration.Dvar.AddMapping(109, 2); // DVAR latched value rconParser.Configuration.Dvar.AddMapping(109, 2); // DVAR latched value
rconParser.Configuration.Dvar.AddMapping(110, 4); // dvar info rconParser.Configuration.Dvar.AddMapping(110, 4); // dvar info
rconParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017'; rconParser.Version = 'CoD4 X - win_mingw-x86 build 963 Mar 12 2019';
rconParser.GameName = 1; // IW3 rconParser.GameName = 1; // IW3
eventParser.Configuration.GameDirectory = 'main'; eventParser.Configuration.GameDirectory = 'main';
eventParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017'; eventParser.Version = 'CoD4 X - win_mingw-x86 build 963 Mar 12 2019';
eventParser.GameName = 1; // IW3 eventParser.GameName = 1; // IW3
eventParser.URLProtocolFormat = 'cod4://{{ip}}:{{port}}'; eventParser.URLProtocolFormat = 'cod4://{{ip}}:{{port}}';
}, },

View File

@ -19,7 +19,7 @@ var plugin = {
rconParser.Configuration.CommandPrefixes.Kick = 'clientkick {0} "{1}"'; rconParser.Configuration.CommandPrefixes.Kick = 'clientkick {0} "{1}"';
rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"'; rconParser.Configuration.CommandPrefixes.Ban = 'clientkick {0} "{1}"';
rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"'; rconParser.Configuration.CommandPrefixes.TempBan = 'tempbanclient {0} "{1}"';
eventParser.Configuration.GameDirectory = 'userraw'; eventParser.Configuration.GameDirectory = 'userraw';
rconParser.Version = 'IW4x (v0.6.0)'; rconParser.Version = 'IW4x (v0.6.0)';
rconParser.GameName = 2; // IW4x rconParser.GameName = 2; // IW4x

View File

@ -127,7 +127,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
int totalSessionHits = HitLocationCount.Sum(_hit => _hit.Value.Count); int totalSessionHits = HitLocationCount.Sum(_hit => _hit.Value.Count);
var weightedSessionAverage = HitLocationCount.Where(_hit => _hit.Value.Count > 0) var weightedSessionAverage = HitLocationCount.Where(_hit => _hit.Value.Count > 0)
.Sum(_hit => _hit.Value.Offset * _hit.Value.Count) / totalHits; .Sum(_hit => _hit.Value.Offset * _hit.Value.Count) / totalSessionHits;
if (weightedSessionAverage > Thresholds.MaxOffset(totalSessionHits) && if (weightedSessionAverage > Thresholds.MaxOffset(totalSessionHits) &&
totalSessionHits > 40) totalSessionHits > 40)
@ -206,7 +206,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
// calculate maximum bone // calculate maximum bone
double currentMaxBoneRatio = (HitLocationCount.Values.Select(v => v.Count / (double)HitCount).Max()); double currentMaxBoneRatio = (HitLocationCount.Values.Select(v => v.Count / (double)HitCount).Max());
var bone = HitLocationCount.FirstOrDefault(b => b.Value == HitLocationCount.Values.Max()).Key; var bone = HitLocationCount.FirstOrDefault(b => b.Value.Count == HitLocationCount.Values.Max(_hit => _hit.Count)).Key;
#region HEADSHOT_RATIO #region HEADSHOT_RATIO
// flag on headshot // flag on headshot

View File

@ -160,7 +160,7 @@ namespace SharedLibraryCore.RCon
string responseString = defaultEncoding.GetString(response, 0, response.Length) + '\n'; string responseString = defaultEncoding.GetString(response, 0, response.Length) + '\n';
if (responseString.Contains("Invalid password")) if (responseString.Contains("Invalid password") || responseString.Contains("rconpassword"))
{ {
throw new NetworkException(Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_RCON_INVALID"]); throw new NetworkException(Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_RCON_INVALID"]);
} }

View File

@ -360,28 +360,36 @@ namespace SharedLibraryCore.Services
{ {
using (var context = new DatabaseContext()) using (var context = new DatabaseContext())
{ {
if (temporalClient.LastConnection == DateTime.MinValue || temporalClient.FirstConnection == DateTime.MinValue)
{
throw new InvalidOperationException($"client {temporalClient} trying to update but parameters are invalid");
}
// grab the context version of the entity // grab the context version of the entity
var entity = context.Clients var entity = context.Clients
.First(client => client.ClientId == temporalClient.ClientId); .First(client => client.ClientId == temporalClient.ClientId);
if (entity.TotalConnectionTime > temporalClient.TotalConnectionTime || entity.Connections > temporalClient.Connections || if (temporalClient.LastConnection > entity.LastConnection)
entity.LastConnection > temporalClient.LastConnection || entity.FirstConnection > temporalClient.FirstConnection)
{ {
throw new InvalidOperationException($"client {temporalClient} trying to update but new parameters don't match saved parameters"); entity.LastConnection = temporalClient.LastConnection;
}
if (temporalClient.Connections > entity.Connections)
{
entity.Connections = temporalClient.Connections;
} }
entity.LastConnection = temporalClient.LastConnection;
entity.Connections = temporalClient.Connections;
entity.FirstConnection = temporalClient.FirstConnection;
entity.Masked = temporalClient.Masked; entity.Masked = temporalClient.Masked;
entity.TotalConnectionTime = temporalClient.TotalConnectionTime;
entity.Password = temporalClient.Password; if (temporalClient.TotalConnectionTime > entity.TotalConnectionTime)
entity.PasswordSalt = temporalClient.PasswordSalt; {
entity.TotalConnectionTime = temporalClient.TotalConnectionTime;
}
if (temporalClient.Password != null)
{
entity.Password = temporalClient.Password;
}
if (temporalClient.PasswordSalt != null)
{
entity.PasswordSalt = temporalClient.PasswordSalt;
}
// update in database // update in database
await context.SaveChangesAsync(); await context.SaveChangesAsync();

View File

@ -13,6 +13,14 @@
<Configurations>Debug;Release;Prerelease</Configurations> <Configurations>Debug;Release;Prerelease</Configurations>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<LangVersion>7.1</LangVersion> <LangVersion>7.1</LangVersion>
<PackageTags>IW4MAdmin</PackageTags>
<RepositoryUrl>https://github.com/RaidMax/IW4M-Admin/</RepositoryUrl>
<PackageProjectUrl>https://www.raidmax.org/IW4MAdmin/</PackageProjectUrl>
<PackageIconUrl>https://www.raidmax.org/IW4MAdmin/img/iw4adminicon-3.png</PackageIconUrl>
<Copyright>2019</Copyright>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -271,7 +271,7 @@ namespace SharedLibraryCore
public static long ConvertGuidToLong(this string str, long? fallback = null) public static long ConvertGuidToLong(this string str, long? fallback = null)
{ {
str = str.Substring(0, Math.Min(str.Length, 16)); str = str.Substring(0, Math.Min(str.Length, 19));
var bot = Regex.Match(str, @"bot[0-9]+").Value; var bot = Regex.Match(str, @"bot[0-9]+").Value;
if (string.IsNullOrWhiteSpace(str) && fallback.HasValue) if (string.IsNullOrWhiteSpace(str) && fallback.HasValue)
@ -279,11 +279,10 @@ namespace SharedLibraryCore
return fallback.Value; return fallback.Value;
} }
// this is a special case for Plutonium T6 // this is a special case for Plutonium T6 and CoD4x
if (str.Length <= 11 && if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out long id))
long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out long id)) // 10 numeric characters + signed character
{ {
id = (uint)id;
} }
else if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id)) else if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id))