mirror of
https://github.com/lyz05/danmaku.git
synced 2026-04-27 12:19:56 +08:00
27 lines
715 B
JavaScript
27 lines
715 B
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const libqqwry = require('lib-qqwry');
|
|
const dns = require('dns');
|
|
const qqwry = libqqwry(); //初始化IP库解析器
|
|
|
|
/* GET home page. */
|
|
router.get('/', function (req, res, next) {
|
|
let ip = req.query.name || req.ip;
|
|
dns.lookup(ip, (err, address, family) => {
|
|
let ipL;
|
|
if (err) {
|
|
ipL = { 'ip': ip, 'msg': '域名解析IP失败' };
|
|
} else {
|
|
ip = address
|
|
try {
|
|
ipL = qqwry.searchIP(ip); //查询IP信息
|
|
} catch (e) {
|
|
ipL = { 'ip': ip, 'msg': e };
|
|
}
|
|
}
|
|
res.json(ipL);
|
|
});
|
|
});
|
|
|
|
module.exports = router;
|