github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/containers/compilers/rump/nodejs/node-wrapper/node_modules/macaddress/README.md (about) 1 node-macaddress 2 =============== 3 4 [](https://travis-ci.org/scravy/node-macaddress) 5 6 Retrieve MAC addresses in Linux, OS X, and Windows. 7 8 A common misconception about MAC addresses is that every *host* had *one* MAC address, 9 while a host may have *multiple* MAC addresses – since *every network interface* may 10 have its own MAC address. 11 12 This library allows to discover the MAC address per network interface and chooses 13 an appropriate interface if all you're interested in is *one* MAC address identifying 14 the host system (see `API + Examples` below). 15 16 **Features:** 17 18 + works on `Linux`, `Mac OS X`, `Windows`, and on most `UNIX` systems. 19 + `node ≥ 0.12` and `io.js` report MAC addresses in `os.networkInterfaces()` 20 this library utilizes this information when available. 21 + also features a sane replacement for `os.networkInterfaces()` 22 (see `API + Examples` below). 23 + works with stoneage node versions ≥ v0.8 (...) 24 25 Usage 26 ----- 27 28 ``` 29 npm install --save macaddress 30 ``` 31 32 ```JavaScript 33 var macaddress = require('macaddress'); 34 ``` 35 36 API + Examples 37 -------------- 38 39 (async) .one(iface, callback) → string 40 (async) .one(callback) → string 41 (async) .all(callback) → { iface: { type: address } } 42 (sync) .networkInterfaces() → { iface: { type: address } } 43 44 --- 45 46 ### `.one([iface], callback)` 47 48 Retrieves the MAC address of the given `iface`. 49 50 If `iface` is omitted, this function automatically chooses an 51 appropriate device (e.g. `eth0` in Linux, `en0` in OS X, etc.). 52 53 **Without `iface` parameter:** 54 55 ```JavaScript 56 macaddress.one(function (err, mac) { 57 console.log("Mac address for this host: %s", mac); 58 }); 59 ``` 60 61 ``` 62 → Mac address for this host: ab:42:de:13:ef:37 63 ``` 64 65 **With `iface` parameter:** 66 67 ```JavaScript 68 macaddress.one('awdl0', function (err, mac) { 69 console.log("Mac address for awdl0: %s", mac); 70 }); 71 ``` 72 73 ``` 74 → Mac address for awdl0: ab:cd:ef:34:12:56 75 ``` 76 77 --- 78 79 ### `.all(callback)` 80 81 Retrieves the MAC addresses for all non-internal interfaces. 82 83 ```JavaScript 84 macaddress.all(function (err, all) { 85 console.log(JSON.stringify(all, null, 2)); 86 }); 87 ``` 88 89 ```JavaScript 90 { 91 "en0": { 92 "ipv6": "fe80::cae0:ebff:fe14:1da9", 93 "ipv4": "192.168.178.20", 94 "mac": "ab:42:de:13:ef:37" 95 }, 96 "awdl0": { 97 "ipv6": "fe80::58b9:daff:fea9:23a9", 98 "mac": "ab:cd:ef:34:12:56" 99 } 100 } 101 ``` 102 103 --- 104 105 ### `.networkInterfaces()` 106 107 A useful replacement of `os.networkInterfaces()`. Reports only non-internal interfaces. 108 109 ```JavaScript 110 console.log(JSON.stringify(macaddress.networkInterfaces(), null, 2)); 111 ``` 112 113 ```JavaScript 114 { 115 "en0": { 116 "ipv6": "fe80::cae0:ebff:fe14:1dab", 117 "ipv4": "192.168.178.22" 118 }, 119 "awdl0": { 120 "ipv6": "fe80::58b9:daff:fea9:23a9" 121 } 122 } 123 ``` 124