Skip to content

Commit 4d8014d

Browse files
committed
Fixed memory leaking in loadInterfaces.js
1 parent 80472ab commit 4d8014d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

server/util/loadInterfaces.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const os = require('os');
22
const https = require('https');
3-
4-
let interfacesNode = os.networkInterfaces();
5-
let interfaces = {};
3+
const config = require('../controller/config');
64

75
let usableInterfaces = {};
86

97
const requestInterfaces = async () => {
8+
let interfacesNode = os.networkInterfaces();
9+
let interfaces = {};
10+
1011
console.log("Looking for network interfaces...");
1112
for (let i in interfacesNode) {
1213
for (let j in interfacesNode[i]) {
@@ -53,6 +54,13 @@ const requestInterfaces = async () => {
5354
for (let i in usableInterfaces) {
5455
console.log(`Found interface ${i} with IP ${usableInterfaces[i]}`);
5556
}
57+
58+
const currentInterface = await config.getValue("interface");
59+
60+
if (!usableInterfaces[currentInterface]) {
61+
console.warn(`Interface ${currentInterface} not found. Falling back to default.`);
62+
await config.updateValue("interface", Object.keys(usableInterfaces)[0]);
63+
}
5664
}
5765

5866
module.exports.requestInterfaces = requestInterfaces;

0 commit comments

Comments
 (0)