diff --git a/Client/controllers/clientController.js b/Client/controllers/clientController.js index 33edafd..3170594 100644 --- a/Client/controllers/clientController.js +++ b/Client/controllers/clientController.js @@ -51,9 +51,10 @@ async function checkLocalIP() { line[1] = String(line[1]).replace(/(\\r|\\n)/g, "").trim(); return line; }); - log.DEBUG("Parsed IP Config Results: ", networkConfigLines); - log.DEBUG("Local IP address: ", networkConfigLines['IPv4Address']); - return networkConfigLines['IPv4Address']; + networkConfig = Object.fromEntries(networkConfigLines); + log.DEBUG("Parsed IP Config Results: ", networkConfig); + log.DEBUG("Local IP address: ", networkConfig['IPv4Address']); + return networkConfig['IPv4Address']; } else { // Linux @@ -67,17 +68,17 @@ async function checkLocalIP() { exports.checkConfig = async function checkConfig() { if (!config.clientConfig.ip) { const ipAddr = await checkLocalIP(); - updateConfigFile('ip', ipAddr); + updateConfig('ip', ipAddr); } if(!config.clientConfig.name) { - const lastOctet = await checkLocalIP().spit('.')[-1]; + const lastOctet = await String(checkLocalIP()).spit('.')[-1]; const clientName = `Radio-Node-${lastOctet}`; - updateConfigFile('name', clientName); + updateConfig('name', clientName); } if(!config.clientConfig.port) { - updateConfigFile('port', 3010); + updateConfig('port', 3010); } } diff --git a/Client/utilities/updateConfig.js b/Client/utilities/updateConfig.js index c1b4945..4774dfa 100644 --- a/Client/utilities/updateConfig.js +++ b/Client/utilities/updateConfig.js @@ -31,7 +31,7 @@ exports.updateId = (updatedId) => { exports.updateConfig = function updateConfig(key, value) { const options = new Options(key, value); - this.updateConfigFile(options, (updatedFiles) => { + updateConfigFile(options, (updatedFiles) => { // Do Something log.DEBUG("Updated config file: ", updatedFiles); }) @@ -43,7 +43,7 @@ exports.updateConfig = function updateConfig(key, value) { * @param options An instance of the Objects class specified to the key being updated * @param callback Callback when the files have been modified */ -exports.updateConfigFile = function updateConfigFile(options, callback){ +function updateConfigFile(options, callback){ replace(options, (error, changedFiles) => { if (error) return console.error('Error occurred:', error); log.DEBUG('Modified files:', changedFiles);