ip-api.js
458 Bytes
const IP2Region = require('ip2region');
const logger = global.yoho.logger;
const ipQuery = new IP2Region();
async function getIsp(ip) {
try {
const result = ipQuery.search(ip);
return {
isp: result.isp,
region: result.province,
city: result.city,
country: result.country
};
} catch (e) {
logger.error(e);
return {};
}
}
module.exports = {
getIsp
};