File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
const os = require ( 'os' ) ;
2
2
const https = require ( 'https' ) ;
3
-
4
- let interfacesNode = os . networkInterfaces ( ) ;
5
- let interfaces = { } ;
3
+ const config = require ( '../controller/config' ) ;
6
4
7
5
let usableInterfaces = { } ;
8
6
9
7
const requestInterfaces = async ( ) => {
8
+ let interfacesNode = os . networkInterfaces ( ) ;
9
+ let interfaces = { } ;
10
+
10
11
console . log ( "Looking for network interfaces..." ) ;
11
12
for ( let i in interfacesNode ) {
12
13
for ( let j in interfacesNode [ i ] ) {
@@ -53,6 +54,13 @@ const requestInterfaces = async () => {
53
54
for ( let i in usableInterfaces ) {
54
55
console . log ( `Found interface ${ i } with IP ${ usableInterfaces [ i ] } ` ) ;
55
56
}
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
+ }
56
64
}
57
65
58
66
module . exports . requestInterfaces = requestInterfaces ;
You can’t perform that action at this time.
0 commit comments