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