diff --git a/api/hooks/sdtdLogs/handleLogLine.js b/api/hooks/sdtdLogs/handleLogLine.js index 1eb0ecf09..5d06a4395 100644 --- a/api/hooks/sdtdLogs/handleLogLine.js +++ b/api/hooks/sdtdLogs/handleLogLine.js @@ -1,4 +1,4 @@ -const geoip = require('geoip-country'); +const geoip = require('geoip-lite'); const _ = require('lodash'); const replaceQuotes = string => string.substring(1, string.length - 1); diff --git a/package-lock.json b/package-lock.json index 5da1f0f9f..c18f2526f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1193,6 +1193,11 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, "buffers": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", @@ -3533,6 +3538,56 @@ "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==", "dev": true }, + "geoip-lite": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/geoip-lite/-/geoip-lite-1.4.2.tgz", + "integrity": "sha512-1rUNqar68+ldSSlSMdpLZPAM+NRokIDzB2lpQFRHSOaDVqtmy25jTAWe0lM2GqWFeaA35RiLhF8GF0vvL+qOKA==", + "requires": { + "async": "^2.1.1", + "colors": "^1.1.2", + "iconv-lite": "^0.4.13", + "ip-address": "^5.8.9", + "lazy": "^1.0.11", + "rimraf": "^2.5.2", + "yauzl": "^2.9.2" + }, + "dependencies": { + "colors": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "requires": { + "glob": "^7.1.3" + } + } + } + }, "geoip-ultralight": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/geoip-ultralight/-/geoip-ultralight-0.1.5.tgz", @@ -4314,6 +4369,28 @@ } } }, + "ip-address": { + "version": "5.9.4", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-5.9.4.tgz", + "integrity": "sha512-dHkI3/YNJq4b/qQaz+c8LuarD3pY24JqZWfjB8aZx1gtpc2MDILu9L9jpZe1sHpzo/yWFweQVn+U//FhazUxmw==", + "requires": { + "jsbn": "1.1.0", + "lodash": "^4.17.15", + "sprintf-js": "1.1.2" + }, + "dependencies": { + "jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha1-sBMHyym2GKHtJux56RH4A8TaAEA=" + }, + "lodash": { + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + } + } + }, "ipaddr.js": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", @@ -14010,6 +14087,25 @@ } } }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + }, + "dependencies": { + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "requires": { + "pend": "~1.2.0" + } + } + } + }, "yeast": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", diff --git a/package.json b/package.json index c96be05bb..c1fe4314d 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "discord.js": "^11.4.2", "discord.js-commando": "^0.10.0", "dotenv": "^6.2.0", + "geoip-lite": "^1.4.2", "grunt": "1.0.3", "he": "^1.2.0", "lodash": "^4.17.13", diff --git a/test/unit/hooks/sdtdlogs/handleLogLine.test.js b/test/unit/hooks/sdtdlogs/handleLogLine.test.js index b7f579ddf..aa7ed37b9 100644 --- a/test/unit/hooks/sdtdlogs/handleLogLine.test.js +++ b/test/unit/hooks/sdtdlogs/handleLogLine.test.js @@ -29,7 +29,7 @@ describe('sdtdLogs#handleLogLine', () => { time: '14:50:25', uptime: '109.802', msg: - 'Player connected, entityid=3667, name=Catalysm, steamid=76561198028175941, steamOwner=76561198028175941, ip=192.168.1.100', + 'Player connected, entityid=3667, name=Catalysm, steamid=76561198028175941, steamOwner=76561198028175941, ip=2.21.16.8', trace: '', type: 'Log' }; @@ -40,6 +40,8 @@ describe('sdtdLogs#handleLogLine', () => { expect(result.data.playerName).to.eq('Catalysm'); expect(result.data.steamId).to.eq('76561198028175941'); expect(result.data.entityId).to.eq('3667'); + // I don't think it makes sense to check the actual country, just that something gets set + expect(result.data.country).to.not.be.null; }); it('Correctly detects a playerJoined event', () => {