fix account add logic
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 55s

This commit is contained in:
Karl 2025-07-05 10:36:14 +01:00
parent d9439d8aae
commit 605541d2d0
7 changed files with 73 additions and 35 deletions

View File

@ -1,5 +1,4 @@
[
"http://apppanel.co.uk/panel/capo/smarters/api//home.php?action=dns",
"http://panelhost.xyz/cli3nts/Funky/Smarters/api/home.php?action=dns",
"https://shadowappz.win/1/kuga/smarters405/api/dns.php"
]

View File

@ -1,5 +1,9 @@
[
"http://webservgroup.xyz/smarters4567891/api/home.php?action=dns",
"http://panelhost.xyz/cli3nts/Funky/Smarters/api/home.php?action=dns",
"http://panelhost.xyz/cli3nts/smartersv3/funky/api/home.php?action=dns"
"http://panelhost.xyz/cli3nts/smartersv3/funky/api/home.php?action=dns",
"http://panelhost.xyz/cli3nts/Funky/Smarters/api/home.php?action=dns",
"http://apppanel.co.uk/panel/capo/smarters/api//home.php?action=dns"
]

View File

@ -183,7 +183,7 @@ async function accountChecker(accountData, urlList) {
try {
let response = await inst.get(url, axiosOptions)
if (response.data.user_info.auth) {
addNewAccount(accountData, data, url)
addNewAccount(accountData, response.data, url)
console.log('New Account Added')
syncApache()
return true
@ -233,4 +233,5 @@ module.exports = {
singleAccountCheck,
}
// singleAccountCheck({ "username": "Karl0ss01", "password": "YqQjYH9Nzw", "userId": 1, "stream": "Badger" })
// singleAccountCheck({ "username": "Karl0ss01", "password": "YqQjYH9Nzw", "userId": 1, "stream": "Badger" })
// singleAccountCheck({ "username": "Chris0207B", "password": "nfAf53tR4w", "userId": 1, "stream": "Bonsai" })

View File

@ -1,27 +0,0 @@
const got = require('got')
const gotRequest = async (url) => {
let returnResponse = {};
let options = {
timeout: 2000
}
return new Promise(async (resolve, reject) => {
await got(url, options)
.then((response) => {
returnResponse = response;
})
.catch((error) => {
returnResponse = typeof error.response !== 'undefined' ? error.response : error;
if (typeof returnResponse.body === 'string' && returnResponse.body.substring(0, 1) === '{') {
returnResponse.body = JSON.parse(returnResponse.body);
}
});
resolve(returnResponse);
})
};
module.exports = {
gotRequest
}

56
lib/makeRequest.js Normal file
View File

@ -0,0 +1,56 @@
const http = require('http');
const https = require('https');
const makeRequest = async (url) => {
return new Promise((resolve) => {
const client = url.startsWith('https://') ? https : http;
const req = client.get(url, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
let parsed = data;
try {
if (typeof data === 'string' && data.trim().startsWith('{')) {
parsed = JSON.parse(data);
}
} catch (e) {
console.warn('Warning: JSON parse failed');
}
resolve({
statusCode: res.statusCode,
headers: res.headers,
body: parsed
});
});
});
req.on('error', (err) => {
console.error('Request failed:', err.message);
resolve({
statusCode: 500,
body: null,
error: err.message
});
});
req.setTimeout(2000, () => {
req.abort();
resolve({
statusCode: 408,
body: null,
error: 'Request timeout'
});
});
});
};
module.exports = {
makeRequest
};

View File

@ -1,6 +1,6 @@
{
"name": "react-backend",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"

View File

@ -5,7 +5,7 @@ const fs = require('fs');
let DNSArray = require('../DNSArray.json')
const otherURLs = require('../otherURLs.json')
const { gotRequest } = require('../lib/gotRequest')
const { makeRequest } = require('../lib/makeRequest')
function splitToArray(DNS) {
@ -18,7 +18,7 @@ async function getStreamsNew() {
let jointArray = []
for (let index = 0; index < DNSArray.length; index++) {
const url = DNSArray[index];
requestData = await gotRequest(url)
requestData = await makeRequest(url)
let DNSList = requestData.body
if (typeof DNSList === 'string' || DNSList instanceof String) {
try {
@ -29,7 +29,12 @@ async function getStreamsNew() {
return jointArray
}
}
DNSList = splitToArray(DNSList.su)
try {
DNSList = splitToArray(DNSList.su)
} catch (error) {
DNSList = splitToArray(DNSList.fu)
}
DNSList.forEach(url => {
jointArray.push(url)
});