mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-17 15:25:03 +08:00
28 lines
608 B
JavaScript
28 lines
608 B
JavaScript
import os from "os"
|
|
|
|
function getLocalIPv(ver = 4) {
|
|
const ips = []
|
|
const inter = os.networkInterfaces()
|
|
// console.dir(inter, { depth: null })
|
|
for (let net in inter) {
|
|
|
|
// console.dir(net, { depth: null })
|
|
// console.log()
|
|
for (let netPort of inter[net]) {
|
|
// netPort = inter[net][netPort]
|
|
// console.dir(netPort, { depth: null })
|
|
if (netPort.family === `IPv${ver}`) {
|
|
// console.dir(netPort, { depth: null })
|
|
ips.push(netPort.address)
|
|
}
|
|
}
|
|
}
|
|
// console.log()
|
|
// console.dir(ips, { depth: null })
|
|
return ips
|
|
}
|
|
|
|
export {
|
|
getLocalIPv
|
|
}
|