diff options
| author | rejbasket <39080670+rejbasket@users.noreply.github.com> | 2023-05-22 22:33:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-22 22:33:19 +0200 |
| commit | ef6f6580df6e8fbce913eecc1fe7e0f8caf1315b (patch) | |
| tree | c1119a5d1affd44ad27e60cc6981ac98534c518d /electron/service/utils/getLocalIP.js | |
| parent | da54f104e6bf5d0e98f7479cf1d060c76e0b01f2 (diff) | |
Update electron version to v14.2.9 (#2214)
Authored-by: rejbasket
Co-authored-by: Kaalleen
Co-authored-by: Lex Neva
Diffstat (limited to 'electron/service/utils/getLocalIP.js')
| -rw-r--r-- | electron/service/utils/getLocalIP.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/electron/service/utils/getLocalIP.js b/electron/service/utils/getLocalIP.js new file mode 100644 index 00000000..14926ee2 --- /dev/null +++ b/electron/service/utils/getLocalIP.js @@ -0,0 +1,17 @@ +'use strict' + +const os = require('os') + +module.exports = function getLocalIP() { + const interfaces = os.networkInterfaces() + + for (const devName in interfaces) { + const iface = interfaces[devName] + for (let i = 0; i < iface.length; i++) { + const alias = iface[i] + if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) { + return alias.address + } + } + } +} |
