Compare commits

..

No commits in common. "release/pre" and "2023.06.10.2-prerelease" have entirely different histories.

55 changed files with 423 additions and 5905 deletions

View File

@ -1251,10 +1251,6 @@
"Alias": "Call of the Dead",
"Name": "zombie_coast"
},
{
"Alias": "Shangri-La",
"Name": "zombie_temple"
},
{
"Alias": "Moon",
"Name": "zombie_moon"

View File

@ -48,8 +48,8 @@ namespace IW4MAdmin.Application.Extensions
loggerConfig = loggerConfig.WriteTo.Console(
outputTemplate:
"[{Timestamp:HH:mm:ss} {Server} {Level:u3}] {Message:lj}{NewLine}{Exception}")
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Debug();
; //.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
//.MinimumLevel.Debug();
}
_defaultLogger = loggerConfig.CreateLogger();

View File

@ -129,7 +129,7 @@ public class BaseConfigurationHandlerV2<TConfigurationType> : IConfigurationHand
await _onIo.WaitAsync();
}
await using var fileStream = File.Create(_path);
await using var fileStream = File.OpenWrite(_path);
await JsonSerializer.SerializeAsync(fileStream, configuration, _serializerOptions);
await fileStream.DisposeAsync();
_configurationInstance = configuration;

View File

@ -432,12 +432,7 @@ namespace IW4MAdmin.Application
appConfigHandler.BuildAsync().GetAwaiter().GetResult();
var commandConfigHandler = new BaseConfigurationHandler<CommandConfiguration>("CommandConfiguration");
commandConfigHandler.BuildAsync().GetAwaiter().GetResult();
if (appConfigHandler.Configuration()?.MasterUrl == new Uri("http://api.raidmax.org:5000"))
{
appConfigHandler.Configuration().MasterUrl = new ApplicationConfiguration().MasterUrl;
}
var appConfig = appConfigHandler.Configuration();
var masterUri = Utilities.IsDevelopment
? new Uri("http://127.0.0.1:8080")

View File

@ -8,11 +8,9 @@ using Data.Abstractions;
using Data.Models;
using Microsoft.EntityFrameworkCore;
using SharedLibraryCore;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Helpers;
using SharedLibraryCore.Interfaces;
using WebfrontCore.Permissions;
using WebfrontCore.QueryHelpers.Models;
using EFClient = Data.Models.Client.EFClient;
@ -20,7 +18,6 @@ namespace IW4MAdmin.Application.QueryHelpers;
public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequest, ClientResourceResponse>
{
public ApplicationConfiguration _appConfig { get; }
private readonly IDatabaseContextFactory _contextFactory;
private readonly IGeoLocationService _geoLocationService;
@ -30,10 +27,8 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
public EFAlias Alias { get; set; }
}
public ClientResourceQueryHelper(IDatabaseContextFactory contextFactory, IGeoLocationService geoLocationService,
ApplicationConfiguration appConfig)
public ClientResourceQueryHelper(IDatabaseContextFactory contextFactory, IGeoLocationService geoLocationService)
{
_appConfig = appConfig;
_contextFactory = contextFactory;
_geoLocationService = geoLocationService;
}
@ -80,9 +75,7 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
if (!string.IsNullOrWhiteSpace(query.ClientIp))
{
clientAliases = SearchByIp(query, clientAliases,
_appConfig.HasPermission(query.RequesterPermission, WebfrontEntity.ClientIPAddress,
WebfrontPermission.Read));
clientAliases = SearchByIp(query, clientAliases);
}
var iqGroupedClientAliases = clientAliases.GroupBy(a => new { a.Client.ClientId, a.Client.LastConnection });
@ -210,7 +203,7 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
}
private static IQueryable<ClientAlias> SearchByIp(ClientResourceRequest query,
IQueryable<ClientAlias> clientAliases, bool canSearchIP)
IQueryable<ClientAlias> clientAliases)
{
var ipString = query.ClientIp.Trim();
var ipAddress = ipString.ConvertToIP();
@ -220,7 +213,7 @@ public class ClientResourceQueryHelper : IResourceQueryHelper<ClientResourceRequ
clientAliases = clientAliases.Where(clientAlias =>
clientAlias.Alias.IPAddress != null && clientAlias.Alias.IPAddress == ipAddress);
}
else if(canSearchIP)
else
{
clientAliases = clientAliases.Where(clientAlias =>
EF.Functions.Like(clientAlias.Alias.SearchableIPAddress, $"{ipString}%"));

View File

@ -194,14 +194,10 @@ namespace IW4MAdmin.Application.RConParsers
foreach (var line in response)
{
var regex = Regex.Match(line, parserRegex.Pattern);
if (!regex.Success || !parserRegex.GroupMapping.ContainsKey(groupType))
if (regex.Success && parserRegex.GroupMapping.ContainsKey(groupType))
{
continue;
value = regex.Groups[parserRegex.GroupMapping[groupType]].ToString();
}
value = regex.Groups[parserRegex.GroupMapping[groupType]].ToString();
break;
}
if (value == null)
@ -308,7 +304,7 @@ namespace IW4MAdmin.Application.RConParsers
{
networkIdString = match.Values[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]];
networkId = networkIdString.IsBotGuid() || (ip == null && ping is 999 or 0) ?
networkId = networkIdString.IsBotGuid() || (ip == null && ping == 999) ?
name.GenerateGuidFromString() :
networkIdString.ConvertGuidToLong(Configuration.GuidNumberStyle);
}

View File

@ -153,8 +153,6 @@ namespace Data.Context
modelBuilder.Entity<EFClientConnectionHistory>(ent => ent.HasIndex(history => history.CreatedDateTime));
modelBuilder.Entity<EFServerSnapshot>(ent => ent.HasIndex(snapshot => snapshot.CapturedAt));
// force full name for database conversion
modelBuilder.Entity<EFClient>().ToTable("EFClients");
modelBuilder.Entity<EFAlias>().ToTable("EFAlias");

View File

@ -1,24 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.Migrations.MySql
{
public partial class AddIndexToEFServerSnapshotCapturedAt : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_EFServerSnapshot_CapturedAt",
table: "EFServerSnapshot",
column: "CapturedAt");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFServerSnapshot_CapturedAt",
table: "EFServerSnapshot");
}
}
}

View File

@ -814,7 +814,6 @@ namespace Data.Migrations.MySql
b.Property<string>("SearchableIPAddress")
.ValueGeneratedOnAddOrUpdate()
.HasMaxLength(255)
.HasColumnType("varchar(255)")
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
@ -1111,8 +1110,6 @@ namespace Data.Migrations.MySql
b.HasKey("ServerSnapshotId");
b.HasIndex("CapturedAt");
b.HasIndex("MapId");
b.HasIndex("ServerId");

View File

@ -1,52 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.Migrations.Postgresql
{
public partial class AddIndexToEFServerSnapshotCapturedAt : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "SearchableIPAddress",
table: "EFAlias",
type: "character varying(255)",
maxLength: 255,
nullable: true,
computedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
stored: true,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true,
oldComputedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
oldStored: true);
migrationBuilder.CreateIndex(
name: "IX_EFServerSnapshot_CapturedAt",
table: "EFServerSnapshot",
column: "CapturedAt");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFServerSnapshot_CapturedAt",
table: "EFServerSnapshot");
migrationBuilder.AlterColumn<string>(
name: "SearchableIPAddress",
table: "EFAlias",
type: "text",
nullable: true,
computedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
stored: true,
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComputedColumnSql: "((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)",
oldStored: true);
}
}
}

View File

@ -853,8 +853,7 @@ namespace Data.Migrations.Postgresql
b.Property<string>("SearchableIPAddress")
.ValueGeneratedOnAddOrUpdate()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnType("text")
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
b.Property<string>("SearchableName")
@ -1164,8 +1163,6 @@ namespace Data.Migrations.Postgresql
b.HasKey("ServerSnapshotId");
b.HasIndex("CapturedAt");
b.HasIndex("MapId");
b.HasIndex("ServerId");

View File

@ -1,24 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.Migrations.Sqlite
{
public partial class AddIndexToEFServerSnapshotCapturedAt : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_EFServerSnapshot_CapturedAt",
table: "EFServerSnapshot",
column: "CapturedAt");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_EFServerSnapshot_CapturedAt",
table: "EFServerSnapshot");
}
}
}

View File

@ -812,7 +812,6 @@ namespace Data.Migrations.Sqlite
b.Property<string>("SearchableIPAddress")
.ValueGeneratedOnAddOrUpdate()
.HasMaxLength(255)
.HasColumnType("TEXT")
.HasComputedColumnSql("((IPAddress & 255) || '.' || ((IPAddress >> 8) & 255)) || '.' || ((IPAddress >> 16) & 255) || '.' || ((IPAddress >> 24) & 255)", true);
@ -1109,8 +1108,6 @@ namespace Data.Migrations.Sqlite
b.HasKey("ServerSnapshotId");
b.HasIndex("CapturedAt");
b.HasIndex("MapId");
b.HasIndex("ServerId");

View File

@ -16,8 +16,7 @@
T7 = 8,
SHG1 = 9,
CSGO = 10,
H1 = 11,
L4D2 = 12,
H1 = 11
}
public enum ConnectionType

View File

