mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
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:
@ -160,7 +160,7 @@ namespace SharedLibraryCore.RCon
|
||||
|
||||
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"]);
|
||||
}
|
||||
|
@ -360,28 +360,36 @@ namespace SharedLibraryCore.Services
|
||||
{
|
||||
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
|
||||
var entity = context.Clients
|
||||
.First(client => client.ClientId == temporalClient.ClientId);
|
||||
|
||||
if (entity.TotalConnectionTime > temporalClient.TotalConnectionTime || entity.Connections > temporalClient.Connections ||
|
||||
entity.LastConnection > temporalClient.LastConnection || entity.FirstConnection > temporalClient.FirstConnection)
|
||||
if (temporalClient.LastConnection > entity.LastConnection)
|
||||
{
|
||||
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.TotalConnectionTime = temporalClient.TotalConnectionTime;
|
||||
entity.Password = temporalClient.Password;
|
||||
entity.PasswordSalt = temporalClient.PasswordSalt;
|
||||
|
||||
if (temporalClient.TotalConnectionTime > entity.TotalConnectionTime)
|
||||
{
|
||||
entity.TotalConnectionTime = temporalClient.TotalConnectionTime;
|
||||
}
|
||||
|
||||
if (temporalClient.Password != null)
|
||||
{
|
||||
entity.Password = temporalClient.Password;
|
||||
}
|
||||
|
||||
if (temporalClient.PasswordSalt != null)
|
||||
{
|
||||
entity.PasswordSalt = temporalClient.PasswordSalt;
|
||||
}
|
||||
|
||||
// update in database
|
||||
await context.SaveChangesAsync();
|
||||
|
@ -13,6 +13,14 @@
|
||||
<Configurations>Debug;Release;Prerelease</Configurations>
|
||||
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
|
||||
<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>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -271,7 +271,7 @@ namespace SharedLibraryCore
|
||||
|
||||
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;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(str) && fallback.HasValue)
|
||||
@ -279,11 +279,10 @@ namespace SharedLibraryCore
|
||||
return fallback.Value;
|
||||
}
|
||||
|
||||
// this is a special case for Plutonium T6
|
||||
if (str.Length <= 11 &&
|
||||
long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out long id)) // 10 numeric characters + signed character
|
||||
// this is a special case for Plutonium T6 and CoD4x
|
||||
if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out long id))
|
||||
{
|
||||
id = (uint)id;
|
||||
|
||||
}
|
||||
|
||||
else if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id))
|
||||
|
Reference in New Issue
Block a user