问题描述
我只需要根据他们的计算机了解用户,而不是使用用户注册到数据库。我认为使用计算机的 ip 地址会有所帮助,但如果有其他选择,我愿意了解它。这是我正在使用的代码:
const { networkInterfaces } = require('os');
const getLocalIP = () => {
const nets = networkInterfaces();
const results = Object.create(null);
for (const name of Object.keys(nets)) {
for (const net of nets[name]) {
if (net.family === 'IPv4' && !net.internal) {
if (!results[name]) {
results[name] = [];
}
results[name].push(net.address);
return net.address
}
}
}
}
exports.getLocalIP = getLocalIP
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)