fixed the vpn detection plugin method signature call

added some fixes for stats/ac
This commit is contained in:
RaidMax 2018-10-06 15:31:05 -05:00
parent de902a58ac
commit c8366a22e5
11 changed files with 36 additions and 24 deletions

View File

@ -5,7 +5,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish> <MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
<PackageId>RaidMax.IW4MAdmin.Application</PackageId> <PackageId>RaidMax.IW4MAdmin.Application</PackageId>
<Version>2.1.9.2</Version> <Version>2.1.9.4</Version>
<Authors>RaidMax</Authors> <Authors>RaidMax</Authors>
<Company>Forever None</Company> <Company>Forever None</Company>
<Product>IW4MAdmin</Product> <Product>IW4MAdmin</Product>
@ -30,7 +30,8 @@
<PropertyGroup> <PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection> <ServerGarbageCollection>true</ServerGarbageCollection>
<TieredCompilation>true</TieredCompilation> <TieredCompilation>true</TieredCompilation>
<AssemblyVersion>2.1.9.3</AssemblyVersion> <AssemblyVersion>2.1.9.4</AssemblyVersion>
<FileVersion>2.1.9.4</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -82,10 +82,13 @@ if "%CurrentConfiguration" == "Release" (
echo PR-RT echo PR-RT
move "%SolutionDir%Publish\WindowsPrerelease\runtimes" "%SolutionDir%Publish\WindowsPrerelease\Lib\runtimes" move "%SolutionDir%Publish\WindowsPrerelease\runtimes" "%SolutionDir%Publish\WindowsPrerelease\Lib\runtimes"
if exist "%SolutionDir%Publish\WindowsPrerelease\refs" move "%SolutionDir%Publish\WindowsPrerelease\refs" "%SolutionDir%Publish\WindowsPrerelease\Lib\refs"
if "%CurrentConfiguration" == "Release" ( if "%CurrentConfiguration" == "Release" (
echo R-RT echo R-RT
rem move "%SolutionDir%Publish\Windows\runtimes" "%SolutionDir%Publish\Windows\Lib\runtimes" move "%SolutionDir%Publish\Windows\runtimes" "%SolutionDir%Publish\Windows\Lib\runtimes"
if exist "%SolutionDir%Publish\Windows\refs" move "%SolutionDir%Publish\Windows\refs" "%SolutionDir%Publish\Windows\Lib\refs"
) )
echo making start scripts echo making start scripts

View File

@ -383,11 +383,10 @@ namespace IW4MAdmin.Application
await Plugin.OnLoadAsync(this); await Plugin.OnLoadAsync(this);
} }
catch (Exception e) catch (Exception ex)
{ {
Logger.WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_PLUGIN"]} {Plugin.Name}"); Logger.WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_PLUGIN"]} {Plugin.Name}");
Logger.WriteDebug($"Exception: {e.Message}"); Logger.WriteDebug(ex.GetExceptionInfo());
Logger.WriteDebug($"Stack Trace: {e.StackTrace}");
} }
} }
#endregion #endregion

View File

