Update srv.js
Browse files
srv.js
CHANGED
|
@@ -1,11 +1,31 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
const fs = require('fs');
|
| 3 |
const path = require('os');
|
|
|
|
|
|
|
|
|
|
| 4 |
const app = express();
|
| 5 |
const port = 7860;
|
| 6 |
|
| 7 |
const allowed = ['MLBB', 'BS', 'PUBG'];
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
async function fetchKey(game) {
|
| 10 |
if (!allowed.includes(game)) throw new Error('Invalid game');
|
| 11 |
|
|
@@ -16,11 +36,11 @@ async function fetchKey(game) {
|
|
| 16 |
const sessionToken = m[1];
|
| 17 |
|
| 18 |
const data = Buffer.from(`game=${game}&token=${sessionToken}`).toString('base64');
|
| 19 |
-
|
| 20 |
const genTxt = await genRes.text();
|
| 21 |
const k = genTxt.match(/id="gameKey"[^>]*>([^<]+)<\/p>/);
|
| 22 |
-
if (!k) throw new Error('key not found in response')
|
| 23 |
-
return
|
| 24 |
}
|
| 25 |
|
| 26 |
app.get('/key', async (req, res) => {
|
|
|
|
| 1 |
const express = require('express');
|
| 2 |
const fs = require('fs');
|
| 3 |
const path = require('os');
|
| 4 |
+
const axios = require('axios');
|
| 5 |
+
const https = require('https');
|
| 6 |
+
|
| 7 |
const app = express();
|
| 8 |
const port = 7860;
|
| 9 |
|
| 10 |
const allowed = ['MLBB', 'BS', 'PUBG'];
|
| 11 |
|
| 12 |
+
const fetch = (() => {
|
| 13 |
+
const agent = new https.Agent({ rejectUnauthorized: false });
|
| 14 |
+
const rand = () => Array.from({ length: 4 }, () => Math.floor(Math.random() * 256)).join('.');
|
| 15 |
+
return (url, opts = {}) =>
|
| 16 |
+
axios({
|
| 17 |
+
url,
|
| 18 |
+
httpsAgent: agent,
|
| 19 |
+
headers: {
|
| 20 |
+
'X-Forwarded-For': rand(),
|
| 21 |
+
'X-Real-IP': rand(),
|
| 22 |
+
'Via': '1.1 ' + Math.random().toString(36).slice(2)
|
| 23 |
+
},
|
| 24 |
+
...opts
|
| 25 |
+
});
|
| 26 |
+
})();
|
| 27 |
+
|
| 28 |
+
|
| 29 |
async function fetchKey(game) {
|
| 30 |
if (!allowed.includes(game)) throw new Error('Invalid game');
|
| 31 |
|
|
|
|
| 36 |
const sessionToken = m[1];
|
| 37 |
|
| 38 |
const data = Buffer.from(`game=${game}&token=${sessionToken}`).toString('base64');
|
| 39 |
+
const genRes = await fetch(`https://web.aachann.my.id/Get-key/genkey.php?data=${data}`);
|
| 40 |
const genTxt = await genRes.text();
|
| 41 |
const k = genTxt.match(/id="gameKey"[^>]*>([^<]+)<\/p>/);
|
| 42 |
+
if (!k) throw new Error('key not found in response');
|
| 43 |
+
return k[1]?.trim() || k[1] || k; //`https://web.aachann.my.id/Get-key/genkey.php?data=${data}`;
|
| 44 |
}
|
| 45 |
|
| 46 |
app.get('/key', async (req, res) => {
|