diff --git a/.gitignore b/.gitignore index f2d8947..52f3c7d 100644 --- a/.gitignore +++ b/.gitignore @@ -116,4 +116,7 @@ screenshots schedules.json # No docker-compose.yml -docker-compose.yml \ No newline at end of file +docker-compose.yml + +# No files +static/files/* diff --git a/src/config.example.json b/src/config.example.json index 3445070..cae50aa 100644 --- a/src/config.example.json +++ b/src/config.example.json @@ -30,5 +30,9 @@ "database": "dcm", "charset": "utf8mb4" }, + "jailbreak": { + "pogo_version": "0", + "gc_version": "0" + } "autoSyncIP": true -} \ No newline at end of file +} diff --git a/src/index.js b/src/index.js index e998caf..dd94479 100644 --- a/src/index.js +++ b/src/index.js @@ -110,6 +110,7 @@ const run = async () => { app.use(async (req, res, next) => { if (req.path === '/api/login' || req.path === '/login' || req.path === '/api/register' || req.path === '/register' || + req.path.includes('/api/download') || req.path === '/api/version.txt' || req.path === '/api/config' || req.path == '/api/log/new') { return next(); } @@ -159,4 +160,4 @@ run().then(x => { console.log('Initialized'); }).catch(err => { console.error('Error:', err); -}); \ No newline at end of file +}); diff --git a/src/routes/api.js b/src/routes/api.js index afa945e..b4d0919 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -22,23 +22,6 @@ const ScheduleManager = require('../models/schedule-manager.js'); const logger = require('../services/logger.js'); const utils = require('../services/utils.js'); -router.use(async (req, res, next) => { - if (req.path === '/api/login' || req.path === '/login' || - req.path === '/api/register' || req.path === '/register' || - req.path === '/config' || req.path === '/log/new') { - return next(); - } - if (!await Migrator.getValueForKey('SETUP')) { - res.redirect('/register'); - return; - } - if (req.session.loggedin) { - next(); - return; - } - res.redirect('/login'); -}); - router.post('/register', async (req, res) => { const isSetup = await Migrator.getValueForKey('SETUP'); if (isSetup) { @@ -145,6 +128,10 @@ router.post('/settings/change', (req, res) => { database: data.database, charset: data.charset }; + newConfig.jailbreak = { + pogo_version: data.pogo_version, + gc_version: data.gc_version + }; fs.writeFileSync(path.resolve(__dirname, '../config.json'), JSON.stringify(newConfig, null, 4)); res.redirect('/settings'); }); @@ -404,6 +391,23 @@ router.get('/configs', async (req, res) => { } }); +router.post('/download/:file', AuthTokenMiddleware, async (req, res) => { + const { uuid } = req.body; + const clientip = ((req.headers['x-forwarded-for'] || '').split(', ')[0]) || (req.connection.remoteAddress || req.connection.localAddress).match('[0-9]+.[0-9].+[0-9]+.[0-9]+$')[0]; + var filePath = 'static/files/' + req.params.file; + var fileName = req.params.file; + logger('dcm').info(`Client ${uuid} at ${clientip} is requesting ` + req.params.file); + res.download(filePath, fileName); +}); + +router.get('/version.txt', AuthTokenMiddleware, async (req, res) => { + const clientip = ((req.headers['x-forwarded-for'] || '').split(', ')[0]) || (req.connection.remoteAddress || req.connection.localAddress).match('[0-9]+.[0-9].+[0-9]+.[0-9]+$')[0]; + // TODO: Do better + res.status(200) + .attachment(`version.txt`) + .send('gc: '+ config.jailbreak.gc_version +'\npogo: ' + config.jailbreak.pogo_version) +}); + router.post('/config', AuthTokenMiddleware, async (req, res) => { const { uuid, ios_version, ipa_version, model, webserver_port } = req.body; let device = await Device.getByName(uuid); diff --git a/src/routes/ui.js b/src/routes/ui.js index 353e67a..f7389fa 100644 --- a/src/routes/ui.js +++ b/src/routes/ui.js @@ -298,6 +298,8 @@ router.get('/settings', (req, res) => { data.logging = config.logging.enabled ? 'checked' : ''; data.max_size = config.logging.max_size; data.log_format = config.logging.format || 'YYYY-MM-DD hh:mm:ss A'; + data.gc_version = config.jailbreak.gc_version; + data.pogo_version = config.jailbreak.pogo_version; res.render('settings', data); }); diff --git a/src/views/settings.mustache b/src/views/settings.mustache index a0023aa..b7f0638 100644 --- a/src/views/settings.mustache +++ b/src/views/settings.mustache @@ -19,6 +19,9 @@ +
@@ -158,6 +161,25 @@
+ +
+
+
{{Jailbreak}}
+
+
+
+ {{Pokémon GO version}} + +
+
+ {{GoCheats version}} + +
+
+
+
+
+
diff --git a/static/files/.gitkeep b/static/files/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/static/files/.gitkeep @@ -0,0 +1 @@ +