@ -42,6 +42,7 @@ var plugin = {
var library = importNamespace('SharedLibraryCore'); var library = importNamespace('SharedLibraryCore');
var kickOrigin = new library.Objects.Player(); var kickOrigin = new library.Objects.Player();
kickOrigin.ClientId = 1; kickOrigin.ClientId = 1;
kickOrigin.CurrentServer = origin.CurrentServer;
origin.Kick(_localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], kickOrigin); origin.Kick(_localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], kickOrigin);
} }
}, },
@ -55,7 +56,7 @@ var plugin = {
onLoadAsync: function (manager) { onLoadAsync: function (manager) {
this.manager = manager; this.manager = manager;
this.logger = manager.GetLogger(); this.logger = manager.GetLogger(0);
}, },
onUnloadAsync: function () { onUnloadAsync: function () {

View File

@ -26,8 +26,8 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
Dictionary<IW4Info.HitLocation, int> HitLocationCount; Dictionary<IW4Info.HitLocation, int> HitLocationCount;
double AngleDifferenceAverage; double AngleDifferenceAverage;
EFClientStatistics ClientStats; EFClientStatistics ClientStats;
DateTime LastHit;
long LastOffset; long LastOffset;
IW4Info.WeaponName LastWeapon;
ILogger Log; ILogger Log;
Strain Strain; Strain Strain;
readonly DateTime ConnectionTime = DateTime.UtcNow; readonly DateTime ConnectionTime = DateTime.UtcNow;
@ -53,16 +53,16 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
if ((kill.DeathType != IW4Info.MeansOfDeath.MOD_PISTOL_BULLET && if ((kill.DeathType != IW4Info.MeansOfDeath.MOD_PISTOL_BULLET &&
kill.DeathType != IW4Info.MeansOfDeath.MOD_RIFLE_BULLET && kill.DeathType != IW4Info.MeansOfDeath.MOD_RIFLE_BULLET &&
kill.DeathType != IW4Info.MeansOfDeath.MOD_HEAD_SHOT) || kill.DeathType != IW4Info.MeansOfDeath.MOD_HEAD_SHOT) ||
kill.HitLoc == IW4Info.HitLocation.none || kill.TimeOffset - LastOffset < 0) kill.HitLoc == IW4Info.HitLocation.none || kill.TimeOffset - LastOffset < 0 ||
// hack: prevents false positives
(LastWeapon != kill.Weapon && (kill.TimeOffset - LastOffset) == 50))
return new DetectionPenaltyResult() return new DetectionPenaltyResult()
{ {
ClientPenalty = Penalty.PenaltyType.Any, ClientPenalty = Penalty.PenaltyType.Any,
}; };
DetectionPenaltyResult result = null; DetectionPenaltyResult result = null;
LastWeapon = kill.Weapon;
if (LastHit == DateTime.MinValue)
LastHit = DateTime.UtcNow;
HitLocationCount[kill.HitLoc]++; HitLocationCount[kill.HitLoc]++;
if (!isDamage) if (!isDamage)

View File

@ -147,7 +147,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
}); });
#if DEBUG == true #if DEBUG == true
var statsInfoSql = iqStatsInfo.ToSql(); var statsInfoSql = iqStatsInfo.ToSql();
#endif #endif
var topPlayers = await iqStatsInfo.ToListAsync(); var topPlayers = await iqStatsInfo.ToListAsync();
@ -406,6 +406,14 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
string fraction, string visibilityPercentage, string snapAngles) string fraction, string visibilityPercentage, string snapAngles)
{ {
var statsSvc = ContextThreads[serverId]; var statsSvc = ContextThreads[serverId];
// incase the add palyer event get delayed
if (!Servers[serverId].PlayerStats.ContainsKey(attacker.ClientId))
{
await AddPlayer(attacker);
}
Vector3 vDeathOrigin = null; Vector3 vDeathOrigin = null;
Vector3 vKillOrigin = null; Vector3 vKillOrigin = null;
Vector3 vViewAngles = null; Vector3 vViewAngles = null;
@ -675,7 +683,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
} }
#if DEBUG #if DEBUG
Log.WriteDebug("Calculating standard kill"); Log.WriteDebug("Calculating standard kill");
#endif #endif
// update the total stats // update the total stats
@ -727,7 +735,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
#if !DEBUG #if !DEBUG
if ((DateTime.UtcNow - attackerStats.LastStatHistoryUpdate).TotalMinutes >= 2.5) if ((DateTime.UtcNow - attackerStats.LastStatHistoryUpdate).TotalMinutes >= 2.5)
#else #else
if ((DateTime.UtcNow - attackerStats.LastStatHistoryUpdate).TotalMinutes >= 0.1) if ((DateTime.UtcNow - attackerStats.LastStatHistoryUpdate).TotalMinutes >= 0.1)
#endif #endif
{ {
attackerStats.LastStatHistoryUpdate = DateTime.UtcNow; attackerStats.LastStatHistoryUpdate = DateTime.UtcNow;

View File

@ -1126,7 +1126,7 @@ namespace SharedLibraryCore.Commands
{ {
} }
public override Task ExecuteAsync(GameEvent E) public override async Task ExecuteAsync(GameEvent E)
{ {
var gameserverProcesses = System.Diagnostics.Process.GetProcessesByName("iw4x"); var gameserverProcesses = System.Diagnostics.Process.GetProcessesByName("iw4x");
@ -1180,12 +1180,12 @@ namespace SharedLibraryCore.Commands
E.Origin.Tell("Could not kill server process"); E.Origin.Tell("Could not kill server process");
E.Owner.Logger.WriteDebug("Unable to kill process"); E.Owner.Logger.WriteDebug("Unable to kill process");
E.Owner.Logger.WriteDebug($"Exception: {e.Message}"); E.Owner.Logger.WriteDebug($"Exception: {e.Message}");
return Task.CompletedTask; return;
} }
} }
} }
return Task.CompletedTask; return;
} }
} }

