working at the moment
This commit is contained in:
parent
6eb118ca87
commit
53d150b64e
@ -139,32 +139,29 @@ async function test(userAccount, streamURLS) {
|
||||
})
|
||||
}
|
||||
|
||||
function updateAccountDNS(userAccount, streamURLS) {
|
||||
return new Promise((resolve, reject) => {
|
||||
streamURLS.forEach(async streamURL => {
|
||||
process.stdout.write('.')
|
||||
let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped)
|
||||
// console.log('tested url ' + url)
|
||||
let t = await gotRequest(url)
|
||||
let body = t.body
|
||||
if (t.statusCode == 200 && body !== "") {
|
||||
try {
|
||||
body = JSON.parse(body)
|
||||
if (body.user_info.auth) {
|
||||
var date = new Date(body.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||
// process.stdout.write('\n')
|
||||
console.log(`${userAccount.username} - ${userAccount.stream} - ${streamURL} - Expires ${date}.`)
|
||||
await updateStreamData(userAccount, streamURL, body.user_info.exp_date)
|
||||
resolve(true)
|
||||
}
|
||||
} catch (error) {
|
||||
// break
|
||||
async function updateAccountDNS(userAccount, streamURLS) {
|
||||
// return new Promise(async (resolve, reject) => {
|
||||
await Promise.all(streamURLS.map(async (streamURL) => {
|
||||
process.stdout.write('.')
|
||||
let url = await buildURL(streamURL, userAccount.username, userAccount.passwordDecryped)
|
||||
// console.log('tested url ' + url)
|
||||
let t = await gotRequest(url)
|
||||
let body = t.body
|
||||
if (t.statusCode == 200 && body !== "") {
|
||||
try {
|
||||
body = JSON.parse(body)
|
||||
if (body.user_info.auth) {
|
||||
var date = new Date(body.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||
// process.stdout.write('\n')
|
||||
console.log(`${userAccount.username} - ${userAccount.stream} - ${streamURL} - Expires ${date}.`)
|
||||
await updateStreamData(userAccount, streamURL, body.user_info.exp_date)
|
||||
resolve(true)
|
||||
}
|
||||
} else {
|
||||
// resolve(false)
|
||||
} catch (error) {
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
async function updateAccounts(userAccount, streamURLS) {
|
||||
@ -205,20 +202,22 @@ async function newUserCheck(accountData) {
|
||||
return user
|
||||
})
|
||||
|
||||
try {
|
||||
for (let i = 0; i < userAccounts.length; ++i) {
|
||||
const userAccount = userAccounts[i];
|
||||
if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) {
|
||||
setExpired(userAccount)
|
||||
} else {
|
||||
await updateAccountDNS(userAccount, streamURLS)
|
||||
}
|
||||
// try {
|
||||
for (let i = 0; i < userAccounts.length; ++i) {
|
||||
const userAccount = userAccounts[i];
|
||||
if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) {
|
||||
setExpired(userAccount)
|
||||
} else {
|
||||
await updateAccountDNS(userAccount, streamURLS)
|
||||
// console.log(a)
|
||||
}
|
||||
console.log(Date.now())
|
||||
return true
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
console.log(Date.now())
|
||||
return true
|
||||
// } catch (error) {
|
||||
// return true
|
||||
// console.error(error);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -255,7 +254,7 @@ async function newSingleCheck(accountData) {
|
||||
})
|
||||
}
|
||||
// console.log('not found')
|
||||
|
||||
|
||||
// for (let userAccount of result) {
|
||||
// if (userAccount.expiaryDate != 123 && Math.round(Date.now() / 1000) > userAccount.expiaryDate) {
|
||||
// setExpired(userAccount)
|
||||
@ -326,7 +325,7 @@ async function newSingleCheck(accountData) {
|
||||
// "username": 'Karl0ss1709',
|
||||
// "password": 'YEfbZskEH2Zu',
|
||||
// "stream": "Badger",
|
||||
// "userId": 1
|
||||
// "userId": 5
|
||||
// })
|
||||
|
||||
|
||||
|
@ -5,19 +5,21 @@ const gotRequest = async (url) => {
|
||||
let options = {
|
||||
timeout: 2000
|
||||
}
|
||||
await got(url, options)
|
||||
.then((response) => {
|
||||
returnResponse = response;
|
||||
})
|
||||
.catch((error) => {
|
||||
returnResponse = typeof error.response !== 'undefined' ? error.response : error;
|
||||
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);
|
||||
}
|
||||
});
|
||||
if (typeof returnResponse.body === 'string' && returnResponse.body.substring(0, 1) === '{') {
|
||||
returnResponse.body = JSON.parse(returnResponse.body);
|
||||
}
|
||||
});
|
||||
|
||||
return returnResponse;
|
||||
resolve(returnResponse);
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -9,6 +9,7 @@ const { newUserCheck } = require('../lib/checker')
|
||||
router.get('/', async function (req, res, next) {
|
||||
let postData = req.body
|
||||
postData.userId = getUserId(req.auth.user)
|
||||
// postData.userId = 5
|
||||
a = await newUserCheck(postData)
|
||||
if (a) {
|
||||
res.send(200)
|
||||
|
Loading…
x
Reference in New Issue
Block a user