Giter VIP home page Giter VIP logo

Comments (4)

MrTurnRight avatar MrTurnRight commented on May 28, 2024

utils.getIP() 这个函数

只读取了en0 和 en1 的网卡
而我的网卡叫eth0, eth1.。。。。
可以加上这两个吗?

utils.getIp = position => {
  const interfaces = os.networkInterfaces();
  const ips = [];

  if (interfaces.en0) {
    for (let i = 0; i < interfaces.en0.length; i++) {
      if (interfaces.en0[i].family === 'IPv4') {
        ips.push(interfaces.en0[i].address);
      }
    }
  }
  if (interfaces.en1) {
    for (let i = 0; i < interfaces.en1.length; i++) {
      if (interfaces.en1[i].family === 'IPv4') {
        ips.push(interfaces.en1[i].address);
      }
    }
  }
  if (position > 0 && position <= ips.length) {
    return ips[position - 1];
  } else if (ips.length) {
    return ips[0];
  }
  return '127.0.0.1';

};

from easywebpack.

hubcarl avatar hubcarl commented on May 28, 2024

@MrTurnRight 可以的,你这边提个 PR 把 ,我这边出现不了这种场景,主要获取节点的方式不确定,需要你这边根据实际情况获取

from easywebpack.

MrTurnRight avatar MrTurnRight commented on May 28, 2024
utils.getIp = position => {
  const interfaces = os.networkInterfaces();
  const ips = [];
  const netCards = [];

  interfaces.en0 && netCards.push(interfaces.en0)
  interfaces.en1 && netCards.push(interfaces.en1)
  interfaces.eth0 && netCards.push(interfaces.eth0)
  interfaces.eth1 && netCards.push(interfaces.eth1)
  netCards.forEach(card => {
    for (let i = 0; i < card.length; i++) {
      if (card[i].family === 'IPv4') {
        ips.push(card[i].address);
      }
    }
  })
  if (position > 0 && position <= ips.length) {
    return ips[position - 1];
  } else if (ips.length) {
    return ips[0];
  }
  return '127.0.0.1';

};

我没有fork代码,,补上这几行就好了。。。

from easywebpack.

hubcarl avatar hubcarl commented on May 28, 2024

已发布新版本,重新安装依赖即可。

from easywebpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.