* @returns {Record >}
()
| 215 | * }>>} |
| 216 | */ |
| 217 | function 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] |