@ -8,7 +8,7 @@ Init()
Setup()
{
level endon( "game_ended" );
// setup default vars
level.eventBus = spawnstruct();
level.eventBus.inVar = "sv_iw4madmin_in";
@ -16,7 +16,7 @@ Setup()
level.eventBus.failKey = "fail";
level.eventBus.timeoutKey = "timeout";
level.eventBus.timeout = 30;
level.commonFunctions = spawnstruct();
level.commonFunctions.setDvar = "SetDvarIfUninitialized";
level.commonFunctions.getPlayerFromClientNum = "GetPlayerFromClientNum";
@ -46,12 +46,12 @@ Setup()
level.commonKeys.busDir = "sv_iw4madmin_integration_busdir";
level.eventBus.inLocation = "";
level.eventBus.outLocation = "";
level.notifyTypes = spawnstruct();
level.notifyTypes.gameFunctionsInitialized = "GameFunctionsInitialized";
level.notifyTypes.sharedFunctionsInitialized = "SharedFunctionsInitialized";
level.notifyTypes.integrationBootstrapInitialized = "IntegrationBootstrapInitialized";
level.clientDataKey = "clientData";
level.eventTypes = spawnstruct();
@ -61,9 +61,9 @@ Setup()
level.eventTypes.setClientDataRequested = "SetClientDataRequested";
level.eventTypes.setClientDataCompleted = "SetClientDataCompleted";
level.eventTypes.executeCommandRequested = "ExecuteCommandRequested";
level.iw4madminIntegrationDebug = 0;
// map the event type to the handler
level.eventCallbacks = [];
level.eventCallbacks[level.eventTypes.clientDataReceived] = ::OnClientDataReceived;
@ -76,14 +76,14 @@ Setup()
level.iw4madminIntegrationDebug = GetDvarInt( "sv_iw4madmin_integration_debug" );
InitializeLogger();
wait ( 0.05 * 2 ); // needed to give script engine time to propagate notifies
level notify( level.notifyTypes.integrationBootstrapInitialized );
level waittill( level.notifyTypes.gameFunctionsInitialized );
LogDebug( "Integration received notify that game functions are initialized" );
_SetDvarIfUninitialized( level.eventBus.inVar, "" );
_SetDvarIfUninitialized( level.eventBus.outVar, "" );
_SetDvarIfUninitialized( level.commonKeys.enabled, 1 );
@ -93,12 +93,12 @@ Setup()
_SetDvarIfUninitialized( "GroupSeparatorChar", "" );
_SetDvarIfUninitialized( "RecordSeparatorChar", "" );
_SetDvarIfUninitialized( "UnitSeparatorChar", "" );
if ( GetDvarInt( level.commonKeys.enabled ) != 1 )
{
return;
}
// start long running tasks
thread MonitorEvents();
thread MonitorBus();
@ -113,7 +113,7 @@ MonitorEvents()
level waittill( level.eventTypes.eventAvailable, event );
LogDebug( "Processing Event " + event.type + "-" + event.subtype );
eventHandler = level.eventCallbacks[event.type];
if ( IsDefined( eventHandler ) )
@ -161,13 +161,11 @@ _SetDvarIfUninitialized( dvarName, dvarValue )
_GetPlayerFromClientNum( clientNum )
{
assertEx( clientNum >= 0, "clientNum cannot be negative" );
if ( clientNum < 0 )
{
return undefined;
}
for ( i = 0; i < level.players.size; i++ )
{
if ( level.players[i] getEntityNumber() == clientNum )
@ -331,7 +329,7 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
{
data = "";
}
if ( !IsDefined( eventSubtype ) )
{
eventSubtype = "None";
@ -346,9 +344,9 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
{
entOrId = entOrId getEntityNumber();
}
request = "0";
if ( responseExpected )
{
request = "1";
@ -357,14 +355,14 @@ BuildEventRequest( responseExpected, eventType, eventSubtype, entOrId, data )
data = BuildDataString( data );
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
request = request + groupSeparator + eventType + groupSeparator + eventSubtype + groupSeparator + entOrId + groupSeparator + data;
return request;
}
MonitorBus()
{
level endon( level.eventTypes.gameEnd );
level.eventBus.inLocation = level.eventBus.inVar + "_" + GetDvar( "net_port" );
level.eventBus.outLocation = level.eventBus.outVar + "_" + GetDvar( "net_port" );
@ -374,7 +372,7 @@ MonitorBus()
for( ;; )
{
wait ( 0.1 );
// check to see if IW4MAdmin is ready to receive more data
inVal = [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation );
@ -382,19 +380,19 @@ MonitorBus()
{
level notify( "bus_ready" );
}
eventString = [[level.busMethods[level.commonFunctions.getOutboundData]]]( level.eventBus.outLocation );
if ( !IsDefined( eventString ) || eventString == "" )
{
continue;
}
LogDebug( "-> " + eventString );
groupSeparator = GetSubStr( GetDvar( "GroupSeparatorChar" ), 0, 1 );
NotifyEvent( strtok( eventString, groupSeparator ) );
[[level.busMethods[level.commonFunctions.SetOutboundData]]]( level.eventBus.outLocation, "" );
}
}
@ -406,7 +404,7 @@ QueueEvent( request, eventType, notifyEntity )
start = GetTime();
maxWait = level.eventBus.timeout * 1000; // 30 seconds
timedOut = "";
while ( [[level.busMethods[level.commonFunctions.getInboundData]]]( level.eventBus.inLocation ) != "" && ( GetTime() - start ) < maxWait )
{
level [[level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout]]]( "bus_ready", 1 );
@ -417,10 +415,10 @@ QueueEvent( request, eventType, notifyEntity )
timedOut = "set";
continue;
}
timedOut = "unset";
}
if ( timedOut == "set" )
{
LogDebug( "Timed out waiting for response..." );
@ -434,9 +432,9 @@ QueueEvent( request, eventType, notifyEntity )
return;
}
LogDebug( "<- " + request );
[[level.busMethods[level.commonFunctions.setInboundData]]]( level.eventBus.inLocation, request );
}
@ -447,10 +445,10 @@ ParseDataString( data )
LogDebug( "No data to parse" );
return [];
}
dataParts = strtok( data, GetSubStr( GetDvar( "RecordSeparatorChar" ), 0, 1 ) );
dict = [];
for ( i = 0; i < dataParts.size; i++ )
{
part = dataParts[i];
@ -460,7 +458,7 @@ ParseDataString( data )
dict[key] = value;
dict[i] = key;
}
return dict;
}
@ -497,14 +495,14 @@ NotifyEvent( eventInfo )
{
origin = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[3] ) );
target = [[level.overrideMethods[level.commonFunctions.getPlayerFromClientNum]]]( int( eventInfo[4] ) );
event = spawnstruct();
event.type = eventInfo[1];
event.subtype = eventInfo[2];
event.data = ParseDataString( eventInfo[5] );
event.origin = origin;
event.target = target;
if ( int( eventInfo[3] ) != -1 && !IsDefined( origin ) )
{
LogDebug( "origin is null but the slot id is " + int( eventInfo[3] ) );
@ -531,7 +529,7 @@ AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
{
return;
}
level.clientCommandCallbacks[commandName] = callback;
level.clientCommandRusAsTarget[commandName] = shouldRunAsTarget == true; //might speed up things later in case someone gives us a string or number instead of a boolean
}
@ -542,7 +540,6 @@ AddClientCommand( commandName, shouldRunAsTarget, callback, shouldOverwrite )
OnClientDataReceived( event )
{
assertEx( isDefined( self ), "player entity is not defined");
clientData = self.pers[level.clientDataKey];
if ( event.subtype == "Fail" )
@ -558,15 +555,15 @@ OnClientDataReceived( event )
{
clientData.meta = [];
}
metaKey = event.data[0];
clientData.meta[metaKey] = event.data[metaKey];
LogDebug( "Meta Key=" + CoerceUndefined( metaKey ) + ", Meta Value=" + CoerceUndefined( event.data[metaKey] ) );
return;
}
clientData.permissionLevel = event.data["level"];
clientData.clientId = event.data["clientId"];
clientData.lastConnection = event.data["lastConnection"];
@ -580,7 +577,7 @@ OnExecuteCommand( event )
{
data = event.data;
response = "";
command = level.clientCommandCallbacks[event.subtype];
runAsTarget = level.clientCommandRusAsTarget[event.subtype];
executionContextEntity = event.origin;
@ -589,7 +586,7 @@ OnExecuteCommand( event )
{
executionContextEntity = event.target;
}
if ( IsDefined( command ) )
{
if ( IsDefined( executionContextEntity ) )
@ -605,7 +602,7 @@ OnExecuteCommand( event )
{
LogDebug( "Unknown Client command->" + event.subtype );
}
// send back the response to the origin, but only if they're not the target
if ( IsDefined( response ) && response != "" && IsPlayer( event.origin ) && event.origin != event.target )
{

View File

@ -37,8 +37,6 @@ Setup()
RegisterClientCommands();
level notify( level.notifyTypes.gameFunctionsInitialized );
scripts\_integration_base::_SetDvarIfUninitialized( level.commonKeys.busdir, GetDvar( "fs_homepath" ) + "userraw/" + "scriptdata" );
if ( GetDvarInt( level.commonKeys.enabled ) != 1 )
{

View File

@ -1,7 +1,5 @@
#include common_scripts\utility;
#inline scripts\_integration_utility;
Init()
{
thread Setup();
@ -11,12 +9,12 @@ Setup()
{
level endon( "game_ended" );
waittillframeend;
level waittill( level.notifyTypes.sharedFunctionsInitialized );
level.eventBus.gamename = "IW5";
scripts\_integration_base::RegisterLogger( ::Log2Console );
level.overrideMethods[level.commonFunctions.getTotalShotsFired] = ::GetTotalShotsFired;
level.overrideMethods[level.commonFunctions.setDvar] = ::SetDvarIfUninitializedWrapper;
level.overrideMethods[level.commonFunctions.waittillNotifyOrTimeout] = ::WaitillNotifyOrTimeoutWrapper;
@ -24,7 +22,7 @@ Setup()
level.overrideMethods[level.commonFunctions.getXuid] = ::GetXuidWrapper;
level.overrideMethods[level.commonFunctions.waitTillAnyTimeout] = ::WaitTillAnyTimeout;
RegisterClientCommands();
level notify( level.notifyTypes.gameFunctionsInitialized );
}
@ -84,36 +82,45 @@ WaitTillAnyTimeout( timeOut, string1, string2, string3, string4, string5 )
GiveWeaponImpl( event, data )
{
_IS_ALIVE( self );
if ( !IsAlive( self ) )
{
return self.name + "^7 is not alive";
}
self IPrintLnBold( "You have been given a new weapon" );
self GiveWeapon( data["weaponName"] );
self SwitchToWeapon( data["weaponName"] );
return self.name + "^7 has been given ^5" + data["weaponName"];
}
TakeWeaponsImpl()
{
_IS_ALIVE( self );
if ( !IsAlive( self ) )
{
return self.name + "^7 is not alive";
}
self TakeAllWeapons();
self IPrintLnBold( "All your weapons have been taken" );
return "Took weapons from " + self.name;
}
TeamSwitchImpl()
{
_IS_ALIVE( self );
if ( !IsAlive( self ) )
{
return self + "^7 is not alive";
}
team = level.allies;
if ( self.team == "allies" )
{
team = level.axis;
}
self IPrintLnBold( "You are being team switched" );
wait( 2 );
self [[team]]();
@ -123,7 +130,10 @@ TeamSwitchImpl()
LockControlsImpl()
{
_IS_ALIVE( self );
if ( !IsAlive( self ) )
{
return self.name + "^7 is not alive";
}
if ( !IsDefined ( self.isControlLocked ) )
{
@ -139,11 +149,11 @@ LockControlsImpl()
info = [];
info[ "alertType" ] = "Alert!";
info[ "message" ] = "You have been frozen!";
self AlertImpl( undefined, info );
self.isControlLocked = true;
return self.name + "\'s controls are locked";
}
else
@ -160,13 +170,11 @@ LockControlsImpl()
NoClipImpl()
{
_VERIFY_PLAYER_ENT( self );
if ( !IsAlive( self ) )
{
self IPrintLnBold( "You are not alive" );
}
if ( !IsDefined ( self.isNoClipped ) )
{
self.isNoClipped = false;
@ -176,29 +184,29 @@ NoClipImpl()
{
SetDvar( "sv_cheats", 1 );
self SetClientDvar( "cg_thirdperson", 1 );
self God();
self Noclip();
self Hide();
SetDvar( "sv_cheats", 0 );
self.isNoClipped = true;
self IPrintLnBold( "NoClip enabled" );
}
else
{
SetDvar( "sv_cheats", 1 );
self SetClientDvar( "cg_thirdperson", 0 );
self God();
self Noclip();
self Hide();
SetDvar( "sv_cheats", 0 );
self.isNoClipped = false;
self IPrintLnBold( "NoClip disabled" );
}
@ -207,13 +215,12 @@ NoClipImpl()
HideImpl()
{
_VERIFY_PLAYER_ENT( self );
if ( !IsAlive( self ) )
{
self IPrintLnBold( "You are not alive" );
return;
}
if ( !IsDefined ( self.isHidden ) )
{
self.isHidden = false;
@ -223,26 +230,26 @@ HideImpl()
{
SetDvar( "sv_cheats", 1 );
self SetClientDvar( "cg_thirdperson", 1 );
self God();
self Hide();
SetDvar( "sv_cheats", 0 );
self.isHidden = true;
self IPrintLnBold( "Hide enabled" );
}
else
{
SetDvar( "sv_cheats", 1 );
self SetClientDvar( "cg_thirdperson", 0 );
self God();
self Show();
SetDvar( "sv_cheats", 0 );
self.isHidden = false;
self IPrintLnBold( "Hide disabled" );
}
}
@ -267,8 +274,6 @@ GotoImpl( event, data )
GotoCoordImpl( data )
{
_VERIFY_PLAYER_ENT( self );
if ( !IsAlive( self ) )
{
self IPrintLnBold( "You are not alive" );
@ -282,8 +287,6 @@ GotoCoordImpl( data )
GotoPlayerImpl( target )
{
_VERIFY_PLAYER_ENT( self );
if ( !IsAlive( target ) )
{
self IPrintLnBold( target.name + " is not alive" );
@ -296,7 +299,10 @@ GotoPlayerImpl( target )
PlayerToMeImpl( event )
{
_IS_ALIVE( self );
if ( !IsAlive( self ) )
{
return self.name + " is not alive";
}
self SetOrigin( event.origin GetOrigin() );
return "Moved here " + self.name;
@ -304,7 +310,10 @@ PlayerToMeImpl( event )
KillImpl()
{
_IS_ALIVE( self );
if ( !IsAlive( self ) )
{
return self.name + " is not alive";
}
self Suicide();
self IPrintLnBold( "You were killed by " + self.name );
@ -314,15 +323,13 @@ KillImpl()
SetSpectatorImpl()
{
_VERIFY_PLAYER_ENT( self );
if ( self.pers["team"] == "spectator" )
{
return self.name + " is already spectating";
}
self [[level.spectator]]();
self IPrintLnBold( "You have been moved to spectator" );
return self.name + " has been moved to spectator";
}

View File

@ -212,7 +212,7 @@ OnBusModeRequestedCallback( event )
scripts\_integration_base::LogDebug( "Bus mode updated" );
if ( GetDvar( level.commonKeys.busMode ) == "file" && GetDvar( level.commonKeys.busDir ) != "" )
if ( GetDvar( level.commonKeys.busMode ) == "file" || GetDvar( level.commonKeys.busDir ) != "" )
{
level.busMethods[level.commonFunctions.getInboundData] = level.overrideMethods[level.commonFunctions.getInboundData];
level.busMethods[level.commonFunctions.getOutboundData] = level.overrideMethods[level.commonFunctions.getOutboundData];

View File

@ -88,7 +88,7 @@ IsBotWrapper( client )
GetXuidWrapper()
{
return self GetGuid();
return self GetXUID();
}
//////////////////////////////////

View File

@ -1,73 +0,0 @@
/*********************************************************************************
* DISCLAIMER: *
* *
* This script is optional and not required for *
* standard functionality. To use this script, a third-party *
* plugin named "t6-gsc-utils" must be installed on the *
* game server in the "*\storage\t6\plugins" folder *
* *
* The "t6-gsc-utils" plugin can be obtained from the GitHub *
* repository at: *
* https://github.com/fedddddd/t6-gsc-utils *
* *
* Please make sure to install the plugin before running this *
* script. *
*********************************************************************************/
/*********************************************************************************
* FUNCTIONALITY: *
* *
* This script extends the game interface to support the "file" *
* bus mode for Plutonium T6, which allows the game server and IW4M-Admin *
* to communicate via files, rather than over rcon using *
* dvars. *
* *
* By enabling the "file" bus mode, IW4M-Admin can send *
* commands and receive responses from the game server by *
* reading and writing to specific files. This provides a *
* flexible and efficient communication channel. *
* *
* Make sure to configure the server to use the "file" bus *
* mode and set the appropriate file path to *
* establish the communication between IW4M-Admin and the *
* game server. *
* *
* The wiki page for the setup of the game interface, and the bus mode *
* can be found on GitHub at: *
* https://github.com/RaidMax/IW4M-Admin/wiki/GameInterface#configuring-bus-mode *
*********************************************************************************/
Init()
{
thread Setup();
}
Setup()
{
level waittill( level.notifyTypes.sharedFunctionsInitialized );
level.overrideMethods[level.commonFunctions.getInboundData] = ::GetInboundData;
level.overrideMethods[level.commonFunctions.getOutboundData] = ::GetOutboundData;
level.overrideMethods[level.commonFunctions.setInboundData] = ::SetInboundData;
level.overrideMethods[level.commonFunctions.setOutboundData] = ::SetOutboundData;
scripts\_integration_base::_SetDvarIfUninitialized( level.commonKeys.busdir, GetDvar( "fs_homepath" ) );
}
GetInboundData( location )
{
return readFile( location );
}
GetOutboundData( location )
{
return readFile( location );
}
SetInboundData( location, data )
{
writeFile( location, data );
}
SetOutboundData( location, data )
{
writeFile( location, data );
}

View File

@ -1,40 +0,0 @@
/*
* This file contains reusable preprocessor directives meant to be used on
* Plutonium & AlterWare clients that are up to date with the latest version.
* Older versions of Plutonium or other clients do not have support for loading
* or parsing "gsh" files.
*/
/*
* Turn off assertions by removing the following define
* gsc-tool will only emit assertions if developer_script dvar is set to 1
* In short, you should not need to remove this define. Just turn them off
* by using the dvar
*/
#define _INTEGRATION_DEBUG
#ifdef _INTEGRATION_DEBUG
#define _VERIFY( cond, msg ) \
assertEx( cond, msg )
#else
// This works as an "empty" define here with gsc-tool
#define _VERIFY( cond, msg )
#endif
// This function is meant to be used inside "client commands"
// If the client is not alive it shall return an error message
#define _IS_ALIVE( ent ) \
_VERIFY( ent, "player entity is not defined" ); \
if ( !IsAlive( ent ) ) \
{ \
return ent.name + "^7 is not alive"; \
}
// This function should be used to verify if a player entity is defined
#define _VERIFY_PLAYER_ENT( ent ) \
_VERIFY( ent, "player entity is not defined" )

View File

@ -3,7 +3,14 @@
Allows integration of IW4M-Admin to GSC, mainly used for special commands that need to use GSC in order to work.
But can also be used to read / write metadata from / to a profile and to get the player permission level.
## Installation Guide
## Installation Plutonium IW5
The documentation can be found here: [GameInterface](https://github.com/RaidMax/IW4M-Admin/wiki/GameInterface)
Move `_integration.gsc` to `%localappdata%\Plutonium\storage\iw5\scripts\`
## Installation IW4x
Move `_integration.gsc` to `IW4x/userraw/scripts`, `IW4x` being the root folder of your game server.

View File

@ -4,7 +4,6 @@ ECHO "Pluto IW5"
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
xcopy /y .\GameInterface\_integration_iw5.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
xcopy /y .\GameInterface\_integration_utility.gsh "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts"
xcopy /y .\AntiCheat\IW5\storage\iw5\scripts\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\iw5\scripts\mp"
ECHO "Pluto T5"
@ -14,8 +13,8 @@ xcopy /y .\GameInterface\_integration_t5.gsc "%LOCALAPPDATA%\Plutonium\storage\t
xcopy /y .\GameInterface\_integration_t5zm.gsc "%LOCALAPPDATA%\Plutonium\storage\t5\scripts\sp\zom"
ECHO "Pluto T6"
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"
xcopy /y .\GameInterface\_integration_base.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
xcopy /y .\GameInterface\_integration_shared.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
xcopy /y .\GameInterface\_integration_t6.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts"
xcopy /y .\GameInterface\_integration_t6zm_helper.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\zm"
xcopy /y .\AntiCheat\PT6\storage\t6\scripts\mp\_customcallbacks.gsc "%LOCALAPPDATA%\Plutonium\storage\t6\scripts\mp"

View File

@ -53,7 +53,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlug
Plugins\ScriptPlugins\ParserPlutoniumT5.js = Plugins\ScriptPlugins\ParserPlutoniumT5.js
Plugins\ScriptPlugins\ServerBanner.js = Plugins\ScriptPlugins\ServerBanner.js
Plugins\ScriptPlugins\ParserBOIII.js = Plugins\ScriptPlugins\ParserBOIII.js
Plugins\ScriptPlugins\ParserL4D2SM.js = Plugins\ScriptPlugins\ParserL4D2SM.js
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomessageFeed", "Plugins\AutomessageFeed\AutomessageFeed.csproj", "{F5815359-CFC7-44B4-9A3B-C04BACAD5836}"
@ -88,7 +87,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GameInterface", "GameInterf
GameFiles\GameInterface\_integration_t6.gsc = GameFiles\GameInterface\_integration_t6.gsc
GameFiles\GameInterface\_integration_t6zm_helper.gsc = GameFiles\GameInterface\_integration_t6zm_helper.gsc
GameFiles\GameInterface\example_module.gsc = GameFiles\GameInterface\example_module.gsc
GameFiles\GameInterface\_integration_t6_file_bus.gsc = GameFiles\GameInterface\_integration_t6_file_bus.gsc
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AntiCheat", "AntiCheat", "{AB83BAC0-C539-424A-BF00-78487C10753C}"

View File

@ -8,7 +8,6 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Integrations.Cod.SecureRcon;
using Microsoft.Extensions.Logging;
using Serilog.Context;
using SharedLibraryCore;
@ -25,7 +24,6 @@ namespace Integrations.Cod
public class CodRConConnection : IRConConnection
{
private static readonly ConcurrentDictionary<EndPoint, ConnectionState> ActiveQueries = new();
private const string PkPattern = "-----BEGIN PRIVATE KEY-----";
public IPEndPoint Endpoint { get; }
public string RConPassword { get; }
@ -149,33 +147,49 @@ namespace Integrations.Cod
{
var convertedRConPassword = ConvertEncoding(RConPassword);
var convertedParameters = ConvertEncoding(parameters);
byte SafeConversion(char c)
{
try
{
return Convert.ToByte(c);
}
catch
{
return (byte)'.';
}
};
switch (type)
{
case StaticHelpers.QueryType.GET_DVAR:
waitForResponse = true;
payload = BuildPayload(_config.CommandPrefixes.RConGetDvar, convertedRConPassword,
convertedParameters);
payload = string
.Format(_config.CommandPrefixes.RConGetDvar, convertedRConPassword,
convertedParameters + '\0').Select(SafeConversion).ToArray();
break;
case StaticHelpers.QueryType.SET_DVAR:
payload = BuildPayload(_config.CommandPrefixes.RConSetDvar, convertedRConPassword,
convertedParameters);
payload = string
.Format(_config.CommandPrefixes.RConSetDvar, convertedRConPassword,
convertedParameters + '\0').Select(SafeConversion).ToArray();
break;
case StaticHelpers.QueryType.COMMAND:
payload = BuildPayload(_config.CommandPrefixes.RConCommand, convertedRConPassword,
convertedParameters);
payload = string
.Format(_config.CommandPrefixes.RConCommand, convertedRConPassword,
convertedParameters + '\0').Select(SafeConversion).ToArray();
break;
case StaticHelpers.QueryType.GET_STATUS:
waitForResponse = true;
payload = (_config.CommandPrefixes.RConGetStatus + '\0').Select(Helpers.SafeConversion).ToArray();
payload = (_config.CommandPrefixes.RConGetStatus + '\0').Select(SafeConversion).ToArray();
break;
case StaticHelpers.QueryType.GET_INFO:
waitForResponse = true;
payload = (_config.CommandPrefixes.RConGetInfo + '\0').Select(Helpers.SafeConversion).ToArray();
payload = (_config.CommandPrefixes.RConGetInfo + '\0').Select(SafeConversion).ToArray();
break;
case StaticHelpers.QueryType.COMMAND_STATUS:
waitForResponse = true;
payload = BuildPayload(_config.CommandPrefixes.RConCommand, convertedRConPassword, "status");
payload = string.Format(_config.CommandPrefixes.RConCommand, convertedRConPassword, "status\0")
.Select(SafeConversion).ToArray();
break;
}
}
@ -320,27 +334,6 @@ namespace Integrations.Cod
return validatedResponse;
}
private byte[] BuildPayload(string queryTemplate, string convertedRConPassword, string convertedParameters)
{
byte[] payload;
if (!RConPassword.StartsWith(PkPattern))
{
payload = string
.Format(queryTemplate, convertedRConPassword,
convertedParameters + '\0').Select(Helpers.SafeConversion).ToArray();
}
else
{
var textContent = string
.Format(queryTemplate, "", convertedParameters)
.Replace("rcon", "rconSafe ")
.Replace(" ", "").Split(" ");
payload = Helpers.BuildSafeRconPayload(textContent[0], textContent[1], RConPassword);
}
return payload;
}
private async Task<byte[][]> SendPayloadAsync(Socket rconSocket, byte[] payload, bool waitForResponse,
CancellationToken token = default)
{
@ -487,7 +480,7 @@ namespace Integrations.Cod
return string.Join("", splitStatusStrings);
}
/// <summary>
/// Recombines multiple game messages into one
/// </summary>
@ -520,7 +513,7 @@ namespace Integrations.Cod
{
return connectionState.ReceivedBytes.ToArray();
}
#endregion
}
}

View File

@ -16,8 +16,4 @@
<ProjectReference Include="..\..\SharedLibraryCore\SharedLibraryCore.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="protobuf-net" Version="3.2.26" />
</ItemGroup>
</Project>

View File

@ -1,57 +0,0 @@
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using ProtoBuf;
namespace Integrations.Cod.SecureRcon;
public static class Helpers
{
private static byte[] ToSerializedMessage(this SecureCommand command)
{
using var ms = new MemoryStream();
Serializer.Serialize(ms, command);
return ms.ToArray();
}
private static byte[] SignData(byte[] data, string privateKey)
{
using var rsa = new RSACryptoServiceProvider();
rsa.ImportFromPem(privateKey);
var rsaFormatter = new RSAPKCS1SignatureFormatter(rsa);
rsaFormatter.SetHashAlgorithm("SHA512");
var hash = SHA512.Create();
var hashedData = hash.ComputeHash(data);
var signature = rsaFormatter.CreateSignature(hashedData);
return signature;
}
public static byte SafeConversion(char c)
{
try
{
return Convert.ToByte(c);
}
catch
{
return (byte)'.';
}
}
public static byte[] BuildSafeRconPayload(string prefix, string command, string signingKey)
{
var message = command.Select(SafeConversion).ToArray();
var header = (prefix + "\n").Select(SafeConversion).ToArray();
var secureCommand = new SecureCommand
{
SecMessage = message,
Signature = SignData(message, signingKey)
};
return header.Concat(secureCommand.ToSerializedMessage()).ToArray();
}
}

View File

@ -1,13 +0,0 @@
using ProtoBuf;
namespace Integrations.Cod.SecureRcon;
[ProtoContract]
public class SecureCommand
{
[ProtoMember(1)]
public byte[] SecMessage { get; set; }
[ProtoMember(2)]
public byte[] Signature { get; set; }
}

View File

@ -104,7 +104,7 @@ namespace Integrations.Source
}
var split = response.TrimEnd('\n').Split('\n');
return split.Take(Math.Max(1, split.Length - 1)).ToArray();
return split.Take(split.Length - 1).ToArray();
}
catch (TaskCanceledException)

View File

@ -22,10 +22,10 @@ const plugin = {
rconParser.Configuration.MapStatus.AddMapping(111, 1);
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
rconParser.Configuration.HostnameStatus.AddMapping(113, 1);
rconParser.Configuration.MapStatus.AddMapping(113, 1);
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
rconParser.Configuration.MaxPlayersStatus.AddMapping(114, 1);
rconParser.Configuration.MapStatus.AddMapping(114, 1);
rconParser.Configuration.Dvar.Pattern = '^"(.+)" = "(.+)" (?:\\( def. "(.*)" \\))?(?: |\\w)+- (.+)$';
rconParser.Configuration.Dvar.AddMapping(106, 1);

View File

@ -3,7 +3,7 @@ let eventParser;
const plugin = {
author: 'RaidMax',
version: 0.7,
version: 0.6,
name: 'CS:GO (SourceMod) Parser',
engine: 'Source',
isParser: true,
@ -22,10 +22,10 @@ const plugin = {
rconParser.Configuration.MapStatus.AddMapping(111, 1);
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
rconParser.Configuration.HostnameStatus.AddMapping(113, 1);
rconParser.Configuration.MapStatus.AddMapping(113, 1);
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
rconParser.Configuration.MaxPlayersStatus.AddMapping(114, 1);
rconParser.Configuration.MapStatus.AddMapping(114, 1);
rconParser.Configuration.Dvar.Pattern = '^"(.+)" = "(.+)" (?:\\( def. "(.*)" \\))?(?: |\\w)+- (.+)$';
rconParser.Configuration.Dvar.AddMapping(106, 1);

View File

@ -1,135 +0,0 @@
let rconParser;
let eventParser;
const plugin = {
author: 'RaidMax',
version: 0.1,
name: 'L4D2 (SourceMod) Parser',
engine: 'Source',
isParser: true,
onEventAsync: function (gameEvent, server) {
},
onLoadAsync: function (manager) {
rconParser = manager.GenerateDynamicRConParser(this.name);
eventParser = manager.GenerateDynamicEventParser(this.name);
rconParser.RConEngine = this.engine;
rconParser.Configuration.StatusHeader.Pattern = '# userid name uniqueid connected ping loss state rate adr';
rconParser.Configuration.MapStatus.Pattern = '^map *: +(.+)$';
rconParser.Configuration.MapStatus.AddMapping(111, 1);
rconParser.Configuration.HostnameStatus.Pattern = '^hostname: +(.+)$';
rconParser.Configuration.HostnameStatus.AddMapping(113, 1);
rconParser.Configuration.MaxPlayersStatus.Pattern = '^players *: +\\d+ humans, \\d+ bots \\((\\d+).+';
rconParser.Configuration.MaxPlayersStatus.AddMapping(114, 1);
rconParser.Configuration.Dvar.Pattern = '^\\"(.+)\\" (?:=|is) \\"(.+)\\"(?: (?:\\( def. \\"(.*)\\" \\)))?$';
rconParser.Configuration.Dvar.AddMapping(106, 1);
rconParser.Configuration.Dvar.AddMapping(107, 2);
rconParser.Configuration.Dvar.AddMapping(108, 3);
rconParser.Configuration.Dvar.AddMapping(109, 3);
rconParser.Configuration.Status.Pattern = '^#\\s*(\\d+) (\\d+) "(.+)" (\\S+) +(\\d+:\\d+(?::\\d+)?) (\\d+) (\\S+) (\\S+) (\\d+) (\\d+\\.\\d+\\.\\d+\\.\\d+:\\d+)$';
rconParser.Configuration.Status.AddMapping(100, 2);
rconParser.Configuration.Status.AddMapping(101, -1);
rconParser.Configuration.Status.AddMapping(102, 6);
rconParser.Configuration.Status.AddMapping(103, 4)
rconParser.Configuration.Status.AddMapping(104, 3);
rconParser.Configuration.Status.AddMapping(105, 10);
rconParser.Configuration.Status.AddMapping(200, 1);
rconParser.Configuration.DefaultDvarValues.Add('sv_running', '1');
rconParser.Configuration.DefaultDvarValues.Add('bugfix_no_version', this.engine);
rconParser.Configuration.DefaultDvarValues.Add('fs_basepath', '');
rconParser.Configuration.DefaultDvarValues.Add('fs_basegame', '');
rconParser.Configuration.DefaultDvarValues.Add('fs_homepath', '');
rconParser.Configuration.DefaultDvarValues.Add('g_log', '');
rconParser.Configuration.DefaultDvarValues.Add('net_ip', 'localhost');
rconParser.Configuration.DefaultDvarValues.Add('g_gametype', '');
rconParser.Configuration.DefaultDvarValues.Add('fs_game', '');
rconParser.Configuration.OverrideDvarNameMapping.Add('sv_hostname', 'hostname');
rconParser.Configuration.OverrideDvarNameMapping.Add('mapname', 'host_map');
rconParser.Configuration.OverrideDvarNameMapping.Add('sv_maxclients', 'maxplayers');
rconParser.Configuration.OverrideDvarNameMapping.Add('g_password', 'sv_password');
rconParser.Configuration.OverrideDvarNameMapping.Add('version', 'bugfix_no_version');
rconParser.Configuration.ColorCodeMapping.Clear();
rconParser.Configuration.ColorCodeMapping.Add('White', '\x01');
rconParser.Configuration.ColorCodeMapping.Add('Red', '\x07');
rconParser.Configuration.ColorCodeMapping.Add('LightRed', '\x0F');
rconParser.Configuration.ColorCodeMapping.Add('DarkRed', '\x02');
rconParser.Configuration.ColorCodeMapping.Add('Blue', '\x0B');
rconParser.Configuration.ColorCodeMapping.Add('DarkBlue', '\x0C');
rconParser.Configuration.ColorCodeMapping.Add('Purple', '\x03');
rconParser.Configuration.ColorCodeMapping.Add('Orchid', '\x0E');
rconParser.Configuration.ColorCodeMapping.Add('Yellow', '\x09');
rconParser.Configuration.ColorCodeMapping.Add('Gold', '\x10');
rconParser.Configuration.ColorCodeMapping.Add('LightGreen', '\x05');
rconParser.Configuration.ColorCodeMapping.Add('Green', '\x04');
rconParser.Configuration.ColorCodeMapping.Add('Lime', '\x06');
rconParser.Configuration.ColorCodeMapping.Add('Grey', '\x08');
rconParser.Configuration.ColorCodeMapping.Add('Grey2', '\x0D');
// only adding there here for the default accent color
rconParser.Configuration.ColorCodeMapping.Add('Cyan', '\x0B');
rconParser.Configuration.NoticeLineSeparator = '. ';
rconParser.Configuration.DefaultRConPort = 27015;
rconParser.CanGenerateLogPath = false;
rconParser.Configuration.CommandPrefixes.RConGetInfo = undefined;
rconParser.Configuration.CommandPrefixes.Kick = 'sm_kick #{0} {1}';
rconParser.Configuration.CommandPrefixes.Ban = 'sm_kick #{0} {1}';
rconParser.Configuration.CommandPrefixes.TempBan = 'sm_kick #{0} {1}';
rconParser.Configuration.CommandPrefixes.Say = 'sm_say {0}';
rconParser.Configuration.CommandPrefixes.Tell = 'sm_psay #{0} "{1}"';
eventParser.Configuration.Say.Pattern = '^"(.+)<(\\d+)><(.+)><(.*?)>" (?:say|say_team) "(.*)"$';
eventParser.Configuration.Say.AddMapping(5, 1);
eventParser.Configuration.Say.AddMapping(3, 2);
eventParser.Configuration.Say.AddMapping(1, 3);
eventParser.Configuration.Say.AddMapping(7, 4);
eventParser.Configuration.Say.AddMapping(13, 5);
eventParser.Configuration.Kill.Pattern = '^"(.+)<(\\d+)><(.+)><(.*)>" \\[-?\\d+ -?\\d+ -?\\d+\\] killed "(.+)<(\\d+)><(.+)><(.*)>" \\[-?\\d+ -?\\d+ -?\\d+\\] with "(\\S*)" *(?:\\((\\w+)((?: ).+)?\\))?$';
eventParser.Configuration.Kill.AddMapping(5, 1);
eventParser.Configuration.Kill.AddMapping(3, 2);
eventParser.Configuration.Kill.AddMapping(1, 3);
eventParser.Configuration.Kill.AddMapping(7, 4);
eventParser.Configuration.Kill.AddMapping(6, 5);
eventParser.Configuration.Kill.AddMapping(4, 6);
eventParser.Configuration.Kill.AddMapping(2, 7);
eventParser.Configuration.Kill.AddMapping(8, 8);
eventParser.Configuration.Kill.AddMapping(9, 9);
eventParser.Configuration.Kill.AddMapping(12, 10);
eventParser.Configuration.MapEnd.Pattern = '^World triggered "Match_Start" on "(.+)"$';
eventParser.Configuration.JoinTeam.Pattern = '^"(.+)<(\\d+)><(.*)>" switched from team <(.+)> to <(.+)>$';
eventParser.Configuration.JoinTeam.AddMapping(5, 1);
eventParser.Configuration.JoinTeam.AddMapping(3, 2);
eventParser.Configuration.JoinTeam.AddMapping(1, 3);
eventParser.Configuration.JoinTeam.AddMapping(7, 5);
eventParser.Configuration.TeamMapping.Add('CT', 2);
eventParser.Configuration.TeamMapping.Add('TERRORIST', 3);
eventParser.Configuration.Time.Pattern = '^L [01]\\d/[0-3]\\d/\\d+ - [0-2]\\d:[0-5]\\d:[0-5]\\d:';
rconParser.Version = 'L4D2SM';
rconParser.GameName = 12; // L4D2
eventParser.Version = 'L4D2SM';
eventParser.GameName = 12; // L4D2
eventParser.URLProtocolFormat = 'steam://connect/{{ip}}:{{port}}';
},
onUnloadAsync: function () {
},
onTickAsync: function (server) {
}
};

View File

@ -25,25 +25,11 @@ namespace Stats.Dtos
/// </summary>
public DateTime? SentAfter { get; set; }
/// <summary>
/// The time associated with SentAfter date
/// </summary>
public string SentAfterTime { get; set; }
public DateTime? SentAfterDateTime => SentAfter?.Add(string.IsNullOrEmpty(SentAfterTime) ? TimeSpan.Zero : TimeSpan.Parse(SentAfterTime));
/// <summary>
/// only look for messages sent before this date0
/// </summary>
public DateTime SentBefore { get; set; } = DateTime.UtcNow.Date;
public DateTime SentBefore { get; set; } = DateTime.UtcNow;
public string SentBeforeTime { get; set; }
public DateTime? SentBeforeDateTime =>
SentBefore.Add(string.IsNullOrEmpty(SentBeforeTime) ? TimeSpan.Zero : TimeSpan.Parse(SentBeforeTime));
public bool IsExactMatch { get; set; }
/// <summary>
/// indicates if the chat is on the meta page
/// </summary>

View File

@ -13,6 +13,7 @@ namespace IW4MAdmin.Plugins.Stats
{
private const int ZScoreRange = 3;
private const int RankIconDivisions = 24;
private const int MaxMessages = 100;
public class LogParams
{
@ -126,5 +127,70 @@ namespace IW4MAdmin.Plugins.Stats
return 0;
}
/// <summary>
/// todo: lets abstract this out to a generic buildable query
/// this is just a dirty PoC
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public static ChatSearchQuery ParseSearchInfo(this string query, int count, int offset)
{
string[] filters = query.Split('|');
var searchRequest = new ChatSearchQuery
{
Filter = query,
Count = count,
Offset = offset
};
// sanity checks
searchRequest.Count = Math.Min(searchRequest.Count, MaxMessages);
searchRequest.Count = Math.Max(searchRequest.Count, 0);
searchRequest.Offset = Math.Max(searchRequest.Offset, 0);
if (filters.Length > 1)
{
if (filters[0].ToLower() != "chat")
{
throw new ArgumentException("Query is not compatible with chat");
}
foreach (string filter in filters.Skip(1))
{
string[] args = filter.Split(' ');
if (args.Length > 1)
{
string recombinedArgs = string.Join(' ', args.Skip(1));
switch (args[0].ToLower())
{
case "before":
searchRequest.SentBefore = DateTime.Parse(recombinedArgs);
break;
case "after":
searchRequest.SentAfter = DateTime.Parse(recombinedArgs);
break;
case "server":
searchRequest.ServerId = args[1];
break;
case "client":
searchRequest.ClientId = int.Parse(args[1]);
break;
case "contains":
searchRequest.MessageContains = string.Join(' ', args.Skip(1));
break;
case "sort":
searchRequest.Direction = Enum.Parse<SortDirection>(args[1], ignoreCase: true);
break;
}
}
}
return searchRequest;
}
throw new ArgumentException("No filters specified for chat search");
}
}
}

View File

@ -53,11 +53,11 @@ namespace Stats.Helpers
}
var iqMessages = context.Set<EFClientMessage>()
.Where(message => message.TimeSent < query.SentBeforeDateTime);
.Where(message => message.TimeSent < query.SentBefore);
if (query.SentAfterDateTime is not null)
if (query.SentAfter is not null)
{
iqMessages = iqMessages.Where(message => message.TimeSent >= query.SentAfterDateTime);
iqMessages = iqMessages.Where(message => message.TimeSent >= query.SentAfter);
}
if (query.ClientId is not null)
@ -72,10 +72,7 @@ namespace Stats.Helpers
if (!string.IsNullOrEmpty(query.MessageContains))
{
iqMessages = query.IsExactMatch
? iqMessages.Where(message => message.Message.ToLower() == query.MessageContains.ToLower())
: iqMessages.Where(message =>
EF.Functions.Like(message.Message.ToLower(), $"%{query.MessageContains.ToLower()}%"));
iqMessages = iqMessages.Where(message => EF.Functions.Like(message.Message.ToLower(), $"%{query.MessageContains.ToLower()}%"));
}
var iqResponse = iqMessages

View File

@ -469,8 +469,6 @@ public class Plugin : IPluginV2
ClientId = request.ClientId,
Before = request.Before,
SentBefore = request.Before ?? DateTime.UtcNow,
SentAfter = request.After,
After = request.After,
Count = request.Count,
IsProfileMeta = true
};

View File

@ -56,4 +56,4 @@ Feel free to join the **IW4MAdmin** [Discord](https://discord.gg/ZZFK5p3)
If you come across an issue, bug, or feature request please post an [issue](https://github.com/RaidMax/IW4M-Admin/issues)
#### Explore the [wiki](https://git.rimmyscorner.com/Parasyn/IW4M-Admin/wiki) to find more information.
#### Explore the [wiki](https://github.com/RaidMax/IW4M-Admin/wiki) to find more information.

View File

@ -179,7 +179,6 @@ namespace SharedLibraryCore
server.Reports.Count(report => DateTime.UtcNow - report.ReportedOn <= TimeSpan.FromHours(24)));
ViewBag.PermissionsSet = PermissionsSet;
ViewBag.Alerts = AlertManager.RetrieveAlerts(Client);
ViewBag.Manager = Manager;
base.OnActionExecuting(context);
}

View File

@ -206,7 +206,7 @@ namespace SharedLibraryCore.Configuration
: ManualWebfrontUrl;
[ConfigurationIgnore] public bool IgnoreServerConnectionLost { get; set; }
[ConfigurationIgnore] public Uri MasterUrl { get; set; } = new("https://master.iw4.zip");
[ConfigurationIgnore] public Uri MasterUrl { get; set; } = new("http://api.raidmax.org:5000");
public IBaseConfiguration Generate()
{

View File

@ -67,7 +67,7 @@ namespace SharedLibraryCore.Configuration.Validation
RuleFor(_app => _app.MasterUrl)
.NotNull()
.Must(_url => _url != null && (_url.Scheme == Uri.UriSchemeHttp || _url.Scheme == Uri.UriSchemeHttps));
.Must(_url => _url != null && _url.Scheme == Uri.UriSchemeHttp);
RuleFor(_app => _app.CommandPrefix)
.NotEmpty();
@ -80,4 +80,4 @@ namespace SharedLibraryCore.Configuration.Validation
.SetValidator(new ServerConfigurationValidator());
}
}
}
}

View File

@ -35,8 +35,7 @@ namespace SharedLibraryCore
T7 = 8,
SHG1 = 9,
CSGO = 10,
H1 = 11,
L4D2 = 12
H1 = 11
}
// only here for performance

View File

@ -50,8 +50,8 @@ namespace SharedLibraryCore
public static char[] DirectorySeparatorChars = { '\\', '/' };
public static char CommandPrefix { get; set; } = '!';
public static string ToStandardFormat(this DateTime? time) => time?.ToString("yyyy-MM-dd HH:mm:ss UTC");
public static string ToStandardFormat(this DateTime time) => time.ToString("yyyy-MM-dd HH:mm:ss UTC");
public static string ToStandardFormat(this DateTime? time) => time?.ToString("yyyy-MM-dd H:mm:ss UTC");
public static string ToStandardFormat(this DateTime time) => time.ToString("yyyy-MM-dd H:mm:ss UTC");
public static EFClient IW4MAdminClient(Server server = null)
{
@ -195,7 +195,7 @@ namespace SharedLibraryCore
}
var output = str;
var colorCodeMatches = Regex.Matches(output, @"\(Color::(\w{1,16})\)",
var colorCodeMatches = Regex.Matches(output, @"\(Color::(.{1,16})\)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
foreach (var match in colorCodeMatches.Where(m => m.Success))
{

View File

@ -249,8 +249,7 @@ namespace WebfrontCore.Controllers
{
ViewBag.Title = Localization["WEBFRONT_SEARCH_RESULTS_TITLE"];
ViewBag.ClientResourceRequest = request;
request.RequesterPermission = Client.Level;
var response = await _clientResourceHelper.QueryResource(request);
return request.Offset > 0
? PartialView("Find/_AdvancedFindList", response.Results)

View File

@ -17,7 +17,6 @@ using Microsoft.Extensions.Logging;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using Data.Abstractions;
using Stats.Config;
using WebfrontCore.QueryHelpers.Models;
namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
{
@ -122,7 +121,7 @@ namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
}
[HttpGet("Message/Find")]
public async Task<IActionResult> FindMessage([FromQuery] ChatResourceRequest query)
public async Task<IActionResult> FindMessage([FromQuery] string query)
{
ViewBag.Localization = _translationLookup;
ViewBag.EnableColorCodes = _manager.GetApplicationSettings().Configuration().EnableColorCodes;
@ -131,15 +130,53 @@ namespace IW4MAdmin.Plugins.Web.StatsWeb.Controllers
ViewBag.Title = _translationLookup["WEBFRONT_STATS_MESSAGES_TITLE"];
ViewBag.Error = null;
ViewBag.IsFluid = true;
var result = query != null ? await _chatResourceQueryHelper.QueryResource(query) : null;
ChatSearchQuery searchRequest = null;
try
{
searchRequest = query.ParseSearchInfo(int.MaxValue, 0);
}
catch (ArgumentException e)
{
_logger.LogWarning(e, "Could not parse chat message search query {query}", query);
ViewBag.Error = e;
}
catch (FormatException e)
{
_logger.LogWarning(e, "Could not parse chat message search query filter format {query}", query);
ViewBag.Error = e;
}
var result = searchRequest != null ? await _chatResourceQueryHelper.QueryResource(searchRequest) : null;
return View("~/Views/Client/Message/Find.cshtml", result);
}
[HttpGet("Message/FindNext")]
public async Task<IActionResult> FindNextMessages(ChatResourceRequest query)
public async Task<IActionResult> FindNextMessages([FromQuery] string query, [FromQuery] int count,
[FromQuery] int offset)
{
var result = await _chatResourceQueryHelper.QueryResource(query);
ChatSearchQuery searchRequest;
try
{
searchRequest = query.ParseSearchInfo(count, offset);
}
catch (ArgumentException e)
{
_logger.LogWarning(e, "Could not parse chat message search query {query}", query);
throw;
}
catch (FormatException e)
{
_logger.LogWarning(e, "Could not parse chat message search query filter format {query}", query);
throw;
}
var result = await _chatResourceQueryHelper.QueryResource(searchRequest);
return PartialView("~/Views/Client/Message/_Item.cshtml", result.Results);
}

View File

@ -1,9 +0,0 @@
using Stats.Dtos;
namespace WebfrontCore.QueryHelpers.Models;
public class ChatResourceRequest : ChatSearchQuery
{
public bool HasData => !string.IsNullOrEmpty(MessageContains) || !string.IsNullOrEmpty(ServerId) ||
ClientId is not null || SentAfterDateTime is not null;
}

View File

@ -16,9 +16,4 @@ public class ClientResourceRequest : ClientPaginationRequest
public EFClient.Permission? ClientLevel { get; set; }
public Reference.Game? GameName { get; set; }
public bool IncludeGeolocationData { get; set; } = true;
public EFClient.Permission RequesterPermission { get; set; } = EFClient.Permission.User;
public bool HasData => !string.IsNullOrEmpty(ClientName) || !string.IsNullOrEmpty(ClientIp) ||
!string.IsNullOrEmpty(ClientGuid) || ClientLevel is not null || GameName is not null;
}

View File

@ -26,14 +26,14 @@ else
</tbody>
</table>
<div id="loaderLoad" class="mt-10 m-auto text-center">
<div id="loaderLoad" class="mt-10 m-auto text-center d-none d-lg-block">
<i class="loader-load-more oi oi-chevron-bottom"></i>
</div>
@section scripts {
<script>
$(document).ready(function () {
initLoader(`/Message/FindNext${window.location.search}`, '#message_table_body', @Model.RetrievedResultCount, 30);
initLoader('/Message/FindNext?query=@ViewBag.Query', '#message_table_body', @Model.RetrievedResultCount, @ViewBag.QueryLimit);
});
</script>
}

View File

@ -1,88 +0,0 @@
@using WebfrontCore.QueryHelpers.Models
@using SharedLibraryCore.Interfaces
@using System.Globalization
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model string
@{
var existingChatFilter = ViewBag.Query as ChatResourceRequest;
var manager = ViewBag.Manager as IManager;
}
<div id="chatSearchWrapper@(Model)" data-has-data="@(existingChatFilter?.HasData ?? false)" >
<div class="form-group">
<label for="messageContains@(Model)">@ViewBag.Localization["WEBFRONT_ACTION_LABEL_MESSAGE"]</label>
<div class="d-flex">
<input type="text" class="form-control" name="messageContains" id="messageContains@(Model)}"
placeholder="Contains" value="@existingChatFilter?.MessageContains"/>
<div class="custom-control ml-10 align-self-center">
<div class="custom-switch">
@if (existingChatFilter?.IsExactMatch ?? false)
{
<input type="checkbox" id="isExactMatch@(Model)" name="isExactMatch" value="true"
checked="checked">
}
else
{
<input type="checkbox" id="isExactMatch@(Model)" name="isExactMatch" value="true">
}
<label for="isExactMatch@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="serverId@(Model)" class="w-quarter">@ViewBag.Localization["WEBFRONT_BAN_MGMT_FORM_ID"]</label>
<label for="clientId@(Model)" class="">@ViewBag.Localization["WEBFRONT_CONTEXT_MENU_GLOBAL_SERVER"]</label>
<div class="d-flex">
<input type="text" class="form-control w-quarter" name="clientId" id="clientId@(Model)}"
placeholder="Id" value="@existingChatFilter?.ClientId"/>
<select class="form-control w-three-quarter ml-10" id="serverId@(Model)" name="serverId">
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
@foreach (var server in manager!.GetServers())
{
<option value="@server.Id" selected="@(server.Id == existingChatFilter?.ServerId)">
[@server.GameName.ToString()] @server.ServerName.StripColors()
</option>
}
</select>
</div>
</div>
<div class="form-group">
<label for="sentAfter@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_SENT_AFTER"]</label>
@{
var afterDate = existingChatFilter?.SentAfterDateTime ?? DateTime.UtcNow.AddHours(-1);
}
<div class="d-flex">
<input type="text" class="form-control date-picker-input w-half" name="sentAfter"
id="sentAfter@(Model)" data-date="@afterDate.ToString("s", CultureInfo.InvariantCulture)"
value="@afterDate.ToString("s", CultureInfo.InvariantCulture)"/>
<input type="time" class="form-control w-half ml-10" name="sentAfterTime"
id="sentAfterTime@(Model)"
style="color-scheme: dark;"
value="@afterDate.ToString("HH:mm")"/>
</div>
</div>
<div class="form-group">
<label for="sentAfter@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_SENT_BEFORE"]</label>
@{
var beforeDate = existingChatFilter?.SentBeforeDateTime ?? DateTime.UtcNow;
}
<div class="d-flex">
<input type="text" class="form-control date-picker-input w-half" name="sentBefore"
id="sentBefore@(Model)" data-date="@beforeDate.ToString("s", CultureInfo.InvariantCulture)"
value="@beforeDate.ToString("s", CultureInfo.InvariantCulture)"/>
<input type="time" class="form-control w-half ml-10" name="sentBeforeTime"
id="sentBeforeTime@(Model)"
style="color-scheme: dark;"
value="@beforeDate.ToString("HH:mm")"/>
</div>
</div>
<input type="submit" class="btn btn-primary" value="@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_BUTTON_SUBMIT"]"/>
</div>

View File

@ -1,116 +0,0 @@
@using WebfrontCore.QueryHelpers.Models
@using System.Globalization
@using Data.Models
@using Data.Models.Client
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using SharedLibraryCore.Dtos
@model string
@{
var existingClientFilter = ViewBag.ClientResourceRequest as ClientResourceRequest;
}
<div id="clientSearchWrapper@(Model)" data-has-data="@(existingClientFilter?.HasData ?? false)" >
<div class="form-group">
<label for="clientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_NAME"]</label>
<div class="d-flex">
<input type="text" class="form-control" name="clientName" id="clientName@(Model)"
placeholder="Unknown Soldier" value="@existingClientFilter?.ClientName"/>
<div class="custom-control ml-10 align-self-center">
<div class="custom-switch">
@if (existingClientFilter?.IsExactClientName ?? false)
{
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true"
checked="checked">
}
else
{
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true">
}
<label for="isExactClientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="clientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_IP"]</label>
<div class="d-flex">
<input type="text" class="form-control" name="clientIP" id="clientIP@(Model)" placeholder="1.1.1.1"
value="@existingClientFilter?.ClientIp">
<div class="custom-control ml-10 align-self-center">
<div class="custom-switch">
@if (existingClientFilter?.IsExactClientIp ?? false)
{
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true"
checked="checked">
}
else
{
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true">
}
<label for="isExactClientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="clientGuid@(Model)">GUID <span class="text-primary">&bull;</span> XUID <span class="text-primary">&bull;</span> NetworkID</label>
<input type="text" class="form-control" name="clientGuid" id="clientGuid@(Model)"
placeholder="110000100000001" value="@existingClientFilter?.ClientGuid"/>
</div>
<div class="form-group">
<label for="clientLevel@(Model)" class="w-half">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_PERMISSION"]</label>
<label for="clientGameName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_GAME"]</label>
<div class="d-flex">
<select class="form-control w-half" id="clientLevel@(Model)" name="clientLevel">
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
@foreach (EFClient.Permission permission in Enum.GetValues(typeof(EFClient.Permission)))
{
<option value="@((int)permission)" selected="@(permission == existingClientFilter?.ClientLevel)">
@permission.ToLocalizedLevelName()
</option>
}
</select>
<select class="form-control w-half ml-10" id="clientGameName@(Model)" name="gameName">
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
@foreach (Reference.Game game in Enum.GetValues(typeof(Reference.Game)))
{
<option value="@((int)game)" selected="@(game == existingClientFilter?.GameName)">
@ViewBag.Localization["GAME_" + game]
</option>
}
</select>
</div>
</div>
<div class="form-group">
<label for="clientConnected@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_CONNECTED_SINCE"]</label>
<div class="d-flex">
@{ var presetDate = (existingClientFilter?.ClientConnected ?? DateTime.UtcNow.AddYears(-1)).ToString("s", CultureInfo.InvariantCulture); }
<input type="text" class="form-control date-picker-input w-half" name="clientConnected"
id="clientConnected@(Model)" data-date="@presetDate"
value="@presetDate"/>
<div class="custom-control ml-10 align-self-center">
<div class="custom-switch">
@if ((existingClientFilter?.Direction ?? SortDirection.Descending) is SortDirection.Descending)
{
<input type="checkbox" id="resultOrder@(Model)" name="direction"
value="@((int)SortDirection.Ascending)">
}
else
{
<input type="checkbox" id="resultOrder@(Model)" name="direction"
value="@((int)SortDirection.Ascending)" checked="checked">
}
<label for="resultOrder@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_OLDEST_FIRST"]</label>
</div>
</div>
</div>
</div>
<input type="submit" class="btn btn-primary" value="@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_BUTTON_SUBMIT"]"/>
</div>

View File

@ -1,21 +1,126 @@
@using Data.Models.Client
@using SharedLibraryCore.Dtos
@using WebfrontCore.QueryHelpers.Models
@using Data.Models
@using System.Globalization
@model string
@{
var existingClientFilter = ViewBag.ClientResourceRequest as ClientResourceRequest;
}
<h6 class="dropdown-header">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_TITLE"]</h6>
<div class="dropdown-divider"></div>
<div class="dropdown-content">
<div class="form-group" id="searchTypeSelectorParent">
<label for="searchType@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_FOR"]</label>
<br/>
<select class="form-control" id="searchType@(Model)" name="searchType">
<option value="client">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_TYPE_PLAYERS"]</option>
<option value="chat">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_TYPE_CHAT"]</option>
</select>
</div>
<form asp-controller="Client" asp-action="AdvancedFind" method="get" id="advancedSearchDropdownContent@(Model)" onsubmit="showLoader()">
<partial name="Search/_ClientSearch.cshtml" model="@Model"/>
</form>
<form asp-controller="Stats" asp-action="FindMessage" method="get" onsubmit="showLoader()">
<partial name="Search/_ChatSearch.cshtml" model="@Model"/>
<div class="form-group">
<label for="searchType@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_FOR"]</label>
<br/>
<select class="form-control" id="searchType@(Model)" name="searchType" disabled="disabled">
<option value="client">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_TYPE_PLAYERS"]</option>
</select>
</div>
<div class="form-group">
<label for="clientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_NAME"]</label>
<div class="d-flex">
<input type="text" class="form-control" name="clientName" id="clientName@(Model)"
placeholder="Unknown Soldier" value="@existingClientFilter?.ClientName"/>
<div class="custom-control ml-10 align-self-center">
<div class="custom-switch">
@if (existingClientFilter?.IsExactClientName ?? false)
{
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true"
checked="checked">
}
else
{
<input type="checkbox" id="isExactClientName@(Model)" name="isExactClientName" value="true">
}
<label for="isExactClientName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="clientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_IP"]</label>
<div class="d-flex">
<input type="text" class="form-control" name="clientIP" id="clientIP@(Model)" placeholder="1.1.1.1"
value="@existingClientFilter?.ClientIp">
<div class="custom-control ml-10 align-self-center">
<div class="custom-switch">
@if (existingClientFilter?.IsExactClientIp ?? false)
{
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true"
checked="checked">
}
else
{
<input type="checkbox" id="isExactClientIP@(Model)" name="isExactClientIP" value="true">
}
<label for="isExactClientIP@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_EXACT"]</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="clientGuid@(Model)">GUID <span class="text-primary">&bull;</span> XUID <span class="text-primary">&bull;</span> NetworkID</label>
<input type="text" class="form-control" name="clientGuid" id="clientGuid@(Model)"
placeholder="110000100000001" value="@existingClientFilter?.ClientGuid"/>
</div>
<div class="form-group">
<label for="clientLevel@(Model)" class="w-half">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_PERMISSION"]</label>
<label for="clientGameName@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_GAME"]</label>
<div class="d-flex">
<select class="form-control w-half" id="clientLevel@(Model)" name="clientLevel">
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
@foreach (EFClient.Permission permission in Enum.GetValues(typeof(EFClient.Permission)))
{
<option value="@((int)permission)" selected="@(permission == existingClientFilter?.ClientLevel)">
@permission.ToLocalizedLevelName()
</option>
}
</select>
<select class="form-control w-half ml-10" id="clientGameName@(Model)" name="gameName">
<option value="">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_SELECT_PERMISSIONS_ANY"]</option>
@foreach (Reference.Game game in Enum.GetValues(typeof(Reference.Game)))
{
<option value="@((int)game)" selected="@(game == existingClientFilter?.GameName)">
@ViewBag.Localization["GAME_" + game]
</option>
}
</select>
</div>
</div>
<div class="form-group">
<label for="clientConnected@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_CONNECTED_SINCE"]</label>
<div class="d-flex">
@{ var presetDate = (existingClientFilter?.ClientConnected ?? DateTime.UtcNow.AddYears(-1)).ToString("s", CultureInfo.InvariantCulture); }
<input type="text" class="form-control date-picker-input w-half" name="clientConnected"
id="clientConnected@(Model)" data-date="@presetDate"
value="@presetDate"/>
<div class="custom-control ml-10 align-self-center">
<div class="custom-switch">
@if ((existingClientFilter?.Direction ?? SortDirection.Descending) is SortDirection.Descending)
{
<input type="checkbox" id="resultOrder@(Model)" name="direction"
value="@((int)SortDirection.Ascending)">
}
else
{
<input type="checkbox" id="resultOrder@(Model)" name="direction"
value="@((int)SortDirection.Ascending)" checked="checked">
}
<label for="resultOrder@(Model)">@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_LABEL_OLDEST_FIRST"]</label>
</div>
</div>
</div>
</div>
<input type="submit" class="btn btn-primary" value="@ViewBag.Localization["WEBFRONT_ADVANCED_SEARCH_BUTTON_SUBMIT"]"/>
</form>
</div>

View File

@ -1,4 +1,28 @@
$(document).ready(function () {
$('.form-inline').submit(function (e) {
const id = $(e.currentTarget).find('input');
if ($(id).val().length < 3) {
e.preventDefault();
$(id)
.addClass('input-text-danger')
.delay(25)
.queue(function () {
$(this).addClass('input-border-transition').dequeue();
})
.delay(1000)
.queue(function () {
$(this).removeClass('input-text-danger').dequeue();
})
.delay(500)
.queue(function () {
$(this).removeClass('input-border-transition').dequeue();
});
} else if ($(id).val().startsWith("chat|")) {
e.preventDefault();
window.location = "/Message/Find?query=" + $(id).val();
}
});
$('.date-picker-input').each((index, selector) => {
new Datepicker(selector, {
buttonClass: 'btn',
@ -7,37 +31,5 @@
prevArrow: '<',
orientation: 'auto top'
});
});
const clientSearchWrapper = $('*[id^="clientSearchWrapper"]');
const chatSearchWrapper = $('*[id^="chatSearchWrapper"]');
const searchTypeSelector = $('#searchTypeSelectorParent select');
let isClients = false;
searchTypeSelector.on('change', function () {
if (isClients) {
clientSearchWrapper.removeClass('d-none');
chatSearchWrapper.addClass('d-none');
} else {
chatSearchWrapper.removeClass('d-none');
clientSearchWrapper.addClass('d-none');
}
isClients = !isClients;
});
const isDefault = clientSearchWrapper.data('has-data') !== 'True' && chatSearchWrapper.data('has-data') !== 'True';
if (isDefault) {
isClients = false;
searchTypeSelector.val('client').change();
} else {
if (clientSearchWrapper.data('has-data') === 'True') {
isClients = false;
searchTypeSelector.val('client').change();
}
if (chatSearchWrapper.data('has-data') === 'True') {
isClients = true;
searchTypeSelector.val('chat').change();
}
}
})
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB