Chameleon 变色龙框架修改 cml dev 局域网ip地

2022-11-16  本文已影响0人  sunfkny

获取cli安装目录

cml -v

[INFO] current running chameleon(安装目录)
修改安装目录/configs/config.js
增加一个获取局域网ip地址的函数

function getLocalAddress() {
  let localWlanHost = 'localhost';
  try {
      const ifaces = require('os').networkInterfaces();
      for (let dev in ifaces) {
          ifaces[dev].forEach((details, alias) => {
              if (details.family === 'IPv4' && !details.internal && details.address.startsWith('192')) {
                  localWlanHost = details.address;
              }
          });
      }
    } catch (e) { }
  return localWlanHost;
}

ip获取方式修改为使用上面的函数

  // ip: require('ip').address()
  ip: getLocalAddress()
上一篇 下一篇

猜你喜欢

热点阅读