Permalink
Browse files

Use geoip-lite

  • Loading branch information...
jkelin committed Aug 18, 2018
1 parent 4e80b2b commit 4b2b26b7fe36643017288396c8968d701ea67a34
Showing with 165 additions and 23 deletions.
  1. +2 −1 package.json
  2. +0 −4 src/globals.d.ts
  3. +3 −8 src/tracker.ts
  4. +160 −10 yarn.lock
View
@@ -14,6 +14,7 @@
"@types/express": "^4.16.0",
"@types/express-handlebars": "^0.0.30",
"@types/fs-extra": "^5.0.4",
"@types/geoip-lite": "^1.1.29",
"@types/lodash": "^4.14.116",
"@types/mongoose": "^5.2.6",
"@types/qs": "^6.5.1",
@@ -35,10 +36,10 @@
"express": "^4.12.2",
"express-handlebars": "^3.0.0",
"fs-extra": "^7.0.0",
"geoip-lite": "^1.3.1",
"influx": "^5.0.7",
"moment": "^2.22.2",
"mongoose": "^5.2.9",
"node-freegeoip": "0.0.1",
"octonode": "^0.9.3",
"qs": "^6.5.2",
"raven": "^2.6.3",
View
@@ -1,7 +1,3 @@
declare module "node-freegeoip" {
function getLocation(ip: string, cb: (err: Error, location: { country_code: string }) => any): void;
}
declare module "octonode" {
interface Commit {
html_url: string;
View
@@ -1,5 +1,5 @@
import winston from "winston";
import freegeoip from "node-freegeoip";
import geoip from "geoip-lite";
import express from "express";
import atob from "atob";
@@ -90,13 +90,8 @@ export async function handleTribesServerData(data: ITribesServerQueryResponse) {
data.players.forEach(timePlayer);
if (!server.country) {
try {
const location = await promisify(freegeoip.getLocation)(server.ip);
server.country = location["country_code"].toLowerCase();
} catch (ex) {
winston.error("Error getting country", ex);
}
const location = geoip.lookup(server.ip);
server.country = location.country.toLowerCase();
}
await server.save()
View
170 yarn.lock

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 4b2b26b

Please sign in to comment.