feat(assist): EE fixed geoip-unknown ip

This commit is contained in:
Taha Yassine Kraiem 2022-04-26 12:47:18 +02:00
parent 5b8eddc0e1
commit 6cacc4ef52
2 changed files with 14 additions and 4 deletions

View file

@ -270,8 +270,13 @@ function extractSessionInfo(socket) {
socket.handshake.query.sessionInfo.userCountry = null;
if (geoip() !== null) {
debug && console.log(`looking for location of ${socket.handshake.headers['x-forwarded-for'] || socket.handshake.address}`);
let country = geoip().country(socket.handshake.headers['x-forwarded-for'] || socket.handshake.address);
socket.handshake.query.sessionInfo.userCountry = country.country.isoCode;
try {
let country = geoip().country(socket.handshake.headers['x-forwarded-for'] || socket.handshake.address);
socket.handshake.query.sessionInfo.userCountry = country.country.isoCode;
} catch (e) {
debug && console.log("geoip-country failed");
debug && console.log(e);
}
}
}
}

View file

@ -249,8 +249,13 @@ function extractSessionInfo(socket) {
socket.handshake.query.sessionInfo.userCountry = null;
if (geoip() !== null) {
debug && console.log(`looking for location of ${socket.handshake.headers['x-forwarded-for'] || socket.handshake.address}`);
let country = geoip().country(socket.handshake.headers['x-forwarded-for'] || socket.handshake.address);
socket.handshake.query.sessionInfo.userCountry = country.country.isoCode;
try {
let country = geoip().country(socket.handshake.headers['x-forwarded-for'] || socket.handshake.address);
socket.handshake.query.sessionInfo.userCountry = country.country.isoCode;
} catch (e) {
debug && console.log("geoip-country failed");
debug && console.log(e);
}
}
}
}