()
| 5 | function serveUrls(hosts, port) { |
| 6 | const names = new Set( |
| 7 | (hosts?.length ? hosts : ["127.0.0.1"]).flatMap((host) => { |
| 8 | if (host === "0.0.0.0" || host === "::") return ["127.0.0.1"]; |
| 9 | return [host.includes(":") ? `[${host}]` : host]; |
| 10 | }), |
| 11 | ); |
| 12 | |
| 13 | for (const list of Object.values(os.networkInterfaces())) { |
| 14 | for (const net of list ?? []) { |
| 15 | if (net.internal || net.family !== "IPv4") continue; |
| 16 | names.add(net.address); |
| 17 | } |
| 18 | } |