Skip to content

Commit

Permalink
Use better GeoIP package
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Jul 11, 2020
1 parent cdf2d82 commit 83d475e
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/hooks/sdtdLogs/handleLogLine.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
96 changes: 96 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion test/unit/hooks/sdtdlogs/handleLogLine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
Expand All @@ -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', () => {
Expand Down

0 comments on commit 83d475e

Please sign in to comment.