summaryrefslogtreecommitdiff
path: root/electron/service/utils/getLocalIP.js
diff options
context:
space:
mode:
authorrejbasket <39080670+rejbasket@users.noreply.github.com>2023-05-22 22:33:19 +0200
committerGitHub <noreply@github.com>2023-05-22 22:33:19 +0200
commitef6f6580df6e8fbce913eecc1fe7e0f8caf1315b (patch)
treec1119a5d1affd44ad27e60cc6981ac98534c518d /electron/service/utils/getLocalIP.js
parentda54f104e6bf5d0e98f7479cf1d060c76e0b01f2 (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.js17
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
+ }
+ }
+ }
+}