XuelesszzZ 94af2b8e7b 6-30-5 | 1 年間 前 | |
---|---|---|
.. | ||
lib | 1 年間 前 | |
History.md | 1 年間 前 | |
LICENSE.txt | 1 年間 前 | |
README.md | 1 年間 前 | |
package.json | 1 年間 前 |
Get current machine IP, MAC and DNS servers.
DNS servers receive from /etc/resolv.conf
.
$ npm install address
Get IP is sync and get MAC is async for now.
var address = require('address');
// default interface 'eth' on linux, 'en' on osx.
address.ip(); // '192.168.0.2'
address.ipv6(); // 'fe80::7aca:39ff:feb0:e67d'
address.mac(function (err, addr) {
console.log(addr); // '78:ca:39:b0:e6:7d'
});
// local loopback
address.ip('lo'); // '127.0.0.1'
// vboxnet MAC
address.mac('vboxnet', function (err, addr) {
console.log(addr); // '0a:00:27:00:00:00'
});
address(function (err, addrs) {
console.log(addrs.ip, addrs.ipv6, addrs.mac);
// '192.168.0.2', 'fe80::7aca:39ff:feb0:e67d', '78:ca:39:b0:e6:7d'
});
address('vboxnet', function (err, addrs) {
console.log(addrs.ip, addrs.ipv6, addrs.mac);
// '192.168.56.1', null, '0a:00:27:00:00:00'
});
address.interface('IPv4', 'eth1');
// { address: '192.168.1.1', family: 'IPv4', mac: '78:ca:39:b0:e6:7d' }
address.dns(function (err, addrs) {
console.log(addrs);
// ['10.13.2.1', '10.13.2.6']
});
run $ npm run benchmark
18,929 op/s » #ip
17,622 op/s » #ipv6
16,347 op/s » #mac
11,906 op/s » #dns
fengmk2 |
alsotang |
mariodu |
mathieutu |
zhangyuheng |
coolme200 |
---|
This project follows the git-contributor spec, auto updated at Fri Apr 29 2022 20:59:23 GMT+0800
.