Minor bugfixes in getting Windows IP
This commit is contained in:
@@ -35,7 +35,7 @@ async function checkLocalIP() {
|
||||
let ipAddr;
|
||||
if (process.platform === "win32") {
|
||||
// Windows
|
||||
var networkConfig = executeAsyncConsoleCommand("ipconfig");
|
||||
var networkConfig = await executeAsyncConsoleCommand("ipconfig");
|
||||
log.DEBUG('Network Config: ', networkConfig);
|
||||
var networkConfigLines = networkConfig.split("\n").filter(line => {
|
||||
if (!line.includes(":")) return false;
|
||||
@@ -46,8 +46,9 @@ async function checkLocalIP() {
|
||||
|
||||
return true;
|
||||
}).map(line => {
|
||||
line = line.split(':');
|
||||
line[0] = line[0].replace(".", "");
|
||||
line = line.split(':', 1);
|
||||
line[0] = String(line[0]).replace("/\./g", "").trim();
|
||||
line[1] = String(line[1].replace(/[\r|\n]/g, ""))
|
||||
return line;
|
||||
});
|
||||
log.DEBUG("Parsed IP Config Results: ", networkConfigLines);
|
||||
@@ -55,7 +56,7 @@ async function checkLocalIP() {
|
||||
}
|
||||
else {
|
||||
// Linux
|
||||
var networkConfig = executeAsyncConsoleCommand("ip addr");
|
||||
var networkConfig = await executeAsyncConsoleCommand("ip addr");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ exports.checkIn = async () => {
|
||||
// ID was not found in the config, creating a new node
|
||||
reqOptions = new requests.requestOptions("/nodes/newNode", "POST");
|
||||
delete config.clientConfig.id;
|
||||
client.clientConfig.ip = checkLocalIP();
|
||||
config.clientConfig.ip = checkLocalIP();
|
||||
requests.sendHttpRequest(reqOptions, JSON.stringify(config.clientConfig), (responseObject) => {
|
||||
// Update the client's ID if the server accepted it
|
||||
if (responseObject.statusCode === 202) {
|
||||
|
||||
Reference in New Issue
Block a user