changes and vpn checking

This commit is contained in:
RaidMax 2018-03-09 02:01:12 -06:00
parent 3c5173eaa4
commit 5c0aa7d14f
42 changed files with 362 additions and 1209 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,8 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VotemapPlugin", "Plugins\Vo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessageboardPlugin", "Plugins\MessageBoard\MessageboardPlugin.csproj", "{E46C85BD-A99C-484E-BCCE-0F1831C5925E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventAPI", "Plugins\EventAPI\EventAPI.csproj", "{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{26E8B310-269E-46D4-A612-24601F16065F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastRestartPlugin", "Plugins\FastRestart\FastRestartPlugin.csproj", "{1479DE87-ACB5-4046-81C8-A0BA5041227D}"
@ -206,38 +204,6 @@ Global
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{E46C85BD-A99C-484E-BCCE-0F1831C5925E}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|Mixed Platforms.Build.0 = Debug|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x64.ActiveCfg = Debug|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x64.Build.0 = Debug|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x86.ActiveCfg = Debug|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Debug|x86.Build.0 = Debug|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Any CPU.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Any CPU.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Mixed Platforms.ActiveCfg = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|Mixed Platforms.Build.0 = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x64.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x64.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.ActiveCfg = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release|x86.Build.0 = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Any CPU.ActiveCfg = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Any CPU.Build.0 = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Mixed Platforms.ActiveCfg = Release-Nightly|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|Mixed Platforms.Build.0 = Release-Nightly|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x64.ActiveCfg = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Any CPU.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
@ -339,7 +305,6 @@ Global
{AF097E6B-48D5-4452-9CCF-0A81A21F341D} = {26E8B310-269E-46D4-A612-24601F16065F}
{428D8EB9-ECA3-4A66-AA59-3A944378C33F} = {26E8B310-269E-46D4-A612-24601F16065F}
{E46C85BD-A99C-484E-BCCE-0F1831C5925E} = {26E8B310-269E-46D4-A612-24601F16065F}
{C9E821BF-23AD-4CB5-B7F9-B3B99B606650} = {26E8B310-269E-46D4-A612-24601F16065F}
{1479DE87-ACB5-4046-81C8-A0BA5041227D} = {26E8B310-269E-46D4-A612-24601F16065F}
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1} = {26E8B310-269E-46D4-A612-24601F16065F}
EndGlobalSection

View File

@ -69,7 +69,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Plugin.cs" />
<None Include="Plugin.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />

View File

@ -85,7 +85,7 @@ namespace EventAPI
message.Contains("wall") ||
message.Contains("cheto") ||
message.Contains("hak") ||
message.Contains("bot");
message.Contains(" bot ");
if (flagged)
{

View File

@ -9,7 +9,6 @@ using System.Threading.Tasks;
namespace StatsPlugin.Commands
{
public class ResetStats : Command
{
public ResetStats() : base("resetstats", "reset your stats to factory-new", "rs", Player.Permission.User, false) { }
@ -32,7 +31,7 @@ namespace StatsPlugin.Commands
// fixme: this doesn't work properly when another context exists
await svc.SaveChangesAsync();
await E.Origin.Tell("Your stats have been reset");
await E.Origin.Tell("Your stats for this server have been reset");
}
else

View File

@ -97,7 +97,7 @@ namespace StatsPlugin
double abdomenRatio = 0;
double chestAbdomenRatio = 0;
if (clientStats.FirstOrDefault()?.HitLocations.Count > 0)
if (clientStats.Where(cs => cs.HitLocations.Count > 0).FirstOrDefault() != null)
{
chestRatio = Math.Round(clientStats.Where(c => c.HitLocations.Count > 0).Sum(c =>
c.HitLocations.First(hl => hl.Location == IW4Info.HitLocation.torso_upper).HitCount) /

View File

@ -118,6 +118,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cheat\Detection.cs" />
<Compile Include="Cheat\DetectionPenaltyResult.cs" />
<Compile Include="Cheat\Thresholds.cs" />
<Compile Include="Commands\ResetStats.cs" />
<Compile Include="Commands\TopStats.cs" />
<Compile Include="Commands\ViewStats.cs" />
@ -147,9 +150,7 @@
<Name>SharedLibrary</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Cheat\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>

View File

@ -56,7 +56,7 @@ namespace SharedLibrary.Database
#if !DEBUG
foreach (string dllPath in System.IO.Directory.GetFiles($"{Utilities.OperatingDirectory}Plugins"))
#else
foreach (string dllPath in System.IO.Directory.GetFiles(@"C:\Users\User\Desktop\stuff\IW4M-Admin\IW4M-Admin\WebfrontCore\bin\x86\Debug\Plugins"))
foreach (string dllPath in System.IO.Directory.GetFiles(@"C:\Projects\IW4M-Admin\WebfrontCore\bin\x86\Debug\Plugins").Where(f => f.Contains(".dll")))
#endif
{
Assembly library;

View File

@ -0,0 +1,11 @@
using System;
namespace SharedLibrary.Dtos
{
public class ChatInfo
{
public string Message { get; set; }
public DateTime Time { get; set; }
public string Name { get; set; }
}
}

View File

@ -0,0 +1,39 @@
using System;
namespace SharedLibrary.Dtos
{
public class EventInfo
{
public EventInfo(EventType Ty, EventVersion V, string M, string T, string O, string Ta)
{
Type = Ty;
Version = V;
Message = System.Web.HttpUtility.HtmlEncode(M);
Title = T;
Origin = System.Web.HttpUtility.HtmlEncode(O);
Target = System.Web.HttpUtility.HtmlEncode(Ta);
ID = Math.Abs(DateTime.Now.GetHashCode());
}
public enum EventType
{
NOTIFICATION,
STATUS,
ALERT,
}
public enum EventVersion
{
IW4MAdmin
}
public EventType Type;
public EventVersion Version;
public string Message;
public string Title;
public string Origin;
public string Target;
public int ID;
}
}

View File

@ -14,7 +14,7 @@ namespace SharedLibrary.Dtos
public string GameType { get; set; }
public int ClientCount { get; set; }
public int MaxClients { get; set; }
public Chat[] ChatHistory { get; set; }
public ChatInfo[] ChatHistory { get; set; }
public List<PlayerInfo> Players { get; set; }
public Helpers.PlayerHistory[] PlayerHistory { get; set; }
public int ID { get; set; }

View File

@ -8,59 +8,6 @@ using SharedLibrary.Objects;
namespace SharedLibrary
{
[Serializable]
public class Chat
{
public Chat(string O, String M, DateTime D)
{
Name = O;
Message = M;
Time = D;
}
public String Message { get; private set; }
public DateTime Time { get; private set; }
public string Name;
}
[Serializable]
public struct RestEvent
{
public RestEvent(EventType Ty, EventVersion V, string M, string T, string O, string Ta)
{
Type = Ty;
Version = V;
Message = System.Web.HttpUtility.HtmlEncode(M);
Title = T;
Origin = System.Web.HttpUtility.HtmlEncode(O);
Target = System.Web.HttpUtility.HtmlEncode(Ta);
ID = Math.Abs(DateTime.Now.GetHashCode());
}
public enum EventType
{
NOTIFICATION,
STATUS,
ALERT,
}
public enum EventVersion
{
IW4MAdmin
}
public EventType Type;
public EventVersion Version;
public string Message;
public string Title;
public string Origin;
public string Target;
public int ID;
}
public class Event
{
public enum GType
@ -135,10 +82,10 @@ namespace SharedLibrary
}
if (removeTime.Contains("ExitLevel"))
return new Event(GType.MapEnd, line[0], null, null, SV);
return new Event(GType.MapEnd, line[0], new Player() { ClientId = 1 }, null, SV);
if (removeTime.Contains("InitGame"))
return new Event(GType.MapChange, line[0], null, null, SV);
return new Event(GType.MapChange, line[0], new Player() { ClientId = 1 }, null, SV);
return null;

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<noInheritable></noInheritable>
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.4148" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
<file name="msvcr90.dll" hashalg="SHA1" hash="98e8006e0a4542e69f1a3555b927758bd76ca07d"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>+CXED+6HzJlSphyMNOn27ujadC0=</dsig:DigestValue></asmv2:hash></file> <file name="msvcp90.dll" hashalg="SHA1" hash="3aec3be680024a46813dee891a753bd58b3f3b12"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>MyKED+9DyS+1XcMeaC0Zlw2vFZ0=</dsig:DigestValue></asmv2:hash></file> <file name="msvcm90.dll" hashalg="SHA1" hash="0195dd0896d74b62531e4f3c771904a3d996450e"><asmv2:hash xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:Transforms><dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity"></dsig:Transform></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></dsig:DigestMethod><dsig:DigestValue>EeyDE7og6WoPd2oBhYbMEnpFHhY=</dsig:DigestValue></asmv2:hash></file>
</assembly>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -39,7 +39,7 @@ namespace SharedLibrary
Players = new List<Player>(new Player[18]);
Reports = new List<Report>();
PlayerHistory = new Queue<Helpers.PlayerHistory>();
ChatHistory = new List<Chat>();
ChatHistory = new List<ChatInfo>();
//Configuration = new ConfigurationManager(this.GetType());
NextMessage = 0;
InitializeTokens();
@ -364,7 +364,7 @@ namespace SharedLibrary
public List<Map> Maps { get; protected set; }
public List<string> Rules { get; protected set; }
public List<Report> Reports { get; set; }
public List<Chat> ChatHistory { get; protected set; }
public List<ChatInfo> ChatHistory { get; protected set; }
public Queue<Helpers.PlayerHistory> PlayerHistory { get; private set; }
public Game GameName { get; protected set; }

View File

@ -153,7 +153,8 @@ namespace SharedLibrary.Services
Offense = penalty.Offense,
Type = penalty.Type.ToString()
},
When = penalty.When
When = penalty.When,
Sensitive = penalty.Type == Objects.Penalty.PenaltyType.Flag
};
// fixme: is this good and fast?
return await iqPenalties.ToListAsync();

View File

@ -154,6 +154,7 @@
<Compile Include="Database\Models\EFPenalty.cs" />
<Compile Include="Database\Models\SharedEntity.cs" />
<Compile Include="Database\Repair.cs" />
<Compile Include="Dtos\ChatInfo.cs" />
<Compile Include="Dtos\CommandResponseInfo.cs" />
<Compile Include="Dtos\PlayerInfo.cs" />
<Compile Include="Dtos\ClientInfo.cs" />
@ -207,7 +208,16 @@
</ItemGroup>
<ItemGroup>
<Content Include="app.config" />
<None Include="packages.config" />
<Compile Include="Dtos\EventInfo.cs" />
<Content Include="LibSQLCE\x86\Microsoft.VC90.CRT\msvcr90.dll" />
<Content Include="LibSQLCE\x86\Microsoft.VC90.CRT\README_ENU.txt" />
<Content Include="LibSQLCE\x86\sqlceca40.dll" />
<Content Include="LibSQLCE\x86\sqlcecompact40.dll" />
<Content Include="LibSQLCE\x86\sqlceer40EN.dll" />
<Content Include="LibSQLCE\x86\sqlceme40.dll" />
<Content Include="LibSQLCE\x86\sqlceqp40.dll" />
<Content Include="LibSQLCE\x86\sqlcese40.dll" />
<None Include="LibSQLCE\x86\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EntityFramework">
@ -242,10 +252,8 @@
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\lib"
copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\lib"
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\x86\*.*" "$(TargetDir)x86"
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"
if not exist "$(ProjectDir)LibSQLCE\x86" md "$(TargetDir)x86"
xcopy /s /y "$(ProjectDir)LibSQLCE\x86\*.*" "$(TargetDir)x86"
xcopy /Y /I /E "$(TargetDir)*" "$(SolutionDir)BUILD\Lib"</PostBuildEvent>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net45" />
<package id="EntityFramework.SqlServerCompact" version="6.2.0" targetFramework="net45" />
<package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net45" />
</packages>

View File

@ -0,0 +1,69 @@
using SharedLibrary;
using System;
using System.Collections.Generic;
namespace WebfrontCore.Application.API
{
class EventAPI
{
public static Queue<SharedLibrary.Dtos.EventInfo> Events = new Queue<SharedLibrary.Dtos.EventInfo>();
static DateTime LastFlagEvent;
static string[] FlaggedMessageContains =
{
" wh ",
"hax",
"cheat",
" hack ",
"aim",
"wall",
"cheto",
"hak",
"bot"
};
static int FlaggedMessageCount;
public static void OnServerEventOccurred(object sender, Event E)
{
if (E.Type == Event.GType.Say && E.Origin.Level < SharedLibrary.Objects.Player.Permission.Trusted)
{
bool flaggedMessage = false;
foreach (string msg in FlaggedMessageContains)
flaggedMessage = flaggedMessage ? flaggedMessage : E.Data.ToLower().Contains(msg);
if (flaggedMessage)
FlaggedMessageCount++;
if (FlaggedMessageCount > 3)
{
if (Events.Count > 20)
Events.Dequeue();
FlaggedMessageCount = 0;
E.Owner.Broadcast("If you suspect someone of ^5CHEATING ^7use the ^5!report ^7command").Wait();
Events.Enqueue(new SharedLibrary.Dtos.EventInfo(
SharedLibrary.Dtos.EventInfo.EventType.ALERT,
SharedLibrary.Dtos.EventInfo.EventVersion.IW4MAdmin,
"Chat indicates there may be a cheater",
"Alert",
E.Owner.Hostname, ""));
}
if ((DateTime.UtcNow - LastFlagEvent).Minutes >= 3)
{
FlaggedMessageCount = 0;
LastFlagEvent = DateTime.Now;
}
}
if (E.Type == Event.GType.Report)
{
Events.Enqueue(new SharedLibrary.Dtos.EventInfo(
SharedLibrary.Dtos.EventInfo.EventType.ALERT,
SharedLibrary.Dtos.EventInfo.EventVersion.IW4MAdmin,
$"**{E.Origin.Name}** has reported **{E.Target.Name}** for: {E.Data.Trim()}",
E.Target.Name, E.Origin.Name, ""));
}
}
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace IW4MAdmin

View File

@ -12,6 +12,7 @@ using SharedLibrary.Helpers;
using SharedLibrary.Exceptions;
using SharedLibrary.Objects;
using SharedLibrary.Services;
using WebfrontCore.Application.API;
namespace IW4MAdmin
{
@ -22,6 +23,7 @@ namespace IW4MAdmin
public List<int> AdministratorIPs { get; set; }
public ILogger Logger { get; private set; }
public bool Running { get; private set; }
public EventHandler<Event> ServerEventOccurred { get; private set; }
static ApplicationManager Instance;
List<AsyncStatus> TaskStatuses;
@ -47,6 +49,7 @@ namespace IW4MAdmin
AliasSvc = new AliasService();
PenaltySvc = new PenaltyService();
AdministratorIPs = new List<int>();
ServerEventOccurred += EventAPI.OnServerEventOccurred;
}
public IList<Server> GetServers()

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Application.Misc
{
public class VPNCheck
{
public static async Task<bool> UsingVPN(string ip)
{
try
{
using (var RequestClient = new System.Net.Http.HttpClient())
{
string response = await RequestClient.GetStringAsync($"http://check.getipintel.net/check.php?ip={ip}&contact=raidmax@live.com");
double probability = Convert.ToDouble(response);
return probability > 0.9;
}
}
catch (Exception)
{
return false;
}
}
}
}

View File

@ -12,6 +12,8 @@ using SharedLibrary.Objects;
using System.Text.RegularExpressions;
using SharedLibrary.Services;
using SharedLibrary.Database.Models;
using SharedLibrary.Dtos;
using WebfrontCore.Application.Misc;
namespace IW4MAdmin
{
@ -58,7 +60,8 @@ namespace IW4MAdmin
}
if (polledPlayer.Name == "Unknown Soldier" ||
polledPlayer.Name == "UnknownSoldier")
polledPlayer.Name == "UnknownSoldier" ||
polledPlayer.Name == "CHEATER")
{
Logger.WriteDebug($"Kicking {polledPlayer} because their name is generic");
await this.ExecuteCommandAsync($"clientkick {polledPlayer.ClientNumber} \"Please change your name using /name.\"");
@ -139,6 +142,12 @@ namespace IW4MAdmin
await ExecuteEvent(new Event(Event.GType.Connect, "", player, null, this));
if (await VPNCheck.UsingVPN(player.IPAddressString))
{
await player.Kick("VPNs are not allowed on this server", new Player() { ClientId = 1 });
}
return true;
}
@ -217,13 +226,13 @@ namespace IW4MAdmin
if (E.Origin.Level < C.Permission)
{
await E.Origin.Tell("You do not have access to that command!");
await E.Origin.Tell("You do not have access to that command");
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} does not have access to \"{C.Name}\"");
}
if (Args.Length < (C.RequiredArgumentCount))
{
await E.Origin.Tell($"Not enough arguments supplied!");
await E.Origin.Tell($"Not enough arguments supplied");
await E.Origin.Tell(C.Syntax);
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\"");
}
@ -334,6 +343,7 @@ namespace IW4MAdmin
return;
await ProcessEvent(E);
((ApplicationManager)Manager).ServerEventOccurred(this, E);
foreach (IPlugin P in SharedLibrary.Plugins.PluginImporter.ActivePlugins)
{
@ -588,7 +598,7 @@ namespace IW4MAdmin
#if DEBUG
{
basepath.Value = (GameName == Game.IW4) ?
@"\\tsclient\J\WIN7_10.25\MW2" :
@"Z:\" :
@"\\tsclient\G\Program Files (x86)\Steam\SteamApps\common\Call of Duty 4";
}
@ -608,16 +618,16 @@ namespace IW4MAdmin
}
else
{
#if !DEBUG
//#if !DEBUG
LogFile = new IFile(logPath);
#else
//#else
}
LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
#endif
// LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
//#endif
Logger.WriteInfo($"Log file is {logPath}");
#if !DEBUG
await Broadcast("IW4M Admin is now ^2ONLINE");
}
#endif
}
@ -626,7 +636,12 @@ namespace IW4MAdmin
{
if (E.Type == Event.GType.Connect)
{
ChatHistory.Add(new Chat(E.Origin.Name, "CONNECTED", DateTime.Now));
ChatHistory.Add(new ChatInfo()
{
Name = E.Origin.Name,
Message = "CONNECTED",
Time = DateTime.UtcNow
});
if (E.Origin.Level > Player.Permission.Moderator)
await E.Origin.Tell($"There are ^5{Reports.Count} ^7recent reports");
@ -646,7 +661,12 @@ namespace IW4MAdmin
else if (E.Type == Event.GType.Disconnect)
{
ChatHistory.Add(new Chat(E.Origin.Name, "DISCONNECTED", DateTime.Now));
ChatHistory.Add(new ChatInfo()
{
Name = E.Origin.Name,
Message = "DISCONNECTED",
Time = DateTime.UtcNow
});
}
else if (E.Type == Event.GType.Script)
@ -699,7 +719,12 @@ namespace IW4MAdmin
{
E.Data = E.Data.StripColors();
ChatHistory.Add(new Chat(E.Origin.Name, E.Data, DateTime.Now));
ChatHistory.Add(new ChatInfo()
{
Name = E.Origin.Name,
Message = E.Data,
Time = DateTime.UtcNow
});
}
}

View File

@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers.API
{
[Route("api")]
public class APIController : BaseController
{
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebfrontCore.Application.API;
namespace WebfrontCore.Controllers.API
{
public class EventController : APIController
{
[HttpGet]
[Route("event")]
public ActionResult Index()
{
var events = EventAPI.Events;
var eventsDto = new List<SharedLibrary.Dtos.EventInfo>();
while (events.Count > 0)
eventsDto.Add(events.Dequeue());
return Json(eventsDto);
}
}
}

View File

@ -18,7 +18,9 @@ namespace WebfrontCore.Controllers
public override void OnActionExecuting(ActionExecutingContext context)
{
Manager = IW4MAdmin.Program.ServerManager;
Authorized = Manager.AdministratorIPs.Contains(context.HttpContext.Connection.RemoteIpAddress.ToString().ConvertToIP());
Authorized = context.HttpContext.Connection.RemoteIpAddress.ToString() == "127.0.0.1" ||
Manager.AdministratorIPs.Contains(context.HttpContext.Connection.RemoteIpAddress.ToString().ConvertToIP());
ViewBag.Authorized = Authorized;
base.OnActionExecuting(context);
}
}

View File

@ -38,12 +38,25 @@ namespace WebfrontCore.Controllers
.OrderBy(i => i)
.ToList(),
};
var meta = await MetaService.GetMeta(client.ClientId);
var penaltyMeta = await Manager.GetPenaltyService()
.ReadGetClientPenaltiesAsync(client.ClientId);
var administeredPenaltiesMeta = await Manager.GetPenaltyService()
.ReadGetClientPenaltiesAsync(client.ClientId, false);
if (client.Level > SharedLibrary.Objects.Player.Permission.Trusted)
clientDto.Meta.Add(new ProfileMeta()
{
Key = "Masked",
Value = client.Masked ? "Is" : "Is not",
Sensitive = false,
When = DateTime.MinValue
});
clientDto.Meta.AddRange(Authorized ? meta : meta.Where(m => !m.Sensitive));
clientDto.Meta.AddRange(await Manager.GetPenaltyService()
.ReadGetClientPenaltiesAsync(client.ClientId));
clientDto.Meta.AddRange(await Manager.GetPenaltyService()
.ReadGetClientPenaltiesAsync(client.ClientId, false));
clientDto.Meta.AddRange(Authorized ? penaltyMeta : penaltyMeta.Where(m => !m.Sensitive));
clientDto.Meta.AddRange(Authorized ? administeredPenaltiesMeta : penaltyMeta.Where(m => !m.Sensitive));
clientDto.Meta = clientDto.Meta
.OrderByDescending(m => m.When)
.ToList();

View File

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
namespace WebfrontCore
{
@ -11,16 +8,16 @@ namespace WebfrontCore
{
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
#if !DEBUG
.UseUrls("http://server.nbsclan.org:8080")
#else
.UseUrls("http://127.0.0.1:5000;http://192.168.88.254:5000")
#endif
.UseUrls(config["Web:Address"])
.Build();
host.Run();

View File

@ -24,7 +24,7 @@ namespace WebfrontCore
IW4MAdmin.Program.Start();
}
public IConfigurationRoot Configuration { get; }
public static IConfigurationRoot Configuration { get; private set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)

View File

@ -8,35 +8,50 @@
</div>
<div id="profile_info" class="text-center text-sm-left pr-3 pl-3">
<div id="profile_name">
@{
string displayAliasButton = Model.Aliases.Count > 0 ? "" : "display: none;";
}
<h1><span class="client-name mr-4">@Model.Name<span id="profile_aliases_btn" class="oi oi-caret-bottom pl-2 @displayAliasButton"></span></span></h1>
<div id="profile_aliases" class="pr-0 pr-sm-4 pb-2 mb-2 text-muted">
@{
foreach (string alias in Model.Aliases)
{
@alias <br />
}
<h1>
<span class="client-name mr-4">
@Model.Name
@if (Model.Aliases.Count > 0 || ViewBag.Authorized)
{
<span id="profile_aliases_btn" class="oi oi-caret-bottom pl-2"></span>
}
</div>
</div>
<div id="profile_level" class="text-muted mb-2">
<h5><span class="level-color-@Model.Level.ToLower()"><strong>@Model.Level</strong></span></h5>
</div>
<div id="profile_time_played" class="text-muted">
Played <span class="text-primary">@Model.TimePlayed</span> hours
</div>
<div id="profile_first_seen" class="text-muted">
First seen <span class="text-primary">@Model.FirstSeen</span> ago
</div>
<div id="profile_last_seen" class="text-muted">
Last seen <span class="text-primary">@Model.LastSeen</span> ago
</div>
</div>
<div id="profile_meta" class="text-center text-sm-right pt-2 mt-md-4 pt-md-3 mr-4 pr-4 mr-md-0 ml-4 pl-4 ml-md-0 pr-md-0 pl-md-0">
</span>
</h1>
<div id="profile_aliases" class="pr-0 pr-sm-4 pb-2 mb-2 text-muted">
@{
foreach (string alias in Model.Aliases)
{
@alias <br />
}
if (ViewBag.Authorized)
{
foreach (string ip in Model.IPs)
{
<a class="ip-locate-link" href="#" data-ip="@ip">@ip</a>
}
}
}
</div>
</div>
<div id="profile_level" class="text-muted mb-2">
<h5><span class="level-color-@Model.Level.ToLower()"><strong>@Model.Level</strong></span></h5>
</div>
<div id="profile_time_played" class="text-muted">
Played <span class="text-primary">@Model.TimePlayed</span> hours
</div>
<div id="profile_first_seen" class="text-muted">
First seen <span class="text-primary">@Model.FirstSeen</span> ago
</div>
<div id="profile_last_seen" class="text-muted">
Last seen <span class="text-primary">@Model.LastSeen</span> ago
</div>
</div>
<div id="profile_meta" class="text-center text-sm-right pt-2 mt-md-4 pt-md-3 mr-4 pr-4 mr-md-0 ml-4 pl-4 ml-md-0 pr-md-0 pl-md-0">
</div>
</div>
<div class="row d-md-flex pt-2">

View File

@ -35,6 +35,24 @@
</nav>
</header>
<div class="modal fade" id="mainModal" tabindex="-1" role="dialog" aria-labelledby="mainModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content bg-dark">
<div class="modal-header">
<h5 class="modal-title" id="mainModalLabel"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="container pt-0 pb-4 pl-4 pr-4">
@RenderBody()
<footer></footer>

View File

@ -8,6 +8,7 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
<assemblyBinding>
<!-- <probing privatePath="lib"/>-->
</assemblyBinding>

View File

@ -6,5 +6,8 @@
"System": "Information",
"Microsoft": "None"
}
},
"Web": {
"Address": "127.0.0.1:5000"
}
}

View File

@ -49,6 +49,19 @@ $(document).ready(function () {
}
});
/*
get ip geolocation info into modal
*/
$('.ip-locate-link').click(function (e) {
$.getJSON("http://ip-api.com/json/" + $(this).data("ip"))
.done(function (response) {
$('.modal-title').text($(this).data("ip"));
$('.modal-body').text(JSON.stringify(response, null, 4));
$('#mainModal').modal();
});
});
});
function penaltyToName(penaltyName) {