mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Merge masterIP and masterPort into masterURL
Merge the masterIP and masterPort configuration entries into a single masterURL entry. Fixes the problem with connecting to an HTTPS version of the master server and also makes it easier to host the master server behind a reverse proxy. This breaks all known code interfacing Clusterio.
This commit is contained in:
1 parent
da99b39402
commit
98900e72dc
15 files changed
+68
-43
No files matched your search
@@ -10,3 +10,6 @@ Breaking Changes
|
|||||||
- Node.js versions below 10 are no longer supported.
|
- Node.js versions below 10 are no longer supported.
|
||||||
- lib/authenticate no longer requires config to be passed to it. Breaks
|
- lib/authenticate no longer requires config to be passed to it. Breaks
|
||||||
playerManager.
|
playerManager.
|
||||||
|
- The masterIP and masterPort config entries has been merged into masterURL.
|
||||||
|
Breaks discordChat, playerManager, serverSelect, trainTeleports and
|
||||||
|
clusterioModel.
|
||||||
@@ -9,7 +9,6 @@ if(process.argv.length < 3){
|
|||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const masterIP = `${config.masterIP}:${config.masterPort}`;
|
|
||||||
const token = config.masterAuthToken
|
const token = config.masterAuthToken
|
||||||
let commandArray = process.argv;
|
let commandArray = process.argv;
|
||||||
commandArray.shift();
|
commandArray.shift();
|
||||||
@@ -24,14 +23,14 @@ let command = commandArray.join(" ");
|
|||||||
let killBiters = `/silent-command local surface=game.surfaces[1] for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do entity.destroy() end`;
|
let killBiters = `/silent-command local surface=game.surfaces[1] for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do entity.destroy() end`;
|
||||||
|
|
||||||
(async ()=>{
|
(async ()=>{
|
||||||
needle.post(masterIP+"/api/runCommand", {
|
needle.post(config.masterURL+"/api/runCommand", {
|
||||||
broadcast:true,
|
broadcast:true,
|
||||||
command,
|
command,
|
||||||
}, needleOptionsWithTokenAuthHeader, (err, resp) => {
|
}, needleOptionsWithTokenAuthHeader, (err, resp) => {
|
||||||
console.log(resp.body)
|
console.log(resp.body)
|
||||||
});
|
});
|
||||||
// setInterval(()=>{
|
// setInterval(()=>{
|
||||||
// needle.post(masterIP+"/api/runCommand", {
|
// needle.post(config.masterURL+"/api/runCommand", {
|
||||||
// broadcast:true,
|
// broadcast:true,
|
||||||
// command: killBiters,
|
// command: killBiters,
|
||||||
// }, needleOptionsWithTokenAuthHeader, (err, resp) => {
|
// }, needleOptionsWithTokenAuthHeader, (err, resp) => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if(!options.name){
|
|||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
needle.post(config.masterIP+":"+config.masterPort+"/api/playerManager/deletePlayer", {
|
needle.post(config.masterURL+"/api/playerManager/deletePlayer", {
|
||||||
name: options.name,
|
name: options.name,
|
||||||
token: options.token
|
token: options.token
|
||||||
}, (err, resp) => {
|
}, (err, resp) => {
|
||||||
|
|||||||
@@ -203,9 +203,7 @@ reboot when you are done, then proceed to the next steps. *reboots matter*
|
|||||||
|
|
||||||
To connect to a master server running on a remote machine, open config.json with your favourite text editor (notepad++). You can also set it up to use the official server browser.
|
To connect to a master server running on a remote machine, open config.json with your favourite text editor (notepad++). You can also set it up to use the official server browser.
|
||||||
|
|
||||||
Change `masterIP `to something like `31.152.123.14` (provided by master server owner)
|
Change `masterURL `to something like `http://203.0.113.33:8080` (provided by master server owner)
|
||||||
|
|
||||||
Change `masterPort` to something like `8080` (provided by master server owner)
|
|
||||||
|
|
||||||
Change `masterAuthToken` to the value found in `secret-api-token.txt` on the master server
|
Change `masterAuthToken` to the value found in `secret-api-token.txt` on the master server
|
||||||
|
|
||||||
|
|||||||
@@ -577,7 +577,7 @@ async function instanceManagement(instanceconfig) {
|
|||||||
console.log("Started instanceManagement();");
|
console.log("Started instanceManagement();");
|
||||||
|
|
||||||
/* Open websocket connection to master */
|
/* Open websocket connection to master */
|
||||||
var socket = ioClient("http://"+config.masterIP+":"+config.masterPort);
|
var socket = ioClient(config.masterURL);
|
||||||
socket.on("hello", data => {
|
socket.on("hello", data => {
|
||||||
console.log("SOCKET | registering slave!");
|
console.log("SOCKET | registering slave!");
|
||||||
socket.emit("registerSlave", {
|
socket.emit("registerSlave", {
|
||||||
@@ -710,15 +710,15 @@ async function instanceManagement(instanceconfig) {
|
|||||||
}
|
}
|
||||||
global.mac = mac;
|
global.mac = mac;
|
||||||
payload.mac = mac;
|
payload.mac = mac;
|
||||||
// console.log("Registered our presence with master "+config.masterIP+" at " + payload.time);
|
// console.log("Registered our presence with master "+config.masterURL+" at " + payload.time);
|
||||||
needle.post(config.masterIP + ":" + config.masterPort + '/api/getID', payload, needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
needle.post(config.masterURL + '/api/getID', payload, needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
||||||
if (err && err.code != "ECONNRESET"){
|
if (err && err.code != "ECONNRESET"){
|
||||||
console.error("We got problems, something went wrong when contacting master"+config.masterIP+" at " + payload.time);
|
console.error("We got problems, something went wrong when contacting master "+config.masterURL+" at " + payload.time);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
} else if (response && response.body) {
|
} else if (response && response.body) {
|
||||||
// In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care.
|
// In the future we might be interested in whether or not we actually manage to send it, but honestly I don't care.
|
||||||
if(response.body !== "ok") {
|
if(response.body !== "ok") {
|
||||||
console.log("Got no \"ok\" while registering our precense with master "+config.masterIP+" at " + payload.time);
|
console.log("Got no \"ok\" while registering our precense with master "+config.masterURL+" at " + payload.time);
|
||||||
console.log(response.body);
|
console.log(response.body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -744,7 +744,7 @@ async function instanceManagement(instanceconfig) {
|
|||||||
modName: modHashes[i].modName,
|
modName: modHashes[i].modName,
|
||||||
hash: modHashes[i].hash,
|
hash: modHashes[i].hash,
|
||||||
};
|
};
|
||||||
needle.post(config.masterIP + ":" + config.masterPort + '/api/checkMod', payload, needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
needle.post(config.masterURL + '/api/checkMod', payload, needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
||||||
if(err) console.error("Unable to contact master server /api/checkMod! Please check your config.json.");
|
if(err) console.error("Unable to contact master server /api/checkMod! Please check your config.json.");
|
||||||
if(response && body && body == "found") {
|
if(response && body && body == "found") {
|
||||||
console.log("master has mod "+modHashes[i].modName);
|
console.log("master has mod "+modHashes[i].modName);
|
||||||
@@ -754,7 +754,7 @@ async function instanceManagement(instanceconfig) {
|
|||||||
console.log("Sending mod: " + mod);
|
console.log("Sending mod: " + mod);
|
||||||
// Send mods master says it wants
|
// Send mods master says it wants
|
||||||
// response.body is a string which is a modName.zip
|
// response.body is a string which is a modName.zip
|
||||||
var req = request.post({url: "http://"+config.masterIP + ":" + config.masterPort + '/api/uploadMod',
|
var req = request.post({url: config.masterURL + '/api/uploadMod',
|
||||||
headers: {
|
headers: {
|
||||||
"x-access-token": config.masterAuthToken,
|
"x-access-token": config.masterAuthToken,
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -7,8 +7,8 @@
|
|||||||
"__comment1": "IP players should connect to to join your servers, should be portforwarded and stuff",
|
"__comment1": "IP players should connect to to join your servers, should be portforwarded and stuff",
|
||||||
"publicIP": "localhost",
|
"publicIP": "localhost",
|
||||||
|
|
||||||
"__comment2": "IP the master web server runs at, can be ignored on the master system",
|
"__comment2": "URL the master web server runs at, can be ignored on the master system. Must not end with a slash",
|
||||||
"masterIP": "localhost",
|
"masterURL": "http://localhost:8080",
|
||||||
|
|
||||||
"__commentMasterPort": "HTTP port for the master to listen to",
|
"__commentMasterPort": "HTTP port for the master to listen to",
|
||||||
"masterPort": 8080,
|
"masterPort": 8080,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = function(config){
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let instance = instances[instanceID];
|
let instance = instances[instanceID];
|
||||||
if(!instance){
|
if(!instance){
|
||||||
needle.get(config.masterIP+":"+config.masterPort+ '/api/slaves', (err, response) => {
|
needle.get(config.masterURL + '/api/slaves', (err, response) => {
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
console.log("Unable to get JSON master/api/slaves, master might be unaccessible");
|
console.log("Unable to get JSON master/api/slaves, master might be unaccessible");
|
||||||
} else if (response && response.body) {
|
} else if (response && response.body) {
|
||||||
|
|||||||
@@ -25,9 +25,14 @@ class UPSdisplay {
|
|||||||
let UPS = Math.round(ticksInPeriod / (timePeriod/1000));
|
let UPS = Math.round(ticksInPeriod / (timePeriod/1000));
|
||||||
// console.log("UPS: " + UPS);
|
// console.log("UPS: " + UPS);
|
||||||
try{
|
try{
|
||||||
needle.post(this.config.masterIP+':'+this.config.masterPort+'/api/editSlaveMeta', {instanceID: this.config.unique, password: this.config.clientPassword, meta: {UPS:UPS, tick:this.tick}}, {headers: {'x-access-token': this.config.masterAuthToken}}, function(err, resp) {
|
needle.post(
|
||||||
// success?
|
this.config.masterURL+'/api/editSlaveMeta',
|
||||||
});
|
{instanceID: this.config.unique, password: this.config.clientPassword, meta: {UPS:UPS, tick:this.tick}},
|
||||||
|
{headers: {'x-access-token': this.config.masterAuthToken}},
|
||||||
|
function(err, resp) {
|
||||||
|
// success?
|
||||||
|
}
|
||||||
|
);
|
||||||
} catch (err){
|
} catch (err){
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,9 +78,14 @@ module.exports = class remoteCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Recorded flows, copper plate since last time: " + payload["copper-plate"]);
|
console.log("Recorded flows, copper plate since last time: " + payload["copper-plate"]);
|
||||||
needle.post(that.config.masterIP + ":" + that.config.masterPort + '/api/logStats', {timestamp: timestamp, instanceID: that.config.unique, data: payload}, needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
needle.post(
|
||||||
// we did it, keep going
|
that.config.masterURL + '/api/logStats',
|
||||||
});
|
{timestamp: timestamp, instanceID: that.config.unique, data: payload},
|
||||||
|
needleOptionsWithTokenAuthHeader,
|
||||||
|
function (err, response, body) {
|
||||||
|
// we did it, keep going
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
oldTimestamp = timestamp;
|
oldTimestamp = timestamp;
|
||||||
oldFlowStats = totalFlows;
|
oldFlowStats = totalFlows;
|
||||||
@@ -105,7 +110,7 @@ module.exports = class remoteCommands {
|
|||||||
g[0] = g[0].replace("\u0000", "");
|
g[0] = g[0].replace("\u0000", "");
|
||||||
// console.log("exporting " + JSON.stringify(g));
|
// console.log("exporting " + JSON.stringify(g));
|
||||||
// send our entity and count to the master for him to keep track of
|
// send our entity and count to the master for him to keep track of
|
||||||
needle.post(that.config.masterIP + ":" + that.config.masterPort + '/api/place', {
|
needle.post(that.config.masterURL + '/api/place', {
|
||||||
name: g[0],
|
name: g[0],
|
||||||
count: g[1],
|
count: g[1],
|
||||||
instanceName: instance, // name of instance
|
instanceName: instance, // name of instance
|
||||||
@@ -168,7 +173,7 @@ module.exports = class remoteCommands {
|
|||||||
// request our items, one item at a time
|
// request our items, one item at a time
|
||||||
for (let i = 0; i < Object.keys(preparedPackage).length; i++) {
|
for (let i = 0; i < Object.keys(preparedPackage).length; i++) {
|
||||||
// console.log(preparedPackage[Object.keys(preparedPackage)[i]]);
|
// console.log(preparedPackage[Object.keys(preparedPackage)[i]]);
|
||||||
needle.post(that.config.masterIP + ":" + that.config.masterPort + '/api/remove', preparedPackage[Object.keys(preparedPackage)[i]], needleOptionsWithTokenAuthHeader, function (err, response, body) {
|
function callback(err, response, body) {
|
||||||
if (response && response.body && typeof response.body == "object") {
|
if (response && response.body && typeof response.body == "object") {
|
||||||
// buffer confirmed orders
|
// buffer confirmed orders
|
||||||
confirmedOrders[confirmedOrders.length] = {name:response.body.name,count:response.body.count}
|
confirmedOrders[confirmedOrders.length] = {name:response.body.name,count:response.body.count}
|
||||||
@@ -176,7 +181,13 @@ module.exports = class remoteCommands {
|
|||||||
console.log(`Imported ${response.body.count} ${response.body.name} from master`);
|
console.log(`Imported ${response.body.count} ${response.body.name} from master`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
needle.post(
|
||||||
|
that.config.masterURL + '/api/remove',
|
||||||
|
preparedPackage[Object.keys(preparedPackage)[i]],
|
||||||
|
needleOptionsWithTokenAuthHeader,
|
||||||
|
callback
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// if we got some confirmed orders
|
// if we got some confirmed orders
|
||||||
// console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders));
|
// console.log("Importing " + confirmedOrders.length + " items! " + JSON.stringify(confirmedOrders));
|
||||||
@@ -195,7 +206,7 @@ module.exports = class remoteCommands {
|
|||||||
// COMBINATOR SIGNALS ---------------------------------------------------------
|
// COMBINATOR SIGNALS ---------------------------------------------------------
|
||||||
// get inventory from Master and RCON it to our slave
|
// get inventory from Master and RCON it to our slave
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
needle.get(that.config.masterIP + ":" + that.config.masterPort + '/api/inventory', function (err, response, body) {
|
needle.get(that.config.masterURL + '/api/inventory', function (err, response, body) {
|
||||||
if(err){
|
if(err){
|
||||||
console.error("Unable to get JSON master/api/inventory, master might be unaccessible");
|
console.error("Unable to get JSON master/api/inventory, master might be unaccessible");
|
||||||
} else if (response && response.body) {
|
} else if (response && response.body) {
|
||||||
@@ -307,7 +318,7 @@ module.exports = class remoteCommands {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let instance = this.instances[instanceID];
|
let instance = this.instances[instanceID];
|
||||||
if(!instance){
|
if(!instance){
|
||||||
needle.get(this.config.masterIP+":"+this.config.masterPort+ '/api/slaves', { compressed: true }, (err, response) => {
|
needle.get(this.config.masterURL + '/api/slaves', { compressed: true }, (err, response) => {
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
console.log("Unable to get JSON master/api/slaves, master might be unaccessible");
|
console.log("Unable to get JSON master/api/slaves, master might be unaccessible");
|
||||||
} else if (response && response.body) {
|
} else if (response && response.body) {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ module.exports = class remoteCommands {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let instance = this.instances[instanceID];
|
let instance = this.instances[instanceID];
|
||||||
if(!instance){
|
if(!instance){
|
||||||
needle.get(this.config.masterIP+":"+this.config.masterPort+ '/api/slaves', { compressed: true }, (err, response) => {
|
needle.get(this.config.masterURL + '/api/slaves', { compressed: true }, (err, response) => {
|
||||||
if(err || response.statusCode != 200) {
|
if(err || response.statusCode != 200) {
|
||||||
console.log("Unable to get JSON master/api/slaves, master might be unaccessible");
|
console.log("Unable to get JSON master/api/slaves, master might be unaccessible");
|
||||||
} else if (response && response.body) {
|
} else if (response && response.body) {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function handleInventory(json, config, callback){
|
|||||||
}
|
}
|
||||||
//console.log("Requesting: "+JSON.stringify(request));
|
//console.log("Requesting: "+JSON.stringify(request));
|
||||||
// request the difference from master
|
// request the difference from master
|
||||||
needle.post(config.masterIP + ":" + config.masterPort + '/api/remove', request, {json:true,headers: {'x-access-token': config.masterAuthToken}}, function (err, response, body) {
|
function callback(err, response, body) {
|
||||||
if (!err && response && response.body && (typeof response.body == "object" || isJson(response.body))) {
|
if (!err && response && response.body && (typeof response.body == "object" || isJson(response.body))) {
|
||||||
// confirmed orders, already removed from master inventory
|
// confirmed orders, already removed from master inventory
|
||||||
//response.body.name: response.body.count
|
//response.body.name: response.body.count
|
||||||
@@ -70,7 +70,13 @@ function handleInventory(json, config, callback){
|
|||||||
} else {
|
} else {
|
||||||
collectStacks(false);
|
collectStacks(false);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
needle.post(
|
||||||
|
config.masterURL + '/api/remove',
|
||||||
|
request,
|
||||||
|
{json:true,headers: {'x-access-token': config.masterAuthToken}},
|
||||||
|
callback
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
collectStacks(false);
|
collectStacks(false);
|
||||||
}
|
}
|
||||||
@@ -87,9 +93,14 @@ function handleInventory(json, config, callback){
|
|||||||
for(let i = 0; i < stackArray.length; i++){
|
for(let i = 0; i < stackArray.length; i++){
|
||||||
if(stackArray[i].count > 0){
|
if(stackArray[i].count > 0){
|
||||||
// console.log("Returning overflow: " + JSON.stringify(stackArray[i]));
|
// console.log("Returning overflow: " + JSON.stringify(stackArray[i]));
|
||||||
needle.post(config.masterIP + ":" + config.masterPort + '/api/place', stackArray[i], {headers: {'x-access-token': config.masterAuthToken}}, function (err, resp, body) {
|
needle.post(
|
||||||
// console.log(body);
|
config.masterURL + '/api/place',
|
||||||
});
|
stackArray[i],
|
||||||
|
{headers: {'x-access-token': config.masterAuthToken}},
|
||||||
|
function (err, resp, body) {
|
||||||
|
// console.log(body);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -127,7 +138,7 @@ function pollInventories(outputFile){
|
|||||||
//return "/silent-command "+'local a="{"for b,c in pairs(game.players)do if c.connected then local d=game.players[b].get_inventory(defines.inventory.player_main).get_contents()local e=game.players[b].get_quickbar().get_contents()local f={}for g=1,game.players[b].force.character_logistic_slot_count do f[g]=game.players[b].character.get_request_slot(g)end;a=a..b..":{inventory:{"for h,i in pairs(d)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;for h,i in pairs(e)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;a=a.."},requestSlots:{"for h,i in pairs(f)do a=a.."['+"'"+'"..i["name"].."'+"'"+']:"..i["count"]..", "end;a=a.."}},"end end;a=a.."}"game.write_file("'+outputFile+'",a)'
|
//return "/silent-command "+'local a="{"for b,c in pairs(game.players)do if c.connected then local d=game.players[b].get_inventory(defines.inventory.player_main).get_contents()local e=game.players[b].get_quickbar().get_contents()local f={}for g=1,game.players[b].force.character_logistic_slot_count do f[g]=game.players[b].character.get_request_slot(g)end;a=a..b..":{inventory:{"for h,i in pairs(d)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;for h,i in pairs(e)do a=a.."['+"'"+'"..h.."'+"'"+']:"..i..","end;a=a.."},requestSlots:{"for h,i in pairs(f)do a=a.."['+"'"+'"..i["name"].."'+"'"+']:"..i["count"]..", "end;a=a.."}},"end end;a=a.."}"game.write_file("'+outputFile+'",a)'
|
||||||
return '/silent-command '+'local a='+"'"+'{"players":{'+"'"+'local b=false;for c,d in pairs(game.players)do if d.connected and d.character then if b then a=a..'+"'"+','+"'"+'else b=true end;local e=game.players[c].get_inventory(defines.inventory.player_main).get_contents()local f=game.players[c].get_quickbar().get_contents()local g={}local z={}for j,k in pairs(e)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for j,k in pairs(f)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for h=1,game.players[c].force.character_logistic_slot_count do g[h]=game.players[c].character.get_request_slot(h)end;a=a..'+"'"+'"'+"'"+'..c..'+"'"+'":{"inventory":{'+"'"+'local i=false;for j,k in pairs(z)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..j..'+"'"+'":'+"'"+'..k end;a=a..'+"'"+'},"requestSlots":{'+"'"+'i=false;for j,k in pairs(g)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..k['+"'"+'name'+"'"+']..'+"'"+'":'+"'"+'..k['+"'"+'count'+"'"+']end;a=a..'+"'"+'}}'+"'"+'end end;a=a.."}}"game.write_file("'+outputFile+'",a,true,0)'
|
return '/silent-command '+'local a='+"'"+'{"players":{'+"'"+'local b=false;for c,d in pairs(game.players)do if d.connected and d.character then if b then a=a..'+"'"+','+"'"+'else b=true end;local e=game.players[c].get_inventory(defines.inventory.player_main).get_contents()local f=game.players[c].get_quickbar().get_contents()local g={}local z={}for j,k in pairs(e)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for j,k in pairs(f)do if z[j] ~= nil then z[j] = z[j] + k else z[j] = k end end for h=1,game.players[c].force.character_logistic_slot_count do g[h]=game.players[c].character.get_request_slot(h)end;a=a..'+"'"+'"'+"'"+'..c..'+"'"+'":{"inventory":{'+"'"+'local i=false;for j,k in pairs(z)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..j..'+"'"+'":'+"'"+'..k end;a=a..'+"'"+'},"requestSlots":{'+"'"+'i=false;for j,k in pairs(g)do if i then a=a..'+"'"+','+"'"+'else i=true end;a=a..'+"'"+'"'+"'"+'..k['+"'"+'name'+"'"+']..'+"'"+'":'+"'"+'..k['+"'"+'count'+"'"+']end;a=a..'+"'"+'}}'+"'"+'end end;a=a.."}}"game.write_file("'+outputFile+'",a,true,0)'
|
||||||
/*
|
/*
|
||||||
needle.post(config.masterIP+':'+config.masterPort+'/api/editSlaveMeta', {instanceID: config.unique, password: config.clientPassword, meta: {UPS:UPS}}, function(err, resp) {
|
needle.post(config.masterURL+'/api/editSlaveMeta', {instanceID: config.unique, password: config.clientPassword, meta: {UPS:UPS}}, function(err, resp) {
|
||||||
// success?
|
// success?
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ const sinon = require("sinon");
|
|||||||
describe("inventoryImports/interfacingFunctions.js", function(){
|
describe("inventoryImports/interfacingFunctions.js", function(){
|
||||||
describe("handleInventory(inventory, config)", function(){
|
describe("handleInventory(inventory, config)", function(){
|
||||||
let config = {
|
let config = {
|
||||||
masterIP:"localhost",
|
masterURL:"http://localhost:8080",
|
||||||
masterPort:8080,
|
|
||||||
masterAuthToken:"",
|
masterAuthToken:"",
|
||||||
}
|
}
|
||||||
it("returns false if given invalid input", function(){
|
it("returns false if given invalid input", function(){
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class ResearchSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initial_request_own_data(callback) {
|
initial_request_own_data(callback) {
|
||||||
const url = `${this.config.masterIP}:${this.config.masterPort}/api/getSlaveMeta`
|
const url = `${this.config.masterURL}/api/getSlaveMeta`
|
||||||
const data = {
|
const data = {
|
||||||
instanceID: this.config.unique,
|
instanceID: this.config.unique,
|
||||||
password: this.config.clientPassword,
|
password: this.config.clientPassword,
|
||||||
@@ -102,7 +102,7 @@ class ResearchSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
request_cluster_data() {
|
request_cluster_data() {
|
||||||
const slaves_data_url = `${this.config.masterIP}:${this.config.masterPort}/api/slaves`
|
const slaves_data_url = `${this.config.masterURL}/api/slaves`
|
||||||
needle.get(slaves_data_url, {compressed:true}, this.sync_researches.bind(this))
|
needle.get(slaves_data_url, {compressed:true}, this.sync_researches.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ class ResearchSync {
|
|||||||
|
|
||||||
this.print_own_contribution()
|
this.print_own_contribution()
|
||||||
|
|
||||||
needle.post(this.config.masterIP + ':' + this.config.masterPort + '/api/editSlaveMeta', {
|
needle.post(this.config.masterURL + '/api/editSlaveMeta', {
|
||||||
instanceID: this.config.unique,
|
instanceID: this.config.unique,
|
||||||
password: this.config.clientPassword,
|
password: this.config.clientPassword,
|
||||||
meta: {research: this.research}
|
meta: {research: this.research}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ describe("researchSync/index.js", function() {
|
|||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
instanceName: "test",
|
instanceName: "test",
|
||||||
masterIP: "localhost",
|
masterURL: "http://localhost:8080",
|
||||||
masterPort: 8080,
|
|
||||||
unique: 99,
|
unique: 99,
|
||||||
clientPassword: "password",
|
clientPassword: "password",
|
||||||
masterAuthToken: "masterToken",
|
masterAuthToken: "masterToken",
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module.exports = class remoteCommands {
|
|||||||
force: force.forceName,
|
force: force.forceName,
|
||||||
forceData: JSON.stringify(force.data),
|
forceData: JSON.stringify(force.data),
|
||||||
};
|
};
|
||||||
needle.post(`${mergedConfig.masterIP}:${mergedConfig.masterPort}/api/logStats`,
|
needle.post(`${mergedConfig.masterURL}/api/logStats`,
|
||||||
request,
|
request,
|
||||||
needleOptionsWithTokenAuthHeader, (err, resp) => {
|
needleOptionsWithTokenAuthHeader, (err, resp) => {
|
||||||
if(!err && resp.body && resp.body.ok == false) console.log("Error calling /api/logStats: " + resp.body);
|
if(!err && resp.body && resp.body.ok == false) console.log("Error calling /api/logStats: " + resp.body);
|
||||||
|
|||||||
Reference in new issue
Block a user