mirror of
https://github.com/Lawin0129/LawinServer.git
synced 2026-01-13 10:52:23 +01:00
Save fortnite settings in LocalAppData
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
Your settings for each build will be saved here.
|
|
||||||
45
index.js
45
index.js
@@ -37,6 +37,9 @@ express.use(Express.static('public'));
|
|||||||
|
|
||||||
const port = process.env.PORT || 3551;
|
const port = process.env.PORT || 3551;
|
||||||
express.listen(port, console.log("Started listening on port", port));
|
express.listen(port, console.log("Started listening on port", port));
|
||||||
|
if (!fs.existsSync(path.join(process.env.LOCALAPPDATA, "LawinServer"))) {
|
||||||
|
fs.mkdirSync(path.join(process.env.LOCALAPPDATA, "LawinServer"));
|
||||||
|
}
|
||||||
|
|
||||||
express.get("/", async (req, res) => {
|
express.get("/", async (req, res) => {
|
||||||
res.sendFile('index.html');
|
res.sendFile('index.html');
|
||||||
@@ -805,6 +808,10 @@ express.get("/fortnite/api/cloudstorage/system/:file", async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
express.get("/fortnite/api/cloudstorage/user/*/:file", async (req, res) => {
|
express.get("/fortnite/api/cloudstorage/user/*/:file", async (req, res) => {
|
||||||
|
if (!fs.existsSync(path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings"))) {
|
||||||
|
fs.mkdirSync(path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings"));
|
||||||
|
}
|
||||||
|
|
||||||
res.set("Content-Type", "application/octet-stream")
|
res.set("Content-Type", "application/octet-stream")
|
||||||
|
|
||||||
if (req.params.file.toLowerCase() != "clientsettings.sav") {
|
if (req.params.file.toLowerCase() != "clientsettings.sav") {
|
||||||
@@ -818,17 +825,23 @@ express.get("/fortnite/api/cloudstorage/user/*/:file", async (req, res) => {
|
|||||||
seasonchecker(req, seasondata);
|
seasonchecker(req, seasondata);
|
||||||
|
|
||||||
var currentBuildID = seasondata.CL;
|
var currentBuildID = seasondata.CL;
|
||||||
|
const file = path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings", `ClientSettings-${currentBuildID}.Sav`);
|
||||||
const file = path.join(__dirname, `./ClientSettings/ClientSettings-${currentBuildID}.Sav`);
|
|
||||||
|
|
||||||
if (fs.existsSync(file)) {
|
if (fs.existsSync(file)) {
|
||||||
return res.status(200).sendFile(file);
|
const ParsedFile = fs.readFileSync(file);
|
||||||
} else {
|
|
||||||
return res.status(200).end();
|
return res.status(200).send(ParsedFile).end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.status(200);
|
||||||
|
res.end();
|
||||||
})
|
})
|
||||||
|
|
||||||
express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => {
|
express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => {
|
||||||
|
if (!fs.existsSync(path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings"))) {
|
||||||
|
fs.mkdirSync(path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings"));
|
||||||
|
}
|
||||||
|
|
||||||
res.set("Content-Type", "application/json")
|
res.set("Content-Type", "application/json")
|
||||||
|
|
||||||
const seasonchecker = require("./seasonchecker.js")
|
const seasonchecker = require("./seasonchecker.js")
|
||||||
@@ -836,21 +849,20 @@ express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => {
|
|||||||
seasonchecker(req, seasondata);
|
seasonchecker(req, seasondata);
|
||||||
|
|
||||||
var currentBuildID = seasondata.CL;
|
var currentBuildID = seasondata.CL;
|
||||||
|
const file = path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings", `ClientSettings-${currentBuildID}.Sav`);
|
||||||
const file = `./ClientSettings/ClientSettings-${currentBuildID}.Sav`;
|
|
||||||
|
|
||||||
if (fs.existsSync(file)) {
|
if (fs.existsSync(file)) {
|
||||||
const utf8_file = fs.readFileSync(path.join(__dirname, file), 'utf-8');
|
const ParsedFile = fs.readFileSync(path.join(__dirname, file), 'utf-8');
|
||||||
const file_stats = fs.statSync(path.join(__dirname, file));
|
const ParsedStats = fs.statSync(path.join(__dirname, file));
|
||||||
|
|
||||||
return res.json([{
|
return res.json([{
|
||||||
"uniqueFilename": "ClientSettings.Sav",
|
"uniqueFilename": "ClientSettings.Sav",
|
||||||
"filename": "ClientSettings.Sav",
|
"filename": "ClientSettings.Sav",
|
||||||
"hash": crypto.createHash('sha1').update(utf8_file).digest('hex'),
|
"hash": crypto.createHash('sha1').update(ParsedFile).digest('hex'),
|
||||||
"hash256": crypto.createHash('sha256').update(utf8_file).digest('hex'),
|
"hash256": crypto.createHash('sha256').update(ParsedFile).digest('hex'),
|
||||||
"length": Buffer.byteLength(utf8_file),
|
"length": Buffer.byteLength(ParsedFile),
|
||||||
"contentType": "application/octet-stream",
|
"contentType": "application/octet-stream",
|
||||||
"uploaded": file_stats.mtime,
|
"uploaded": ParsedStats.mtime,
|
||||||
"storageType": "S3",
|
"storageType": "S3",
|
||||||
"storageIds": {},
|
"storageIds": {},
|
||||||
"accountId": req.params.accountId,
|
"accountId": req.params.accountId,
|
||||||
@@ -862,13 +874,18 @@ express.get("/fortnite/api/cloudstorage/user/:accountId", async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
express.put("/fortnite/api/cloudstorage/user/*/*", async (req, res) => {
|
express.put("/fortnite/api/cloudstorage/user/*/*", async (req, res) => {
|
||||||
|
if (!fs.existsSync(path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings"))) {
|
||||||
|
fs.mkdirSync(path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings"));
|
||||||
|
}
|
||||||
|
|
||||||
const seasonchecker = require("./seasonchecker.js")
|
const seasonchecker = require("./seasonchecker.js")
|
||||||
const seasondata = require("./memory.json");
|
const seasondata = require("./memory.json");
|
||||||
seasonchecker(req, seasondata);
|
seasonchecker(req, seasondata);
|
||||||
|
|
||||||
var currentBuildID = seasondata.CL;
|
var currentBuildID = seasondata.CL;
|
||||||
|
const file = path.join(process.env.LOCALAPPDATA, "LawinServer", "ClientSettings", `ClientSettings-${currentBuildID}.Sav`);
|
||||||
|
|
||||||
fs.writeFileSync(`./ClientSettings/ClientSettings-${currentBuildID}.Sav`, req.rawBody, 'latin1');
|
fs.writeFileSync(file, req.rawBody, 'latin1');
|
||||||
res.status(204).end();
|
res.status(204).end();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user