feat(assist): fixed geoip race-condition
This commit is contained in:
parent
ffb82f38fc
commit
60cb0ea9b3
4 changed files with 11 additions and 7 deletions
|
|
@ -268,9 +268,9 @@ function extractSessionInfo(socket) {
|
|||
socket.handshake.query.sessionInfo.userDevice = ua.device.model || null;
|
||||
socket.handshake.query.sessionInfo.userDeviceType = ua.device.type || 'desktop';
|
||||
socket.handshake.query.sessionInfo.userCountry = null;
|
||||
if (geoip !== 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);
|
||||
let country = geoip().country(socket.handshake.headers['x-forwarded-for'] || socket.handshake.address);
|
||||
socket.handshake.query.sessionInfo.userCountry = country.country.isoCode;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,9 +247,9 @@ function extractSessionInfo(socket) {
|
|||
socket.handshake.query.sessionInfo.userDevice = ua.device.model || null;
|
||||
socket.handshake.query.sessionInfo.userDeviceType = ua.device.type || 'desktop';
|
||||
socket.handshake.query.sessionInfo.userCountry = null;
|
||||
if (geoip !== 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);
|
||||
let country = geoip().country(socket.handshake.headers['x-forwarded-for'] || socket.handshake.address);
|
||||
socket.handshake.query.sessionInfo.userCountry = country.country.isoCode;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,9 +218,9 @@ function extractSessionInfo(socket) {
|
|||
socket.handshake.query.sessionInfo.userDevice = ua.device.model || null;
|
||||
socket.handshake.query.sessionInfo.userDeviceType = ua.device.type || 'desktop';
|
||||
socket.handshake.query.sessionInfo.userCountry = null;
|
||||
if (geoip !== 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);
|
||||
let country = geoip().country(socket.handshake.headers['x-forwarded-for'] || socket.handshake.address);
|
||||
socket.handshake.query.sessionInfo.userCountry = country.country.isoCode;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,8 @@ if (process.env.MAXMINDDB_FILE !== undefined) {
|
|||
console.error("!!! please provide a valid value for MAXMINDDB_FILE env var.");
|
||||
}
|
||||
|
||||
module.exports = {geoip}
|
||||
module.exports = {
|
||||
geoip: () => {
|
||||
return geoip;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue