mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Gather more information about who adds stuff to the cluster
This commit is contained in:
1 parent
339f38c1b0
commit
c7744b5189
2 files changed
+22
-10
No files matched your search
@@ -544,9 +544,11 @@ function instanceManagement() {
|
|||||||
// 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(config.masterIP + ":" + config.masterPort + '/api/place', {
|
needle.post(config.masterIP + ":" + config.masterPort + '/api/place', {
|
||||||
name: g[0],
|
name: g[0],
|
||||||
count: g[1]
|
count: g[1],
|
||||||
|
instanceName: instance, // name of instance
|
||||||
|
unique: instanceconfig.unique, // a hash computed from the randomly generated rcon password
|
||||||
}, function (err, resp, body) {
|
}, function (err, resp, body) {
|
||||||
// console.log(body);
|
if(body == "failure") console.error("#### Export failed! Lost: "+g[1]+" "+g[0]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ var config = require('./config');
|
|||||||
|
|
||||||
// homebrew modules
|
// homebrew modules
|
||||||
const getFactorioLocale = require("./lib/getFactorioLocale");
|
const getFactorioLocale = require("./lib/getFactorioLocale");
|
||||||
|
const stringUtils = require("./lib/stringUtils");
|
||||||
|
|
||||||
// Library for create folder recursively if it does not exist
|
// Library for create folder recursively if it does not exist
|
||||||
const mkdirp = require("mkdirp");
|
const mkdirp = require("mkdirp");
|
||||||
@@ -55,10 +56,8 @@ db.signals = new Datastore({ filename: 'database/signals.db', autoload: true, in
|
|||||||
db.signals.ensureIndex({ fieldName: 'time', expireAfterSeconds: 3600 }, function (err) {});
|
db.signals.ensureIndex({ fieldName: 'time', expireAfterSeconds: 3600 }, function (err) {});
|
||||||
|
|
||||||
// production chart database
|
// production chart database
|
||||||
// db.flows = new Datastore({ filename: "database/flows.db", autoload: true});
|
|
||||||
db.flows = new LinvoDB("flows", {}, {});
|
db.flows = new LinvoDB("flows", {}, {});
|
||||||
// db.flows.ensureIndex({ fieldName: "slaveID", expireAfterSeconds: 2592000}); // expire after 30 days
|
|
||||||
// db.slaves = new Datastore({ filename: 'database/slaves.db', autoload: true, inMemoryOnly: false});
|
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
try{
|
try{
|
||||||
@@ -207,11 +206,22 @@ app.get("/api/slaves", function(req, res) {
|
|||||||
app.post("/api/place", function(req, res) {
|
app.post("/api/place", function(req, res) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
||||||
console.log("added: " + req.body.name + " " + req.body.count);
|
let x = req.body;
|
||||||
// save items we get
|
if( x.unique
|
||||||
db.items.addItem(req.body);
|
&& x.instanceName // This is in no way a proper authentication or anything, its just to make sure everybody are registered as slaves before modifying the cluster
|
||||||
// Attempt confirming
|
&& stringUtils.hashCode(slaves[x.unique].rconPassword) == x.unique){
|
||||||
res.end("success");
|
|
||||||
|
console.log("added: " + req.body.name + " " + req.body.count+" from "+x.instanceName+" ("+x.unique+")");
|
||||||
|
// save items we get
|
||||||
|
db.items.addItem({
|
||||||
|
name:req.body.name,
|
||||||
|
count:req.body.count
|
||||||
|
});
|
||||||
|
// Attempt confirming
|
||||||
|
res.send("success");
|
||||||
|
} else {
|
||||||
|
res.send("failure");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// endpoint to remove items from DB when client orders items
|
// endpoint to remove items from DB when client orders items
|
||||||
|
|||||||
Reference in new issue
Block a user