update parsers to include game name

prompt to enter log path if game doesn't generate
This commit is contained in:
RaidMax 2019-02-05 18:02:45 -06:00
parent f3290cf066
commit 044991272f
18 changed files with 70 additions and 131 deletions

View File

@ -299,6 +299,7 @@ namespace IW4MAdmin.Application
} }
serverConfig.ModifyParsers(); serverConfig.ModifyParsers();
await ConfigHandler.Save();
} }
} }
} }

View File

@ -247,7 +247,7 @@
] ]
}, },
{ {
"Game": "T6M", "Game": "T6",
"Maps": [ "Maps": [
{ {
"Alias": "Aftermath", "Alias": "Aftermath",

View File

@ -4,6 +4,7 @@ using SharedLibraryCore.Interfaces;
using System; using System;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using static SharedLibraryCore.Server;
namespace IW4MAdmin.Application.EventParsers namespace IW4MAdmin.Application.EventParsers
{ {
@ -70,6 +71,8 @@ namespace IW4MAdmin.Application.EventParsers
public string Version { get; set; } = "CoD"; public string Version { get; set; } = "CoD";
public Game GameName { get; set; } = Game.COD;
public virtual GameEvent GetEvent(Server server, string logLine) public virtual GameEvent GetEvent(Server server, string logLine)
{ {
logLine = Regex.Replace(logLine, @"([0-9]+:[0-9]+ |^[0-9]+ )", "").Trim(); logLine = Regex.Replace(logLine, @"([0-9]+:[0-9]+ |^[0-9]+ )", "").Trim();

View File

@ -679,7 +679,12 @@ namespace IW4MAdmin
var version = await this.GetDvarAsync<string>("version"); var version = await this.GetDvarAsync<string>("version");
Version = version.Value; Version = version.Value;
GameName = Utilities.GetGame(version?.Value); GameName = Utilities.GetGame(version?.Value ?? RconParser.Version);
if (GameName == Game.UKN)
{
GameName = RconParser.GameName;
}
if (version?.Value?.Length != 0) if (version?.Value?.Length != 0)
{ {
@ -733,12 +738,12 @@ namespace IW4MAdmin
this.Gametype = gametype; this.Gametype = gametype;
this.IP = ip.Value == "localhost" ? ServerConfig.IPAddress : ip.Value ?? ServerConfig.IPAddress; this.IP = ip.Value == "localhost" ? ServerConfig.IPAddress : ip.Value ?? ServerConfig.IPAddress;
if (logsync.Value == 0 || logfile.Value == string.Empty) if ((logsync.Value == 0 || logfile.Value == string.Empty) && RconParser.CanGenerateLogPath)
{ {
// this DVAR isn't set until the a map is loaded // this DVAR isn't set until the a map is loaded
await this.SetDvarAsync("logfile", 2); await this.SetDvarAsync("logfile", 2);
await this.SetDvarAsync("g_logsync", 2); // set to 2 for continous in other games, clamps to 1 for IW4 await this.SetDvarAsync("g_logsync", 2); // set to 2 for continous in other games, clamps to 1 for IW4
await this.SetDvarAsync("g_log", "games_mp.log"); //await this.SetDvarAsync("g_log", "games_mp.log");
Logger.WriteWarning("Game log file not properly initialized, restarting map..."); Logger.WriteWarning("Game log file not properly initialized, restarting map...");
await this.ExecuteCommandAsync("map_restart"); await this.ExecuteCommandAsync("map_restart");
logfile = await this.GetDvarAsync<string>("g_log"); logfile = await this.GetDvarAsync<string>("g_log");

View File

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using static SharedLibraryCore.Server;
namespace IW4MAdmin.Application.RconParsers namespace IW4MAdmin.Application.RconParsers
{ {
@ -31,7 +32,6 @@ namespace IW4MAdmin.Application.RconParsers
RConGetInfo = "ÿÿÿÿgetinfo", RConGetInfo = "ÿÿÿÿgetinfo",
RConResponse = "ÿÿÿÿprint", RConResponse = "ÿÿÿÿprint",
}, },
GameName = Server.Game.IW4
}; };
Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){16}|(?:[a-z]|[0-9]){32}|bot[0-9]+|(?:[0-9]+)) *(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$"; Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){16}|(?:[a-z]|[0-9]){32}|bot[0-9]+|(?:[0-9]+)) *(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$";
@ -53,6 +53,8 @@ namespace IW4MAdmin.Application.RconParsers
public IRConParserConfiguration Configuration { get; set; } public IRConParserConfiguration Configuration { get; set; }
public string Version { get; set; } = "CoD"; public string Version { get; set; } = "CoD";
public Game GameName { get; set; } = Game.COD;
public bool CanGenerateLogPath { get; set; } = true;
public async Task<string[]> ExecuteCommandAsync(Connection connection, string command) public async Task<string[]> ExecuteCommandAsync(Connection connection, string command)
{ {

View File

@ -11,7 +11,6 @@ namespace IW4MAdmin.Application.RconParsers
sealed internal class DynamicRConParserConfiguration : IRConParserConfiguration sealed internal class DynamicRConParserConfiguration : IRConParserConfiguration
{ {
public CommandPrefix CommandPrefixes { get; set; } public CommandPrefix CommandPrefixes { get; set; }
public Server.Game GameName { get; set; }
public ParserRegex Status { get; set; } = new ParserRegex(); public ParserRegex Status { get; set; } = new ParserRegex();
public ParserRegex Dvar { get; set; } = new ParserRegex(); public ParserRegex Dvar { get; set; } = new ParserRegex();
public bool WaitForResponse { get; set; } = true; public bool WaitForResponse { get; set; } = true;

View File

@ -1,31 +0,0 @@
var plugin = {
author: 'RaidMax',
version: 1.1,
name: 'Shared GUID Kicker Plugin',
onEventAsync: function (gameEvent, server) {
// make sure we only check for IW4(x)
if (server.GameName !== 2) {
return false;
}
// connect or join event
if (gameEvent.Type === 3) {
// this GUID seems to have been packed in a IW4 torrent and results in an unreasonable amount of people using the same GUID
if (gameEvent.Origin.NetworkId === -805366929435212061) {
gameEvent.Origin.Kick('Your GUID is generic. Delete players/guids.dat and rejoin', _IW4MAdminClient);
}
}
},
onLoadAsync: function (manager) {
},
onUnloadAsync: function () {
},
onTickAsync: function (server) {
}
};

View File

@ -1,62 +0,0 @@
var plugin = {
author: 'RaidMax',
version: 1.0,
name: 'VPN Detection Plugin',
manager: null,
logger: null,
vpnExceptionIds: [],
checkForVpn: function (origin) {
var exempt = false;
// prevent players that are exempt from being kicked
this.vpnExceptionIds.forEach(function (id) {
if (id === origin.ClientId) {
exempt = true;
return false;
}
});
if (exempt) {
return;
}
var usingVPN = false;
try {
var cl = new System.Net.Http.HttpClient();
var re = cl.GetAsync('https://api.xdefcon.com/proxy/check/?ip=' + origin.IPAddressString).Result;
var co = re.Content;
var parsedJSON = JSON.parse(co.ReadAsStringAsync().Result);
co.Dispose();
re.Dispose();
cl.Dispose();
usingVPN = parsedJSON.success && parsedJSON.proxy;
} catch (e) {
this.logger.WriteError(e.message);
}
if (usingVPN) {
this.logger.WriteInfo(origin + ' is using a VPN (' + origin.IPAddressString + ')');
origin.Kick(_localization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], _IW4MAdminClient);
}
},
onEventAsync: function (gameEvent, server) {
// connect event
if (gameEvent.Type === 3) {
this.checkForVpn(gameEvent.Origin);
}
},
onLoadAsync: function (manager) {
this.manager = manager;
this.logger = manager.GetLogger(0);
},
onUnloadAsync: function () {
},
onTickAsync: function (server) {
}
};

View File

@ -17,9 +17,11 @@ var plugin = {
rconParser.Configuration.Dvar.Pattern = '^"(.+)" is: "(.+)?" default: "(.+)?" info: "(.+)?"$'; rconParser.Configuration.Dvar.Pattern = '^"(.+)" is: "(.+)?" default: "(.+)?" info: "(.+)?"$';
rconParser.Configuration.Dvar.AddMapping(110, 4); rconParser.Configuration.Dvar.AddMapping(110, 4);
rconParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017'; rconParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017';
rconParser.GameName = 1; // IW3
eventParser.Configuration.GameDirectory = 'main'; eventParser.Configuration.GameDirectory = 'main';
eventParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017'; eventParser.Version = 'CoD4 X 1.8 win_mingw-x86 build 2055 May 2 2017';
eventParser.GameName = 1; // IW3
}, },
onUnloadAsync: function () { onUnloadAsync: function () {

View File

@ -3,7 +3,7 @@ var eventParser;
var plugin = { var plugin = {
author: 'RaidMax', author: 'RaidMax',
version: 0.1, version: 0.2,
name: 'IW3 Parser', name: 'IW3 Parser',
isParser: true, isParser: true,
@ -22,7 +22,9 @@ var plugin = {
eventParser.Configuration.GameDirectory = 'userraw'; eventParser.Configuration.GameDirectory = 'userraw';
rconParser.Version = 'IW4x (v0.6.0)'; rconParser.Version = 'IW4x (v0.6.0)';
rconParser.GameName = 2; // IW4x
eventParser.Version = 'IW4x (v0.6.0)'; eventParser.Version = 'IW4x (v0.6.0)';
eventParser.GameName = 2; // IW4x
}, },
onUnloadAsync: function () { onUnloadAsync: function () {

View File

@ -3,7 +3,7 @@ var eventParser;
var plugin = { var plugin = {
author: 'RaidMax', author: 'RaidMax',
version: 0.1, version: 0.2,
name: 'Plutoniun T6 Parser', name: 'Plutoniun T6 Parser',
isParser: true, isParser: true,
@ -34,11 +34,12 @@ var plugin = {
rconParser.Configuration.Status.AddMapping(104, 6); rconParser.Configuration.Status.AddMapping(104, 6);
rconParser.Configuration.Status.AddMapping(105, 8); rconParser.Configuration.Status.AddMapping(105, 8);
eventParser.Configuration.GameDirectory = 't6r\\data';
eventParser.Configuration.GameDirectory = 't6r\\\\data';
rconParser.Version = 'Call of Duty Multiplayer - Ship COD_T6_S MP build 1.0.44 CL(1759941) CODPCAB2 CEG Fri May 9 19:19:19 2014 win-x86 813e66d5'; rconParser.Version = 'Call of Duty Multiplayer - Ship COD_T6_S MP build 1.0.44 CL(1759941) CODPCAB2 CEG Fri May 9 19:19:19 2014 win-x86 813e66d5';
rconParser.GameName = 7; // T6
eventParser.Version = 'Call of Duty Multiplayer - Ship COD_T6_S MP build 1.0.44 CL(1759941) CODPCAB2 CEG Fri May 9 19:19:19 2014 win-x86 813e66d5'; eventParser.Version = 'Call of Duty Multiplayer - Ship COD_T6_S MP build 1.0.44 CL(1759941) CODPCAB2 CEG Fri May 9 19:19:19 2014 win-x86 813e66d5';
eventParser.GameName = 7; // T6
}, },
onUnloadAsync: function () { onUnloadAsync: function () {

View File

@ -3,7 +3,7 @@ var eventParser;
var plugin = { var plugin = {
author: 'RaidMax', author: 'RaidMax',
version: 0.1, version: 0.2,
name: 'Tekno MW3 Parser', name: 'Tekno MW3 Parser',
isParser: true, isParser: true,
@ -27,9 +27,12 @@ var plugin = {
rconParser.Configuration.Dvar.AddMapping(107, 1); // RCon DvarValue rconParser.Configuration.Dvar.AddMapping(107, 1); // RCon DvarValue
rconParser.Configuration.Dvar.Pattern = '^(.*)$'; rconParser.Configuration.Dvar.Pattern = '^(.*)$';
rconParser.Version = 'IW5 MP 1.4 build 382 latest Thu Jan 19 2012 11:09:49AM win-x86'; rconParser.Version = 'IW5 MP 1.4 build 382 latest Thu Jan 19 2012 11:09:49AM win-x86';
rconParser.GameName = 3; // IW5
rconParser.CanGenerateLogPath = false;
eventParser.Configuration.GameDirectory = 'scripts'; eventParser.Configuration.GameDirectory = 'scripts';
eventParser.Version = 'IW5 MP 1.4 build 382 latest Thu Jan 19 2012 11:09:49AM win-x86'; eventParser.Version = 'IW5 MP 1.4 build 382 latest Thu Jan 19 2012 11:09:49AM win-x86';
eventParser.GameName = 3; // IW5
}, },
onUnloadAsync: function () { onUnloadAsync: function () {

View File

@ -38,10 +38,15 @@ namespace SharedLibraryCore.Configuration
if (selection.Item1 > 0) if (selection.Item1 > 0)
{ {
RConParserVersion = selection.Item2; RConParserVersion = selection.Item2;
if (!rconParsers[selection.Item1 - 1].CanGenerateLogPath)
{
Console.WriteLine(loc["SETUP_SERVER_NO_LOG"]);
ManualLogPath = Utilities.PromptString(loc["SETUP_SERVER_LOG_PATH"]);
}
} }
parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray(); parserVersions = eventParsers.Select(_parser => _parser.Version).ToArray();
Console.WriteLine($"{IPAddress}:{Port}");
selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_EVENT_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions); selection = Utilities.PromptSelection($"{loc["SETUP_SERVER_EVENT_PARSER_VERSION"]} ({IPAddress}:{Port})", $"{loc["SETUP_PROMPT_DEFAULT"]} (Call of Duty)", null, parserVersions);
if (selection.Item1 > 0) if (selection.Item1 > 0)

View File

@ -1,4 +1,6 @@
namespace SharedLibraryCore.Interfaces using static SharedLibraryCore.Server;
namespace SharedLibraryCore.Interfaces
{ {
public interface IEventParser public interface IEventParser
{ {
@ -15,6 +17,15 @@
/// </summary> /// </summary>
/// <returns>Game directory prefix</returns> /// <returns>Game directory prefix</returns>
IEventParserConfiguration Configuration { get; set; } IEventParserConfiguration Configuration { get; set; }
/// <summary>
/// stores the game/client specific version (usually the value of the "version" DVAR)
/// </summary>
string Version { get; set; } string Version { get; set; }
/// <summary>
/// specifies the game name (usually the internal studio iteration ie: IW4, T5 etc...)
/// </summary>
Game GameName { get; set; }
} }
} }

View File

@ -51,5 +51,16 @@ namespace SharedLibraryCore.Interfaces
/// stores the game/client specific version (usually the value of the "version" DVAR) /// stores the game/client specific version (usually the value of the "version" DVAR)
/// </summary> /// </summary>
string Version { get; set; } string Version { get; set; }
/// <summary>
/// specifies the game name (usually the internal studio iteration ie: IW4, T5 etc...)
/// </summary>
Game GameName { get; set; }
/// <summary>
/// indicates if the game supports generating a log path from DVAR retrieval
/// of fs_game, fs_basepath, g_log
/// </summary>
bool CanGenerateLogPath { get; set; }
} }
} }

View File

@ -9,10 +9,6 @@ namespace SharedLibraryCore.Interfaces
/// </summary> /// </summary>
CommandPrefix CommandPrefixes { get; set; } CommandPrefix CommandPrefixes { get; set; }
/// <summary> /// <summary>
/// optionally stores the game name type
/// </summary>
Server.Game GameName { get; set; }
/// <summary>
/// stores the regex info for parsing get status response /// stores the regex info for parsing get status response
/// </summary> /// </summary>
ParserRegex Status { get; set; } ParserRegex Status { get; set; }

View File

@ -17,14 +17,16 @@ namespace SharedLibraryCore
{ {
public enum Game public enum Game
{ {
UKN, COD = -1,
IW3, UKN = 0,
IW4, IW3 = 1,
IW5, IW4 = 2,
T4, IW5 = 3,
T5, IW6 = 4,
T5M, T4 = 5,
T6M, T5 = 6,
T6 = 7,
T7 = 8
} }
public Server(IManager mgr, ServerConfiguration config) public Server(IManager mgr, ServerConfiguration config)
@ -51,12 +53,6 @@ namespace SharedLibraryCore
public long EndPoint => Convert.ToInt64($"{IP.Replace(".", "")}{Port}"); public long EndPoint => Convert.ToInt64($"{IP.Replace(".", "")}{Port}");
//Returns current server IP set by `net_ip` -- *STRING*
public String GetIP()
{
return IP;
}
//Returns current server port set by `net_port` -- *INT* //Returns current server port set by `net_port` -- *INT*
public int GetPort() public int GetPort()
{ {

View File

@ -367,16 +367,11 @@ namespace SharedLibraryCore
return Game.T4; return Game.T4;
} }
if (gameName.Contains("COD_T5_S")) if (gameName.Contains("T5"))
{ {
return Game.T5; return Game.T5;
} }
if (gameName.Contains("T5M"))
{
return Game.T5M;
}
if (gameName.Contains("IW5")) if (gameName.Contains("IW5"))
{ {
return Game.IW5; return Game.IW5;
@ -384,7 +379,7 @@ namespace SharedLibraryCore
if (gameName.Contains("COD_T6_S")) if (gameName.Contains("COD_T6_S"))
{ {
return Game.T6M; return Game.T6;
} }
return Game.UKN; return Game.UKN;