From 86c08d31c9037422610708ef402ad504183dfdf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=AASherif=20Hamdy=E2=80=AC=E2=80=8F?= <36704690+Sherif-7amdy@users.noreply.github.com> Date: Wed, 31 May 2023 06:07:41 +0300 Subject: [PATCH] Update index.js --- index.js | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index afc6a8bd6c..d84d2eb016 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,41 @@ -const express = require('express') -const app = express() -app.all('/', (req, res) => { - console.log("Just got a request!") - res.send('Yo!') -}) -app.listen(process.env.PORT || 3000) \ No newline at end of file +const express = require('express'); +const https = require('https'); + +const app = express(); + +const options = { + headers: { + 'user-agent': 'Android Vinebre Software' + }, + rejectUnauthorized: false +}; + +app.get('/akotvapp', (req, res) => { + const s = req.query.s || 'default value'; + https.get('https://config.e-droid.net/srv/config.php?v=142&vname=2.0&idapp=2174667&idusu=0&cod_g=&gp=0&am=0&idl=en&pa_env=1&pa=US&pn=com.chacha2022&fus=010100000000&aid=a5417094071fea1a', options, (response) => { + let data = ''; + response.on('data', (chunk) => { + data += chunk; + }); + + response.on('end', () => { + const delimiter = '[s21700473_url='; + const first_step = data.includes(delimiter) ? data.split(delimiter) : []; + const second_step = first_step.length > 1 ? first_step[1].split('][') : []; + const user = second_step.length > 0 ? second_step[0] : ''; + const a = user.replace('/611', s); + + // Set the response header to the URL + res.location(a); + res.sendStatus(302); // Send redirect response + }); + }).on('error', (error) => { + console.error(error); + res.status(500).json({ error: 'Something went wrong' }); // Send error response + }); +}); + +const port = process.env.PORT || 3000; +app.listen(port, () => { + console.log(`Server started on port ${port}`); +});