working at the moment

This commit is contained in:
Karl 2021-09-20 16:03:43 +00:00
parent 6eb118ca87
commit 53d150b64e
3 changed files with 51 additions and 49 deletions

View File

@ -139,9 +139,9 @@ async function test(userAccount, streamURLS) {
}) })
} }
function updateAccountDNS(userAccount, streamURLS) { async function updateAccountDNS(userAccount, streamURLS) {
return new Promise((resolve, reject) => { // return new Promise(async (resolve, reject) => {
streamURLS.forEach(async streamURL => { await Promise.all(streamURLS.map(async (streamURL) => {
process.stdout.write('.') process.stdout.write('.')
let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped) let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped)
// console.log('tested url ' + url) // console.log('tested url ' + url)
@ -158,13 +158,10 @@ function updateAccountDNS(userAccount, streamURLS) {
resolve(true) resolve(true)
} }
} catch (error) { } catch (error) {
// break
} }
} else { } else {
// resolve(false)
} }
}) }));
})
} }
async function updateAccounts(userAccount, streamURLS) { async function updateAccounts(userAccount, streamURLS) {
@ -205,20 +202,22 @@ async function newUserCheck(accountData) {
return user return user
}) })
try { // try {
for (let i = 0; i < userAccounts.length; ++i) { for (let i = 0; i < userAccounts.length; ++i) {
const userAccount = userAccounts[i]; const userAccount = userAccounts[i];
if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) { if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) {
setExpired(userAccount) setExpired(userAccount)
} else { } else {
await updateAccountDNS(userAccount, streamURLS) await updateAccountDNS(userAccount, streamURLS)
// console.log(a)
} }
} }
console.log(Date.now()) console.log(Date.now())
return true return true
} catch (error) { // } catch (error) {
console.error(error); // return true
} // console.error(error);
// }
} }
@ -326,7 +325,7 @@ async function newSingleCheck(accountData) {
// "username": 'Karl0ss1709', // "username": 'Karl0ss1709',
// "password": 'YEfbZskEH2Zu', // "password": 'YEfbZskEH2Zu',
// "stream": "Badger", // "stream": "Badger",
// "userId": 1 // "userId": 5
// }) // })

View File

@ -5,6 +5,7 @@ const gotRequest = async (url) => {
let options = { let options = {
timeout: 2000 timeout: 2000
} }
return new Promise(async (resolve, reject) => {
await got(url, options) await got(url, options)
.then((response) => { .then((response) => {
returnResponse = response; returnResponse = response;
@ -17,7 +18,8 @@ const gotRequest = async (url) => {
} }
}); });
return returnResponse; resolve(returnResponse);
})
}; };
module.exports = { module.exports = {

View File

@ -9,6 +9,7 @@ const { newUserCheck } = require('../lib/checker')
router.get('/', async function (req, res, next) { router.get('/', async function (req, res, next) {
let postData = req.body let postData = req.body
postData.userId = getUserId(req.auth.user) postData.userId = getUserId(req.auth.user)
// postData.userId = 5
a = await newUserCheck(postData) a = await newUserCheck(postData)
if (a) { if (a) {
res.send(200) res.send(200)