minor fixed

This commit is contained in:
RaidMax 2018-12-03 19:21:13 -06:00
parent 4522992c0e
commit b77bdbe793
6 changed files with 44 additions and 17 deletions

View File

@ -6,7 +6,7 @@
<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
<Version>2.2.2.0</Version>
<Version>2.2.2.2</Version>
<Authors>RaidMax</Authors>
<Company>Forever None</Company>
<Product>IW4MAdmin</Product>
@ -31,8 +31,8 @@
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
<TieredCompilation>true</TieredCompilation>
<AssemblyVersion>2.2.2.0</AssemblyVersion>
<FileVersion>2.2.2.0</FileVersion>
<AssemblyVersion>2.2.2.2</AssemblyVersion>
<FileVersion>2.2.2.2</FileVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -40,7 +40,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
ProjectSection(SolutionItems) = preProject
Plugins\ScriptPlugins\SharedGUIDKick.js = Plugins\ScriptPlugins\SharedGUIDKick.js
Plugins\ScriptPlugins\VPNDetection.js = Plugins\ScriptPlugins\VPNDetection.js
Plugins\ScriptPlugins\VpnDetectionPrivate.js = Plugins\ScriptPlugins\VpnDetectionPrivate.js
EndProjectSection
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "GameLogServer", "GameLogServer\GameLogServer.pyproj", "{42EFDA12-10D3-4C40-A210-9483520116BC}"

View File

@ -485,7 +485,7 @@ namespace SharedLibraryCore.Database.Models
// hack: re apply the automated offense to the reban
if (currentBan.AutomatedOffense != null)
{
autoKickClient.AdministeredPenalties.Add(new EFPenalty()
autoKickClient.AdministeredPenalties?.Add(new EFPenalty()
{
AutomatedOffense = currentBan.AutomatedOffense
});

View File

@ -5,7 +5,6 @@ using System.Collections.Concurrent;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -29,7 +28,8 @@ namespace SharedLibraryCore.RCon
static readonly ConcurrentDictionary<EndPoint, ConnectionState> ActiveQueries = new ConcurrentDictionary<EndPoint, ConnectionState>();
public IPEndPoint Endpoint { get; private set; }
public string RConPassword { get; private set; }
ILogger Log;
private readonly ILogger Log;
public Connection(string ipAddress, int port, string password, ILogger log)
{
@ -107,7 +107,7 @@ namespace SharedLibraryCore.RCon
{
response = await SendPayloadAsync(payload, waitForResponse);
if (response.Length == 0)
if (response.Length == 0 && waitForResponse)
{
throw new Exception();
}

View File

@ -50,6 +50,12 @@ namespace SharedLibraryCore.Services
public async Task UpdateAlias(EFClient entity)
{
// todo: move this out
if (entity.IsBot)
{
return;
}
using (var context = new DatabaseContext())
{
context.Attach(entity);
@ -60,10 +66,16 @@ namespace SharedLibraryCore.Services
bool hasExistingAlias = false;
// get all aliases by IP
var aliases = await context.Aliases
var iqAliases = context.Aliases
.Include(a => a.Link)
.Where(a => a.IPAddress != null && a.IPAddress == ip)
.ToListAsync();
.Where(a => a.Link.Active)
.Where(a => (a.IPAddress != null && a.IPAddress == ip) ||
a.LinkId == entity.AliasLinkId);
#if DEBUG == true
var aliasSql = iqAliases.ToSql();
#endif
var aliases = await iqAliases.ToListAsync();
// see if they have a matching IP + Name but new NetworkId
var existingAlias = aliases.FirstOrDefault(a => a.Name == name);
@ -112,6 +124,7 @@ namespace SharedLibraryCore.Services
existingAlias = alias;
aliasLink = _aliasLink;
await context.SaveChangesAsync();
}
// if no existing alias create new alias
@ -128,10 +141,24 @@ namespace SharedLibraryCore.Services
entity.CurrentServer.Logger.WriteDebug($"Connecting player does not have an existing alias {entity}");
}
entity.Level = hasExistingAlias ?
await context.Clients.Where(c => c.AliasLinkId == existingAlias.LinkId)
.MaxAsync(c => c.Level) :
Permission.User;
else
{
var linkIds = aliases.Select(a => a.LinkId);
if (linkIds.Count() > 0)
{
var highestLevel = await context.Clients
.Where(c => linkIds.Contains(c.AliasLinkId))
.MaxAsync(c => c.Level);
if (entity.Level != highestLevel)
{
context.Update(entity);
entity.Level = highestLevel;
await context.SaveChangesAsync();
}
}
}
if (entity.CurrentAlias != existingAlias ||
entity.AliasLink != aliasLink)

View File

@ -36,7 +36,8 @@ namespace SharedLibraryCore
CurrentAlias = new EFAlias()
{
Name = "IW4MAdmin"
}
},
AdministeredPenalties = new List<EFPenalty>()
};
}