mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
Remove support for uploading mods to master
Remove the uploadMod and checkMod APIs as these have become more or less obsolete after Factorio implementd syncing mods to the server in game.
This commit is contained in:
1 parent
1d26212e1d
commit
f3171c2feb
4 files changed
+2
-97
No files matched your search
@@ -64,6 +64,8 @@ Version 2.0.0
|
||||
- Removed getLua and getCommand from lib/clusterTools. If you need to run
|
||||
more than the most trivial of code in commands use the save patcher and
|
||||
add in a remote interface.
|
||||
- Removed mod uploading and distributing from the HTTP interface. Breaks
|
||||
the old unmaintained and no longer needed factorioClusterioClient.
|
||||
|
||||
|
||||
Version 1.2.3
|
||||
|
||||
@@ -704,48 +704,6 @@ async function instanceManagement(config, instance, instanceconfig, server) {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Mod uploading and management -----------------------------------------------
|
||||
// get mod names and hashes
|
||||
// string: instance, function: callback
|
||||
|
||||
setTimeout(function(){hashMods(instance, uploadMods)}, 5000);
|
||||
function uploadMods(modHashes) {
|
||||
// [{modName:string,hash:string}, ... ]
|
||||
for(let i=0;i<modHashes.length;i++){
|
||||
let payload = {
|
||||
modName: modHashes[i].modName,
|
||||
hash: modHashes[i].hash,
|
||||
};
|
||||
needle.post(config.masterURL + '/api/checkMod', payload, needleOptionsWithTokenAuthHeader(config), function (err, response, body) {
|
||||
if(err) console.error("Unable to contact master server /api/checkMod! Please check your config.json.");
|
||||
if(response && body && body == "found") {
|
||||
console.log("master has mod "+modHashes[i].modName);
|
||||
} else if (response && body && typeof body == "string") {
|
||||
let mod = response.body;
|
||||
if(config.uploadModsToMaster){
|
||||
console.log("Sending mod: " + mod);
|
||||
// Send mods master says it wants
|
||||
// response.body is a string which is a modName.zip
|
||||
var req = request.post({url: config.masterURL + '/api/uploadMod',
|
||||
headers: {
|
||||
"x-access-token": config.masterAuthToken,
|
||||
},
|
||||
}, function (err, resp, body) {
|
||||
if (err) {
|
||||
console.error(new Error("Unable to contact master server /api/uploadMod! Please check your config.json."));
|
||||
} else {
|
||||
console.log('URL: ' + body);
|
||||
}
|
||||
});
|
||||
var form = req.form();
|
||||
form.append('file', fs.createReadStream(instance.path("mods", mod)));
|
||||
} else {
|
||||
console.log("Not sending mod: " + mod + " to master because config.uploadModsToMaster is not enabled")
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} // END OF INSTANCE START ---------------------------------------------------------------------
|
||||
|
||||
// string, function
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
"__comment6.5": "When the master is undersupplied, we have 3 different modes to 'fairly' distribute items. First to ask gets all, dole division using weird formula or experimental neural net tries to make stuff as fair as possible. Feel free to play around.",
|
||||
"disableFairItemDistribution": false,
|
||||
"useNeuralNetDoleDivider": true,
|
||||
"uploadModsToMaster": false,
|
||||
"msBetweenCommands": 10,
|
||||
"allowRemoteCommandExecution": true,
|
||||
"enableCrossServerShout": true,
|
||||
|
||||
@@ -275,54 +275,6 @@ app.post("/api/getSlaveMeta", function (req, res) {
|
||||
res.send('{"INVALID_REQUEST":1}');
|
||||
}
|
||||
});
|
||||
// mod management
|
||||
// should handle uploading and checking if mods are uploaded
|
||||
/**
|
||||
POST Check if a mod has been uploaded to the master before. Only checks against filename, not hash.
|
||||
@memberof clusterioMaster
|
||||
@instance
|
||||
@alias /api/checkMod
|
||||
*/
|
||||
app.post("/api/checkMod", authenticate.middleware, function(req,res) {
|
||||
endpointHitCounter.labels(req.route.path).inc();
|
||||
let files = fs.readdirSync(path.join(config.databaseDirectory, "masterMods"));
|
||||
let found = false;
|
||||
files.forEach(file => {
|
||||
if(file == req.body.modName) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
if(!found) {
|
||||
// we don't have mod, plz send
|
||||
res.send(req.body.modName);
|
||||
} else {
|
||||
res.send("found");
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
/**
|
||||
POST endpoint for uploading mods to the master server. Required for automatic mod downloads with factorioClusterioClient (electron app, see seperate repo)
|
||||
@memberof clusterioMaster
|
||||
@instance
|
||||
@alias /api/uploadMod
|
||||
*/
|
||||
app.post("/api/uploadMod", authenticate.middleware, function(req,res) {
|
||||
endpointHitCounter.labels(req.route.path).inc();
|
||||
if (req.files && req.files.file) {
|
||||
// console.log(req.files.file);
|
||||
req.files.file.mv(path.resolve(config.databaseDirectory, "masterMods", req.files.file.name), function(err) {
|
||||
if (err) {
|
||||
res.status(500).send(err);
|
||||
} else {
|
||||
res.send('File uploaded!');
|
||||
console.log("Uploaded mod: " + req.files.file.name);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
res.send('No files were uploaded.');
|
||||
|
||||
}
|
||||
});
|
||||
/**
|
||||
Prepare the slaveCache for both /api/slaves calls
|
||||
*/
|
||||
@@ -671,12 +623,6 @@ async function startServer() {
|
||||
config.databaseDirectory = args.databaseDirectory || config.databaseDirectory || "./database";
|
||||
await fs.ensureDir(config.databaseDirectory);
|
||||
|
||||
const masterModFolder = path.join(config.databaseDirectory, "masterMods");
|
||||
await fs.ensureDir(masterModFolder);
|
||||
|
||||
// mod downloads
|
||||
app.use(express.static(masterModFolder));
|
||||
|
||||
await loadDatabase(config.databaseDirectory);
|
||||
authenticate.setAuthSecret(config.masterAuthSecret);
|
||||
|
||||
|
||||
Reference in new issue
Block a user