feat(assist): fixed geoip-unknown ip
This commit is contained in:
parent
45c59b22af
commit
5b8eddc0e1
1 changed files with 7 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue