mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-18 07:44:50 +08:00
更新
This commit is contained in:
27
utils/net.js
Normal file
27
utils/net.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user