Skip to content

Commit

Permalink
Added setting disableImportsOfEverythingExceptElectricity
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielv123 committed Nov 7, 2018
1 parent 1676dc8 commit 2c6b8be
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -56,6 +56,8 @@ sharedPlugins/serverManager/database/*
sharedPlugins/serverManager/config.json
sharedPlugins/serverManager/secret-api-token.txt
!sharedPlugins/scenario_loader/
sharedPlugins/scenario_loader/scenarios
!sharedPlugins/statisticsExporter/

# File used for marking plugins as disabled
sharedPlugins/*/DISABLED
Expand Down
4 changes: 3 additions & 1 deletion config.json.dist
Expand Up @@ -54,5 +54,7 @@
"mirrorAllChat": false,
"__comment7": "Autosave interval for items in the master storage in milliseconds. Defaults to one minute when set to 0 or not set.",
"autosaveInterval": 600000,
"disablePrometheusPushgateway": false
"disablePrometheusPushgateway": false,
"__comment8": "This setting only affects the master. It makes every import for things that arent 'electricity' return a maximum of 0. Effectively disables teleport chests.",
"disableImportsOfEverythingExceptElectricity": false
}
19 changes: 13 additions & 6 deletions master.js
Expand Up @@ -46,6 +46,7 @@ const base64url = require('base64url');
const moment = require("moment");

// constants
console.log(`Requiring config from ${args.config || './config'}`)
const config = require(args.config || './config');
config.databaseDirectory = args.databaseDirectory || config.databaseDirectory || "./database";
const masterModFolder = path.join(config.databaseDirectory, "/masterMods/");
Expand Down Expand Up @@ -301,7 +302,7 @@ async function shutdown() {
console.log("Plugin "+plugin.pluginConfig.name+" exited in "+(Date.now()-startTime)+"ms");
}
}
console.log("Exited in "+(Date.now()-exitStartTime)+"ms");
console.log("Clusterio cleanly exited in "+(Date.now()-exitStartTime)+"ms");
process.exit(0);
}

Expand Down Expand Up @@ -489,10 +490,12 @@ app.post("/api/place", authenticate.middleware, function(req, res) {
}
});
}
if( x.instanceID
&& x.instanceName
&& !isNaN(Number(x.count))// This is in no way a proper authentication or anything, its just to make sure everybody are registered as slaves before modifying the cluster (or not, to maintain backwards compat)
/*&& stringUtils.hashCode(slaves[x.unique].rconPassword) == x.unique*/){
if(x.instanceID
&& x.instanceName
&& !isNaN(Number(x.count))// This is in no way a proper authentication or anything, its just to make sure everybody are registered as slaves before modifying the cluster (or not, to maintain backwards compat)
/*&& stringUtils.hashCode(slaves[x.unique].rconPassword) == x.unique*/
&& x.name
&& typeof x.name == "string"){
if(config.logItemTransfers){
console.log("added: " + req.body.name + " " + req.body.count+" from "+x.instanceName+" ("+x.instanceID+")");
}
Expand Down Expand Up @@ -552,7 +555,11 @@ app.post("/api/remove", authenticate.middleware, function(req, res) {
if(slaves[object.instanceID]) object.instanceName = slaves[object.instanceID].instanceName;
let item = db.items[object.name]
// console.dir(doc);
if (!item) {
if(!item
||((
config.disableImportsOfEverythingExceptElectricity === true || config.disableImportsOfEverythingExceptElectricity === "true" )
&& object.name != "electricity")
){
if(config.logItemTransfers){
console.log('failure could not find ' + object.name);
}
Expand Down

0 comments on commit 2c6b8be

Please sign in to comment.