mirror of
https://github.com/Retropex/apolloapi-v2.git
synced 2025-05-29 13:32:30 +02:00
Get network from system for node conf
This commit is contained in:
parent
a90a60a9eb
commit
d42d58ecf8
32
src/utils.js
32
src/utils.js
@ -85,21 +85,23 @@ module.exports.auth = {
|
|||||||
const interfaces = os.networkInterfaces();
|
const interfaces = os.networkInterfaces();
|
||||||
let network = null;
|
let network = null;
|
||||||
|
|
||||||
console.log(interfaces);
|
|
||||||
|
|
||||||
// Check if wlan0 has an associated IP address
|
// Check if wlan0 has an associated IP address
|
||||||
if (interfaces['wlan0'] && interfaces['wlan0'].some(info => info.family === 'IPv4')) {
|
if (
|
||||||
|
interfaces['wlan0'] &&
|
||||||
|
interfaces['wlan0'].some((info) => info.family === 'IPv4')
|
||||||
|
) {
|
||||||
// If wlan0 has an associated IP address, use wlan0
|
// If wlan0 has an associated IP address, use wlan0
|
||||||
network = interfaces['wlan0'].find(info => info.family === 'IPv4').cidr;
|
network = interfaces['wlan0'].find((info) => info.family === 'IPv4').cidr;
|
||||||
} else if (interfaces['eth0'] && interfaces['eth0'].some(info => info.family === 'IPv4')) {
|
} else if (
|
||||||
|
interfaces['eth0'] &&
|
||||||
|
interfaces['eth0'].some((info) => info.family === 'IPv4')
|
||||||
|
) {
|
||||||
// If wlan0 doesn't have an associated IP address but eth0 does, use eth0
|
// If wlan0 doesn't have an associated IP address but eth0 does, use eth0
|
||||||
network = interfaces['eth0'].find(info => info.family === 'IPv4').cidr;
|
network = interfaces['eth0'].find((info) => info.family === 'IPv4').cidr;
|
||||||
} else {
|
} else {
|
||||||
console.log('No IP address associated with wlan0 or eth0');
|
console.log('No IP address associated with wlan0 or eth0');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('LAN IP Address:', network);
|
|
||||||
|
|
||||||
return network;
|
return network;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -175,13 +177,17 @@ module.exports.auth = {
|
|||||||
const defaultConfVariables = defaultConf.match(/^[^=\r\n]+/gm);
|
const defaultConfVariables = defaultConf.match(/^[^=\r\n]+/gm);
|
||||||
|
|
||||||
// Remove variables from settings.nodeUserConf that are also present in defaultConf
|
// Remove variables from settings.nodeUserConf that are also present in defaultConf
|
||||||
const filteredUserConfVariables = userConfVariables.filter(variable => !defaultConfVariables.includes(variable));
|
const filteredUserConfVariables = userConfVariables.filter(
|
||||||
|
(variable) => !defaultConfVariables.includes(variable)
|
||||||
|
);
|
||||||
|
|
||||||
// Join the remaining variables back into a single string
|
if (filteredUserConfVariables.length) {
|
||||||
const filteredUserConf = filteredUserConfVariables.join('\n');
|
// Join the remaining variables back into a single string
|
||||||
|
const filteredUserConf = filteredUserConfVariables.join('\n');
|
||||||
|
|
||||||
// Append the filtered user configuration to the overall configuration
|
// Append the filtered user configuration to the overall configuration
|
||||||
conf += `\n#USER_INPUT_START\n${filteredUserConf}\n#USER_INPUT_END`;
|
conf += `\n#USER_INPUT_START\n${filteredUserConf}\n#USER_INPUT_END`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Writing Bitcoin conf file', conf);
|
console.log('Writing Bitcoin conf file', conf);
|
||||||
|
Loading…
Reference in New Issue
Block a user