MCPcopy Index your code
hub / github.com/nodejs/node / networkInterfaces

Function networkInterfaces

lib/os.js:217–245  ·  view source on GitHub ↗

* @returns {Record >}

()

Source from the content-addressed store, hash-verified

215 * }>>}
216 */
217function networkInterfaces() {
218 const data = getInterfaceAddresses();
219 const result = {};
220
221 if (data === undefined)
222 return result;
223 for (let i = 0; i < data.length; i += 7) {
224 const name = data[i];
225 const entry = {
226 address: data[i + 1],
227 netmask: data[i + 2],
228 family: data[i + 3],
229 mac: data[i + 4],
230 internal: data[i + 5],
231 cidr: getCIDR(data[i + 1], data[i + 2], data[i + 3]),
232 };
233 const scopeid = data[i + 6];
234 if (scopeid !== -1)
235 entry.scopeid = scopeid;
236
237 const existing = result[name];
238 if (existing !== undefined)
239 ArrayPrototypePush(existing, entry);
240 else
241 result[name] = [entry];
242 }
243
244 return result;
245}
246
247/**
248 * @param {number} [pid]

Callers 1

mainFunction · 0.85

Calls 1

getCIDRFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…