(ver = 4)
| 2 | import { printRed } from "./colorOut.js"; |
| 3 | |
| 4 | function getLocalIPv(ver = 4) { |
| 5 | const ips = [] |
| 6 | const inter = os.networkInterfaces() |
| 7 | // console.dir(inter, { depth: null }) |
| 8 | for (let net in inter) { |
| 9 | |
| 10 | // console.dir(net, { depth: null }) |
| 11 | // console.log() |
| 12 | for (let netPort of inter[net]) { |
| 13 | // netPort = inter[net][netPort] |
| 14 | // console.dir(netPort, { depth: null }) |
| 15 | if (netPort.family === `IPv${ver}`) { |
| 16 | // console.dir(netPort, { depth: null }) |
| 17 | ips.push(netPort.address) |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | // console.log() |
| 22 | // console.dir(ips, { depth: null }) |
| 23 | return ips |
| 24 | } |
| 25 | |
| 26 | async function fetchUrl(url, opts = {}, timeout = 6000) { |
| 27 | const controller = new AbortController(); |
nothing calls this directly
no outgoing calls
no test coverage detected