mirror of
https://github.com/maierfelix/POGOserver.git
synced 2026-04-19 16:07:22 -05:00
Update
- Removed .save file - Moved allowed api hosts into configuration file - Determine first run by failed asset validation
This commit is contained in:
parent
6a983bc8be
commit
0eb318debc
1
.save
1
.save
|
|
@ -1 +0,0 @@
|
|||
{"isFirstRun":true,"allowedApiHosts":["localhost"],"loginDetails":{"username":"root","password":"1337"}}
|
||||
|
|
@ -13,6 +13,7 @@ export default {
|
|||
API_ENABLE: true,
|
||||
API_USERNAME: "root",
|
||||
API_PASSWORD: "",
|
||||
API_ALLOWED_HOSTS: ["localhost", "127.0.0.1"],
|
||||
|
||||
// Server settings
|
||||
MAX_CONNECTIONS: 64,
|
||||
|
|
|
|||
|
|
@ -17,15 +17,14 @@ let showHint = true;
|
|||
|
||||
export function processApiCall(req, res, route) {
|
||||
|
||||
let save = JSON.parse(fs.readFileSync(".save", "utf8"));
|
||||
let allowedHosts = save.allowedApiHosts;
|
||||
let allowedHosts = CFG.API_ALLOWED_HOSTS;
|
||||
|
||||
let hoster = url.parse(req.headers.referer).host;
|
||||
|
||||
if (!(allowedHosts.indexOf(hoster) > -1)) {
|
||||
print(`Denied API access for ${hoster}!`, 31);
|
||||
if (showHint) {
|
||||
print(`To grant ${hoster} API access, add it to the allowed hosts in .save`, 33);
|
||||
print(`To grant ${hoster} API access, add it to the allowed hosts in cfg.js`, 33);
|
||||
showHint = false;
|
||||
}
|
||||
let result = {
|
||||
|
|
|
|||
27
src/setup.js
27
src/setup.js
|
|
@ -20,20 +20,6 @@ export function setup() {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
let save = JSON.parse(fs.readFileSync(".save", "utf8"));
|
||||
|
||||
if (save.isFirstRun) {
|
||||
print("Required assets are missing! Preparing dump session..", 33);
|
||||
setTimeout(() => {
|
||||
this.onFirstRun(() => {
|
||||
save.isFirstRun = false;
|
||||
fs.writeFileSync(".save", JSON.stringify(save), "utf8");
|
||||
this.setup().then(resolve);
|
||||
});
|
||||
}, 1e3);
|
||||
return void 0;
|
||||
}
|
||||
|
||||
// make sure all assets got loaded properly
|
||||
this.validateAssets().then(() => {
|
||||
|
||||
|
|
@ -54,14 +40,25 @@ export function setup() {
|
|||
});
|
||||
|
||||
}).catch((e) => {
|
||||
//fse.removeSync(CFG.DUMP_ASSET_PATH);
|
||||
print("Error: " + e + " was not found!", 31);
|
||||
this.initDumpSession().then(resolve);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export function initDumpSession() {
|
||||
print("Required assets are missing! Preparing dump session..", 33);
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
this.onFirstRun(() => {
|
||||
this.setup().then(resolve);
|
||||
});
|
||||
}, 1e3);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure all required
|
||||
* assets got loaded properly
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user