View File

@ -37,7 +37,7 @@ namespace SharedLibraryCore.Configuration
public Task Save() public Task Save()
{ {
var appConfigJSON = JsonConvert.SerializeObject(_configuration, Formatting.Indented); var appConfigJSON = JsonConvert.SerializeObject(_configuration, Formatting.Indented);
return File.WriteAllTextAsync(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "Configuration", $"{Filename}.json"), appConfigJSON); return File.WriteAllTextAsync(Path.Join(Utilities.OperatingDirectory, "Configuration", $"{Filename}.json"), appConfigJSON);
} }
public T Configuration() => _configuration; public T Configuration() => _configuration;

View File

@ -39,7 +39,7 @@ namespace SharedLibraryCore.RCon
/// <summary> /// <summary>
/// timeout in seconds to wait for a socket send or receive before giving up /// timeout in seconds to wait for a socket send or receive before giving up
/// </summary> /// </summary>
public static readonly int SocketTimeout = 1000; public static readonly int SocketTimeout = 7500;
/// <summary> /// <summary>
/// interval in milliseconds to wait before sending the next RCon request /// interval in milliseconds to wait before sending the next RCon request
/// </summary> /// </summary>

View File

@ -30,7 +30,7 @@ namespace WebfrontCore
#if DEBUG #if DEBUG
.UseContentRoot(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\..\", "WebfrontCore"))) .UseContentRoot(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\..\", "WebfrontCore")))
#else #else
.UseContentRoot(Path.Join(Directory.GetCurrentDirectory(), "..\\")) .UseContentRoot(SharedLibraryCore.Utilities.OperatingDirectory)
#endif #endif
.UseUrls(Manager.GetApplicationSettings().Configuration().WebfrontBindUrl) .UseUrls(Manager.GetApplicationSettings().Configuration().WebfrontBindUrl)
.UseKestrel() .UseKestrel()

View File

@ -20,7 +20,7 @@ namespace WebfrontCore
public Startup(IHostingEnvironment env) public Startup(IHostingEnvironment env)
{ {
var builder = new ConfigurationBuilder() var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath) // .SetBasePath(SharedLibraryCore.Utilities.OperatingDirectory)
.AddEnvironmentVariables(); .AddEnvironmentVariables();
Configuration = builder.Build(); Configuration = builder.Build();
@ -32,10 +32,10 @@ namespace WebfrontCore
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// Add framework services. // Add framework services.
var mvcBulder = services.AddMvc(); var mvcBuilder = services.AddMvc();
foreach (var asm in Program.Manager.GetPluginAssemblies()) foreach (var asm in Program.Manager.GetPluginAssemblies())
mvcBulder.AddApplicationPart(asm); mvcBuilder.AddApplicationPart(asm);
services.Configure<RazorViewEngineOptions>(o => services.Configure<RazorViewEngineOptions>(o =>
{ {