feat(assist): fixed geoip-unknown ip

This commit is contained in:
Taha Yassine Kraiem 2022-04-26 12:44:07 +02:00
parent 45c59b22af
commit 5b8eddc0e1

View file

@ -220,8 +220,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);
}
}
}
}