From f613f0aace67e2a3e0cc659159c8efdddb2a2e12 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Fri, 26 Jul 2019 10:22:02 -0500 Subject: [PATCH] finish tweaks to log reader add some more shared guids --- Application/IO/GameLogReaderHttp.cs | 12 +++---- GameLogServer/GameLogServer/log_reader.py | 41 ++++++++++------------- Plugins/ScriptPlugins/SharedGUIDKick.js | 8 +++-- 3 files changed, 27 insertions(+), 34 deletions(-) diff --git a/Application/IO/GameLogReaderHttp.cs b/Application/IO/GameLogReaderHttp.cs index d0e1d72ef..846c9aaad 100644 --- a/Application/IO/GameLogReaderHttp.cs +++ b/Application/IO/GameLogReaderHttp.cs @@ -35,10 +35,6 @@ namespace IW4MAdmin.Application.IO public async Task> ReadEventsFromLog(Server server, long fileSizeDiff, long startPosition) { -#if DEBUG == true - server.Logger.WriteDebug($"Begin reading from http log at {DateTime.Now.Millisecond}"); -#endif - if (!ignoreBots.HasValue) { ignoreBots = server.Manager.GetApplicationSettings().Configuration().IgnoreBots; @@ -55,8 +51,11 @@ namespace IW4MAdmin.Application.IO return events; } - else if (response.Data != null) + else if (!string.IsNullOrWhiteSpace(response.Data)) { +#if DEBUG + server.Manager.GetLogger(0).WriteInfo(response.Data); +#endif // parse each line foreach (string eventLine in response.Data.Split(Environment.NewLine)) { @@ -116,9 +115,6 @@ namespace IW4MAdmin.Application.IO } } -#if DEBUG == true - server.Logger.WriteDebug($"End reading from http log at {DateTime.Now.Millisecond}"); -#endif return events; } } diff --git a/GameLogServer/GameLogServer/log_reader.py b/GameLogServer/GameLogServer/log_reader.py index e4fb87024..c8ea79fc3 100644 --- a/GameLogServer/GameLogServer/log_reader.py +++ b/GameLogServer/GameLogServer/log_reader.py @@ -39,50 +39,43 @@ class LogReader(object): next_retrieval_key = self._generate_key() - #print('next key is %s' % next_retrieval_key) - # this is the first time the key has been requested, so we need to the next one if retrieval_key not in self.log_file_sizes: - print ('requested key %s does not exist' % retrieval_key) - self.log_file_sizes[next_retrieval_key] = { - 'size': new_file_size, - 'length': 0, - 'read': time.time(), - 'next_key': next_retrieval_key, # the key that IW4MAdmin should request next - 'previous_key': retrieval_key # the old key that can be deleted next - } - return { - 'content': None, - 'next_key': next_retrieval_key + print('retrieval key "%s" does not exist' % retrieval_key) + last_log_info = { + 'size' : new_file_size, + 'previous_key' : None } else: - current_log_info = self.log_file_sizes[retrieval_key] + last_log_info = self.log_file_sizes[retrieval_key] - # grab the previous values - last_length = current_log_info['length'] - last_size = current_log_info['size'] + print('next key is %s' % next_retrieval_key) + expired_key = last_log_info['previous_key'] + print('expired key is %s' % expired_key) + + # grab the previous value + last_size = last_log_info['size'] file_size_difference = new_file_size - last_size #print('generating info for next key %s' % next_retrieval_key) - # update the new size and actually read the data + # update the new size self.log_file_sizes[next_retrieval_key] = { 'size' : new_file_size, - 'length': last_length, 'read': time.time(), 'next_key': next_retrieval_key, 'previous_key': retrieval_key } - if current_log_info['previous_key'] in self.log_file_sizes.keys(): - #print('deleting old key %s' % current_log_info['previous_key']) - del self.log_file_sizes[current_log_info['previous_key']] + if expired_key in self.log_file_sizes: + print('deleting expired key %s' % expired_key) + del self.log_file_sizes[expired_key] #print('reading %i bytes starting at %i' % (file_size_difference, last_size)) - new_log_info = self.get_file_lines(path, last_size, file_size_difference) + new_log_content = self.get_file_lines(path, last_size, file_size_difference) return { - 'content': new_log_info, + 'content': new_log_content, 'next_key': next_retrieval_key } diff --git a/Plugins/ScriptPlugins/SharedGUIDKick.js b/Plugins/ScriptPlugins/SharedGUIDKick.js index c0cc3a95e..ae3bc60bf 100644 --- a/Plugins/ScriptPlugins/SharedGUIDKick.js +++ b/Plugins/ScriptPlugins/SharedGUIDKick.js @@ -11,8 +11,12 @@ var plugin = { // 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) { + // 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.NetworkId === 3150799945255696069 || + gameEvent.Origin.NetworkId === 5859032128210324569 || + gameEvent.Origin.NetworkId === 2908745942105435771 || + gameEvent.Origin.NetworkId === -6492697076432899192) { gameEvent.Origin.Kick('Your GUID is generic. Delete players/guids.dat and rejoin', _IW4MAdminClient); } }