pax_global_header00006660000000000000000000000064131475167340014525gustar00rootroot0000000000000052 comment=f17f63e7eb38e45abf64d90612774eb98b59cee2 address-1.0.3/000077500000000000000000000000001314751673400131535ustar00rootroot00000000000000address-1.0.3/.gitignore000066400000000000000000000001631314751673400151430ustar00rootroot00000000000000coverage *.seed *.log *.csv *.dat *.out *.pid *.gz pids logs results node_modules npm-debug.log .DS_Store .idea/address-1.0.3/.travis.yml000066400000000000000000000002061314751673400152620ustar00rootroot00000000000000sudo: false language: node_js node_js: - '8' - '6' - '4' script: 'npm run test-travis' after_script: 'npm i codecov && codecov' address-1.0.3/AUTHORS000066400000000000000000000004121314751673400142200ustar00rootroot00000000000000# Ordered by date of first contribution. # Auto-generated by 'contributors' on Wed, 05 Aug 2015 23:46:41 GMT. # https://github.com/xingrz/node-contributors fengmk2 (http://fengmk2.com) alsotang (https://github.com/alsotang) address-1.0.3/History.md000066400000000000000000000015151314751673400151400ustar00rootroot00000000000000 1.0.3 / 2017-08-24 ================== **fixes** * [[`ed491c5`](http://github.com/node-modules/address/commit/ed491c5bd353118e4e4d384f47f13c3e1cfeb80e)] - fix: ignore wrong mac address on node 8.x (#10) (fengmk2 <>) 1.0.2 / 2017-05-26 ================== * fix: win32 get mac failed (#9) 1.0.1 / 2016-09-30 ================== * test: remove 0.12 * fix: search interface before family match * add contributors 1.0.0 / 2015-08-06 ================== * chore: use npm scripts instead of Makefile * add benchmark 0.0.3 / 2013-11-04 ================== * get the first not local ip when interface not exists 0.0.2 / 2013-08-08 ================== * use networkInterface() to get mac fix #3 0.0.1 / 2013-07-31 ================== * ip(), ipv6(), mac(), dns() work on osx and linux now. * first commit address-1.0.3/LICENSE.txt000066400000000000000000000022171314751673400150000ustar00rootroot00000000000000This software is licensed under the MIT License. Copyright (C) 2013 - 2014 fengmk2 Copyright (C) 2015 - 2016 node-modules Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. address-1.0.3/README.md000066400000000000000000000047201314751673400144350ustar00rootroot00000000000000address ======= [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![Gittip][gittip-image]][gittip-url] [![David deps][david-image]][david-url] [![npm download][download-image]][download-url] [npm-image]: https://img.shields.io/npm/v/address.svg?style=flat-square [npm-url]: https://npmjs.org/package/address [travis-image]: https://img.shields.io/travis/node-modules/address.svg?style=flat-square [travis-url]: https://travis-ci.org/node-modules/address [coveralls-image]: https://img.shields.io/coveralls/node-modules/address.svg?style=flat-square [coveralls-url]: https://coveralls.io/r/node-modules/address?branch=master [gittip-image]: https://img.shields.io/gittip/fengmk2.svg?style=flat-square [gittip-url]: https://www.gittip.com/fengmk2/ [david-image]: https://img.shields.io/david/node-modules/address.svg?style=flat-square [david-url]: https://david-dm.org/node-modules/address [download-image]: https://img.shields.io/npm/dm/address.svg?style=flat-square [download-url]: https://npmjs.org/package/address Get current machine IP, MAC and DNS servers. DNS servers receive from `/etc/resolv.conf`. ## Install ```bash $ npm install address ``` ## Usage Get IP is sync and get MAC is async for now. ```js 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' }); ``` ### Get all addresses: IPv4, IPv6 and MAC ```js 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' }); ``` ### Get an interface info with family ```js address.interface('IPv4', 'eth1'); // { address: '192.168.1.1', family: 'IPv4', mac: '78:ca:39:b0:e6:7d' } ``` ### Get DNS servers ```js address.dns(function (err, addrs) { console.log(addrs); // ['10.13.2.1', '10.13.2.6'] }); ``` ## benchmark run `$ npm run benchmark` ``` 18,929 op/s » #ip 17,622 op/s » #ipv6 16,347 op/s » #mac 11,906 op/s » #dns ``` ## License [MIT](LICENSE.txt) address-1.0.3/benchmark/000077500000000000000000000000001314751673400151055ustar00rootroot00000000000000address-1.0.3/benchmark/address.benchmark.js000066400000000000000000000011001314751673400210110ustar00rootroot00000000000000var Benchmark = require('benchmark'); var benchmarks = require('beautify-benchmark'); var suite = new Benchmark.Suite(); var address = require('..'); var os = require('os'); suite.add('os.platform()', function() { os.platform(); }); suite.on('cycle', function(event) { benchmarks.add(event.target); }); suite.on('start', function(event) { console.log('\n Starting...', process.version, Date()); }); suite.on('complete', function done() { benchmarks.log(); }); suite.run({ 'async': false }); // os.platform() x 67,436,816 ops/sec ±1.56% (84 runs sampled)address-1.0.3/lib/000077500000000000000000000000001314751673400137215ustar00rootroot00000000000000address-1.0.3/lib/address.js000066400000000000000000000140071314751673400157060ustar00rootroot00000000000000'use strict'; var os = require('os'); var fs = require('fs'); var child = require('child_process'); var DEFAULT_RESOLV_FILE = '/etc/resolv.conf'; function getInterfaceName() { var val = 'eth'; var platform = os.platform(); if (platform === 'darwin') { val = 'en'; } else if (platform === 'win32') { val = null; } return val; } function getIfconfigCMD() { if (os.platform() === 'win32') { return 'ipconfig/all'; } return '/sbin/ifconfig'; } /** * Get all addresses. * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @param {Function(err, addr)} callback * - {Object} addr { * - {String} ip * - {String} ipv6 * - {String} mac * } */ function address(interfaceName, callback) { if (typeof interfaceName === 'function') { callback = interfaceName; interfaceName = null; } var addr = { ip: address.ip(interfaceName), ipv6: address.ipv6(interfaceName), mac: null }; address.mac(interfaceName, function (err, mac) { if (mac) { addr.mac = mac; } callback(err, addr); }); } address.interface = function (family, name) { var interfaces = os.networkInterfaces(); var noName = !name; name = name || getInterfaceName(); family = family || 'IPv4'; for (var i = -1; i < 8; i++) { var interfaceName = name + (i >= 0 ? i : ''); // support 'lo' and 'lo0' var items = interfaces[interfaceName]; if (items) { for (var j = 0; j < items.length; j++) { var item = items[j]; if (item.family === family) { return item; } } } } if (noName) { // filter 127.0.0.1, get the first ip for (var k in interfaces) { var items = interfaces[k]; for (var i = 0; i < items.length; i++) { var item = items[i]; if (item.family === family && item.address !== '127.0.0.1') { return item; } } } } return; }; /** * Get current machine IPv4 * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @return {String} IP address */ address.ip = function (interfaceName) { var item = address.interface('IPv4', interfaceName); return item && item.address; }; /** * Get current machine IPv6 * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @return {String} IP address */ address.ipv6 = function (interfaceName) { var item = address.interface('IPv6', interfaceName); return item && item.address; }; // osx start line 'en0: flags=8863 mtu 1500' // linux start line 'eth0 Link encap:Ethernet HWaddr 00:16:3E:00:0A:29 ' var MAC_OSX_START_LINE = /^(\w+)\:\s+flags=/; var MAC_LINUX_START_LINE = /^(\w+)\s{2,}link encap:\w+/i; // ether 78:ca:39:b0:e6:7d // HWaddr 00:16:3E:00:0A:29 var MAC_RE = address.MAC_RE = /(?:ether|HWaddr)\s+((?:[a-z0-9]{2}\:){5}[a-z0-9]{2})/i; // osx: inet 192.168.2.104 netmask 0xffffff00 broadcast 192.168.2.255 // linux: inet addr:10.125.5.202 Bcast:10.125.15.255 Mask:255.255.240.0 var MAC_IP_RE = address.MAC_IP_RE = /inet\s(?:addr\:)?(\d+\.\d+\.\d+\.\d+)/; function getMAC(content, interfaceName, matchIP) { var lines = content.split('\n'); for (var i = 0; i < lines.length; i++) { var line = lines[i].trimRight(); var m = MAC_OSX_START_LINE.exec(line) || MAC_LINUX_START_LINE.exec(line); if (!m) { continue; } // check interface name var name = m[1]; if (name.indexOf(interfaceName) !== 0) { continue; } var ip = null; var mac = null; var match = MAC_RE.exec(line); if (match) { mac = match[1]; } i++; while (true) { line = lines[i]; if (!line || MAC_OSX_START_LINE.exec(line) || MAC_LINUX_START_LINE.exec(line)) { i--; break; // hit next interface, handle next interface } if (!mac) { match = MAC_RE.exec(line); if (match) { mac = match[1]; } } if (!ip) { match = MAC_IP_RE.exec(line); if (match) { ip = match[1]; } } i++; } if (ip === matchIP) { return mac; } } } /** * Get current machine MAC address * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @param {Function(err, address)} callback */ address.mac = function (interfaceName, callback) { if (typeof interfaceName === 'function') { callback = interfaceName; interfaceName = null; } interfaceName = interfaceName || getInterfaceName(); var item = address.interface('IPv4', interfaceName); if (!item) { return callback(); } // https://github.com/nodejs/node/issues/13581 // bug in node 7.x and <= 8.4.0 if (!process.env.CI && (item.mac === 'ff:00:00:00:00:00' || item.mac === '00:00:00:00:00:00')) { // wrong address, ignore it item.mac = ''; } if (item.mac) { return callback(null, item.mac); } child.exec(getIfconfigCMD(), {timeout: 5000}, function (err, stdout, stderr) { if (err || !stdout) { return callback(err); } var mac = getMAC(stdout || '', interfaceName, item.address); callback(null, mac); }); }; // nameserver 172.24.102.254 var DNS_SERVER_RE = /^nameserver\s+(\d+\.\d+\.\d+\.\d+)$/i; /** * Get DNS servers. * * @param {String} [filepath] resolv config file path. default is '/etc/resolv.conf'. * @param {Function(err, servers)} callback */ address.dns = function (filepath, callback) { if (typeof filepath === 'function') { callback = filepath; filepath = null; } filepath = filepath || DEFAULT_RESOLV_FILE; fs.readFile(filepath, 'utf8', function (err, content) { if (err) { return callback(err); } var servers = []; content = content || ''; var lines = content.split('\n'); for (var i = 0; i < lines.length; i++) { var line = lines[i].trim(); var m = DNS_SERVER_RE.exec(line); if (m) { servers.push(m[1]); } } callback(null, servers); }); }; module.exports = address; address-1.0.3/package.json000066400000000000000000000022671314751673400154500ustar00rootroot00000000000000{ "name": "address", "version": "1.0.3", "description": "Get current machine IP, MAC and DNS servers.", "main": "lib/address.js", "files": [ "lib" ], "scripts": { "test": "mocha --check-leaks -R spec -t 5000 test/*.test.js", "test-cov": "istanbul cover node_modules/.bin/_mocha -- --check-leaks -t 5000 test/*.test.js", "test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- --check-leaks -t 5000 test/*.test.js", "benchmark": "matcha", "autod": "autod -w --prefix '^'", "cnpm": "npm install --registry=https://registry.npm.taobao.org", "contributors": "contributors -f plain -o AUTHORS" }, "dependencies": {}, "devDependencies": { "contributors": "*", "istanbul": "*", "matcha": "*", "mm": "*", "mocha": "*", "pedding": "*", "should": "*", "benchmark": "*", "beautify-benchmark": "*", "webstorm-disable-index": "1" }, "repository": { "type": "git", "url": "git://github.com/node-modules/address.git" }, "keywords": [ "address", "ip", "ipv4", "mac" ], "engines": { "node": ">= 0.12.0" }, "author": "fengmk2 ", "license": "MIT" }address-1.0.3/test/000077500000000000000000000000001314751673400141325ustar00rootroot00000000000000address-1.0.3/test/address.test.js000066400000000000000000000200461314751673400170750ustar00rootroot00000000000000'use strict'; var os = require('os'); var child = require('child_process'); var path = require('path'); var should = require('should'); var mm = require('mm'); var fs = require('fs'); var pedding = require('pedding'); var address = require('../'); var fixtures = path.join(__dirname, 'fixtures'); describe('address.test.js', function () { beforeEach(mm.restore); describe('regex check', function () { it('should MAC_IP_RE pass', function () { should.ok(address.MAC_IP_RE.test(' inet 10.7.84.211 netmask 0xfffffc00 broadcast 10.7.87.255')); should.ok(address.MAC_IP_RE.test(' inet addr:10.125.5.202 Bcast:10.125.15.255 Mask:255.255.240.0')); }); it('should MAC_RE pass', function () { should.ok(address.MAC_RE.test(' ether c4:2c:03:32:d5:3d ')); should.ok(address.MAC_RE.test('eth0 Link encap:Ethernet HWaddr 00:16:3E:00:0A:29 ')); }); }); describe('address()', function () { it('should return first ethernet addrs', function (done) { address(function (err, addr) { should.not.exists(err); addr.should.have.keys('ip', 'ipv6', 'mac'); addr.mac && addr.mac.should.match(/^(?:[a-z0-9]{2}\:){5}[a-z0-9]{2}$/i); addr.ip && addr.ip.should.match(/^\d+\.\d+\.\d+\.\d+$/); done(); }); }); it('should return first ethernet addrs from osx', function (done) { mm(address, 'interface', function () { return {address: '192.168.2.104'}; }); mm.data(child, 'exec', fs.readFileSync(path.join(fixtures, 'darwin.txt'), 'utf8')); address('en', function (err, addr) { should.not.exists(err); addr.should.have.keys('ip', 'ipv6', 'mac'); addr.ip.should.equal('192.168.2.104'); // addr.ipv6.should.match(/^[a-z0-9]{4}\:\:[a-z0-9]{4}\:[a-z0-9]{4}\:[a-z0-9]{4}\:[a-z0-9]{4}$/); addr.mac.should.equal('78:ca:39:b0:e6:7d'); done(); }); }); it('should return first ethernet addrs from linux', function (done) { mm(address, 'interface', function () { return {address: '10.125.5.202'}; }); mm.data(child, 'exec', fs.readFileSync(path.join(fixtures, 'linux.txt'), 'utf8')); address('eth', function (err, addr) { should.not.exists(err); addr.should.have.keys('ip', 'ipv6', 'mac'); addr.ip.should.equal('10.125.5.202'); // addr.ipv6.should.match(/^[a-z0-9]{4}\:\:[a-z0-9]{4}\:[a-z0-9]{4}\:[a-z0-9]{4}\:[a-z0-9]{4}$/); addr.mac.should.equal('00:16:3E:00:0A:29'); done(); }); }); it('should return first vnic interface addrs from osx', function (done) { mm(address, 'ip', function () { return '10.211.55.2'; }); mm.data(child, 'exec', fs.readFileSync(path.join(fixtures, 'darwin.txt'), 'utf8')); address('vnic', function (err, addr) { should.not.exists(err); addr.ip.should.equal('10.211.55.2') // console.log(addr) // addr.mac.should.equal('00:1c:42:00:00:08'); should.not.exists(addr.ipv6); done(); }); }); it('should return first local loopback addrs', function (done) { address('lo', function (err, addr) { should.not.exists(err); addr.should.have.keys('ip', 'ipv6', 'mac'); addr.should.property('ip').with.equal('127.0.0.1'); done(); }); }); it('should return first local loopback addrs from linux', function (done) { mm.data(child, 'exec', fs.readFileSync(path.join(fixtures, 'linux.txt'), 'utf8')); address('lo', function (err, addr) { should.not.exists(err); addr.should.have.keys('ip', 'ipv6', 'mac'); addr.should.property('ip').with.equal('127.0.0.1'); done(); }); }); }); describe('interface()', function () { it('should return interface with family', function () { var item = address.interface(); should.exists(item); item.should.have.property('address'); item.should.have.property('family'); }); }); describe('address.mac()', function () { it.skip('should return mac', function (done) { address.mac(function (err, mac) { should.not.exists(err); should.exists(mac); mac.should.match(/(?:[a-z0-9]{2}\:){5}[a-z0-9]{2}/i); done(); }); }); it('should return mock mac address', function (done) { mm(address, 'interface', function () { return {address: os.platform() === 'linux' ? '10.125.5.202' : '192.168.2.104'}; }); mm.data(child, 'exec', fs.readFileSync(path.join(fixtures, os.platform() + '.txt'), 'utf8')); address.mac(os.platform() === 'linux' ? 'eth' : 'en', function (err, mac) { should.not.exists(err); should.exists(mac); mac.should.match(/(?:[a-z0-9]{2}\:){5}[a-z0-9]{2}/i); done(); }); }); it('should return null when ip not exists', function (done) { mm(address, 'interface', function () { return null; }); address.mac(function (err, mac) { should.not.exists(err); should.not.exists(mac); done(); }); }); it('should return err when ifconfig cmd exec error', function (done) { mm(address, 'interface', function () { return null; }); mm.error(child, 'exec'); address.mac(function (err, mac) { // should.exists(err); should.not.exists(mac); done(); }); }); it('should return mac mock win32', function (done) { mm(os, 'platform', function () { return 'win32'; }); mm(os, 'networkInterfaces', function () { return require(path.join(__dirname, './fixtures/win32_interfaces.json')); }); address.mac(function (err, mac) { should.not.exists(err); should.exists(mac); mac.should.equal('e8:2a:ea:8b:c2:20'); done(); }); }); }); describe('address.ip()', function () { it('should return 127.0.0.1', function () { address.ip('lo').should.equal('127.0.0.1'); }); it('should return the first not 127.0.0.1 interface', function () { mm(os, 'networkInterfaces', function () { return { lo: [ { address: '127.0.0.1', family: 'IPv4', internal: true } ], bond0: [ { address: '10.206.52.79', family: 'IPv4', internal: false } ] }; }); address.ip().should.equal('10.206.52.79'); }); it('should return utun1', function () { mm(os, 'networkInterfaces', function () { return { lo: [ { address: '127.0.0.1', family: 'IPv4', internal: true } ], utun0: [ { address: 'fe80::696:ad3d:eeec:1722', family: 'IPv6', internal: false } ], utun1: [ { address: '10.206.52.79', family: 'IPv4', internal: false } ] }; }); address.ip('utun').should.equal('10.206.52.79'); address.ipv6('utun').should.equal('fe80::696:ad3d:eeec:1722'); }); }); describe('address.dns()', function () { it('should return dns servers from osx', function (done) { mm.data(fs, 'readFile', fs.readFileSync(path.join(fixtures, 'dns_darwin.txt'), 'utf8')); address.dns(function (err, servers) { should.not.exists(err); should.exists(servers); servers.should.be.instanceof(Array); servers.length.should.above(0); done(); }); }); it('should return dns servers from linux', function (done) { mm.data(fs, 'readFile', fs.readFileSync(path.join(fixtures, 'dns_linux.txt'), 'utf8')); address.dns(function (err, servers) { should.not.exists(err); should.exists(servers); servers.should.be.instanceof(Array); servers.length.should.above(0); done(); }); }); it('should return err when fs error', function (done) { mm.error(fs, 'readFile'); address.dns(function (err, servers) { should.exists(err); should.not.exists(servers); done(); }); }); }); }); address-1.0.3/test/fixtures/000077500000000000000000000000001314751673400160035ustar00rootroot00000000000000address-1.0.3/test/fixtures/darwin.txt000066400000000000000000000032141314751673400200300ustar00rootroot00000000000000lo0: flags=8049 mtu 16384 options=3 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863 mtu 1500 options=2b ether c4:2c:03:32:d5:3d media: autoselect (none) status: inactive en1: flags=8863 mtu 1500 ether 78:ca:39:b0:e6:7d inet6 fe80::7aca:39ff:feb0:e67d%en1 prefixlen 64 scopeid 0x5 inet 192.168.2.104 netmask 0xffffff00 broadcast 192.168.2.255 media: autoselect status: active p2p0: flags=8843 mtu 2304 ether 0a:ca:39:b0:e6:7d media: autoselect status: inactive fw0: flags=8863 mtu 4078 lladdr 60:33:4b:ff:fe:93:2a:62 media: autoselect status: inactive vnic0: flags=8843 mtu 1500 options=3 ether 00:1c:42:00:00:08 inet 10.211.55.2 netmask 0xffffff00 broadcast 10.211.55.255 media: autoselect status: active vnic1: flags=8843 mtu 1500 options=3 ether 00:1c:42:00:00:09 inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255 media: autoselect status: active vboxnet0: flags=8843 mtu 1500 ether 0a:00:27:00:00:00 inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255 address-1.0.3/test/fixtures/dns_darwin.txt000066400000000000000000000004251314751673400206750ustar00rootroot00000000000000# # Mac OS X Notice # # This file is not used by the host name and address resolution # or the DNS query routing mechanisms used by most processes on # this Mac OS X system. # # This file is automatically generated. # domain hz.ali.com nameserver 10.13.2.1 nameserver 10.13.2.6address-1.0.3/test/fixtures/dns_linux.txt000066400000000000000000000001421314751673400205440ustar00rootroot00000000000000search tbsite.net options attempts:1 timeout:2 nameserver 10.125.250.210 nameserver 172.24.102.254address-1.0.3/test/fixtures/linux.txt000066400000000000000000000015031314751673400177020ustar00rootroot00000000000000eth0 Link encap:Ethernet HWaddr 00:16:3E:00:0A:29 inet addr:10.125.5.202 Bcast:10.125.15.255 Mask:255.255.240.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4034645 errors:0 dropped:0 overruns:0 frame:0 TX packets:1877492 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:926626551 (883.6 MiB) TX bytes:284125548 (270.9 MiB) Interrupt:14 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:17633 errors:0 dropped:0 overruns:0 frame:0 TX packets:17633 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2496787 (2.3 MiB) TX bytes:2496787 (2.3 MiB)address-1.0.3/test/fixtures/linux_with_can.txt000066400000000000000000000024021314751673400215550ustar00rootroot00000000000000can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 UP RUNNING NOARP MTU:16 Metric:1 RX packets:282 errors:0 dropped:0 overruns:0 frame:0 TX packets:2909 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:1975 (1.9 KiB) TX bytes:20083 (19.6 KiB) Interrupt:55 eth0 Link encap:Ethernet HWaddr 00:18:31:8A:41:C6 inet addr:10.42.193.19 Bcast:10.42.193.255 Mask:255.255.255.0 inet6 addr: fe80::218:31ff:fe8a:41c6/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:305126 errors:0 dropped:12547 overruns:0 frame:0 TX packets:49447 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:63758575 (60.8 MiB) TX bytes:4862291 (4.6 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:2404 errors:0 dropped:0 overruns:0 frame:0 TX packets:2404 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:230580 (225.1 KiB) TX bytes:230580 (225.1 KiB)address-1.0.3/test/fixtures/win32.txt000066400000000000000000000050101314751673400175020ustar00rootroot00000000000000Windows IP Configuration Host Name . . . . . . . . . . . . : CJ-VII Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Ethernet adapter Local Area Connection 2: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Anchorfree HSS Adapter Physical Address. . . . . . . . . : 00-FF-95-E2-1A-B2 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : NVIDIA nForce Networking Controller Physical Address. . . . . . . . . : F8-0F-41-13-79-EE DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::f400:f7b2:ec8a:a958%12(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.0.4(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Monday, 10 September, 2012 00:09:01 Lease Expires . . . . . . . . . . : Monday, 10 September, 2012 06:39:16 Default Gateway . . . . . . . . . : 192.168.0.1 DHCP Server . . . . . . . . . . . : 192.168.0.1 DHCPv6 IAID . . . . . . . . . . . : 184028993 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-16-0A-83-DC-F8-0F-41-13-79-EE DNS Servers . . . . . . . . . . . : 65.32.5.111 65.32.5.112 NetBIOS over Tcpip. . . . . . . . : Enabled Tunnel adapter Teredo Tunneling Pseudo-Interface: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Teredo Tunneling Pseudo-Interface Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes IPv6 Address. . . . . . . . . . . : 2001:0:9d38:953c:43d:ac2:cda7:67b0(Preferred) Link-local IPv6 Address . . . . . : fe80::43d:ac2:cda7:67b0%14(Preferred) Default Gateway . . . . . . . . . : :: NetBIOS over Tcpip. . . . . . . . : Disabled Tunnel adapter isatap.{0B47D2C2-3636-4E51-B6DA-6EEF1042FFAC}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3 Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yesaddress-1.0.3/test/fixtures/win32_cn.txt000066400000000000000000000034461314751673400201750ustar00rootroot00000000000000 Windows IP 配置 无线局域网适配器 无线网络连接: 连接特定的 DNS 后缀 . . . . . . . : hz.ali.com 本地链接 IPv6 地址. . . . . . . . : fe80::8998:cb2d:9da9:8c5a%13 IPv4 地址 . . . . . . . . . . . . : 10.7.85.99 子网掩码 . . . . . . . . . . . . : 255.255.252.0 默认网关. . . . . . . . . . . . . : 10.7.84.1 以太网适配器 本地连接: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . : taobao.ali.com 以太网适配器 VirtualBox Host-Only Network: 连接特定的 DNS 后缀 . . . . . . . : 本地链接 IPv6 地址. . . . . . . . : fe80::28ee:200e:3cb5:b433%18 IPv4 地址 . . . . . . . . . . . . : 192.168.56.1 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 隧道适配器 Teredo Tunneling Pseudo-Interface: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . : 隧道适配器 isatap.taobao.ali.com: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . : 隧道适配器 isatap.{0E89351D-D9F0-4095-B876-BD3F17DC41EE}: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . : 隧道适配器 isatap.hz.ali.com: 媒体状态 . . . . . . . . . . . . : 媒体已断开 连接特定的 DNS 后缀 . . . . . . . : hz.ali.com C:\Users\tangyao>getmac 物理地址 传输名称 =================== ========================================================== 5C-26-0A-84-A3-1B 媒体已断开连接 已禁用 已断开 74-DE-2B-1E-56-85 \Device\Tcpip_{E112BD43-B42F-483A-82DE-D57D4A7ED5E4} 08-00-27-00-C0-F3 \Device\Tcpip_{0E89351D-D9F0-4095-B876-BD3F17DC41EE} address-1.0.3/test/fixtures/win32_interfaces.json000066400000000000000000000014261314751673400220460ustar00rootroot00000000000000{ "无线网络连接": [ { "address": "fe80::f96c:4017:300f:e9ea", "netmask": "ffff:ffff:ffff:ffff::", "family": "IPv6", "mac": "e8:2a:ea:8b:c2:20", "scopeid": 14, "internal": false }, { "address": "10.15.230.231", "netmask": "255.255.254.0", "family": "IPv4", "mac": "e8:2a:ea:8b:c2:20", "internal": false } ], "Loopback Pseudo-Interface 1": [ { "address": "::1", "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "family": "IPv6", "mac": "00:00:00:00:00:00", "scopeid": 0, "internal": true }, { "address": "127.0.0.1", "netmask": "255.0.0.0", "family": "IPv4", "mac": "00:00:00:00:00:00", "internal": true } ] }