node.js获取本机Ip, hostName, mac

//获取ip地址
getIPAdress() {
  let interfaces = require('os').networkInterfaces();
  for (var devName in interfaces) {
    var iface = interfaces[devName];
      for (var i = ; i < iface.length; i++) {
        let alias = iface[i];
        if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
          console.log(alias.address);
        }
      }
  }
},
//获取hostName
getHostName() {
  let os = require('os');
  console.log(os.hostname())
},
//获取mac地址,首先要安装getmac依赖-----  npm install --save getmac
require('getmac').getMac(function(err,macAddress){
  console.log(macAddress)
})
上一篇:libmad编译


下一篇:Validform使用ajax详解