latest
This commit is contained in:
parent
51e9d71d72
commit
6e235425f9
@ -147,22 +147,16 @@ async function userCheck(accountData) {
|
|||||||
return user
|
return user
|
||||||
})
|
})
|
||||||
|
|
||||||
// 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) {
|
|
||||||
// return true
|
|
||||||
// console.error(error);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -200,8 +194,46 @@ async function singleCheck(accountData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
|
||||||
|
async function singleAccountCheck(accountData) {
|
||||||
|
streamURLS = await getStreamsNew()
|
||||||
|
accountData
|
||||||
|
urlList = []
|
||||||
|
|
||||||
|
for (let index = 0; index < streamURLS.length; index++) {
|
||||||
|
const streamURL = streamURLS[index];
|
||||||
|
urlList.push(await buildURL(streamURL, accountData.username, accountData.password))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let index = 0; index < urlList.length; index++) {
|
||||||
|
const streamURL = urlList[index];
|
||||||
|
try {
|
||||||
|
const response = await axios.get(streamURL)
|
||||||
|
if (response.status == 200 && response.data !== "") {
|
||||||
|
try {
|
||||||
|
let data = response.data
|
||||||
|
if (data.user_info.auth) {
|
||||||
|
var date = new Date(data.user_info.exp_date * 1000).toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
|
||||||
|
// process.stdout.write('\n')
|
||||||
|
console.log(`${accountData.username} - ${accountData.stream} - ${streamURL} - Expires ${date}.`)
|
||||||
|
await updateStreamData(accountData, streamURL, data.user_info.exp_date)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
newCheck,
|
newCheck,
|
||||||
singleCheck,
|
singleCheck,
|
||||||
userCheck
|
userCheck,
|
||||||
|
singleAccountCheck
|
||||||
}
|
}
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -175,6 +175,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz",
|
||||||
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
|
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA=="
|
||||||
},
|
},
|
||||||
|
"axios": {
|
||||||
|
"version": "0.21.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
|
||||||
|
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
|
||||||
|
"requires": {
|
||||||
|
"follow-redirects": "^1.14.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"babel-runtime": {
|
"babel-runtime": {
|
||||||
"version": "6.26.0",
|
"version": "6.26.0",
|
||||||
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
|
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
|
||||||
@ -572,6 +580,11 @@
|
|||||||
"unpipe": "~1.0.0"
|
"unpipe": "~1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"follow-redirects": {
|
||||||
|
"version": "1.14.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz",
|
||||||
|
"integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g=="
|
||||||
|
},
|
||||||
"forever-agent": {
|
"forever-agent": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"start": "node ./bin/www"
|
"start": "node ./bin/www"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.21.4",
|
||||||
"bcrypt": "^5.0.0",
|
"bcrypt": "^5.0.0",
|
||||||
"cryptr": "^6.0.2",
|
"cryptr": "^6.0.2",
|
||||||
"express": "~4.16.1",
|
"express": "~4.16.1",
|
||||||
|
@ -3,7 +3,7 @@ var router = express.Router();
|
|||||||
|
|
||||||
const { storeAccountToDB } = require('../lib/Accounts')
|
const { storeAccountToDB } = require('../lib/Accounts')
|
||||||
const { getUserId } = require('../lib/getUser')
|
const { getUserId } = require('../lib/getUser')
|
||||||
const { singleCheck } = require('../lib/checker')
|
const { singleAccountCheck } = require('../lib/checker')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -17,19 +17,18 @@ router.post('/', async function (req, res, next) {
|
|||||||
postData.username = postData.username.replace("O", "0")
|
postData.username = postData.username.replace("O", "0")
|
||||||
}
|
}
|
||||||
postData.userId = getUserId(req.auth.user)
|
postData.userId = getUserId(req.auth.user)
|
||||||
let userName = req.auth.user
|
// let result = await storeAccountToDB(postData)
|
||||||
let result = await storeAccountToDB(postData)
|
// console.log(result)
|
||||||
console.log(result)
|
// if (result.affectedRows < 1) {
|
||||||
if (result.affectedRows < 1) {
|
// res.send('Adding account failed')
|
||||||
res.send('Adding account failed')
|
// } else {
|
||||||
} else {
|
a = await singleAccountCheck(postData)
|
||||||
a = await singleCheck(postData)
|
|
||||||
if (a) {
|
if (a) {
|
||||||
res.send('Account ' + postData.username + ' Added successfully to ' + userName)
|
res.send('Account ' + postData.username + ' Added successfully to ' + req.auth.user)
|
||||||
} else {
|
} else {
|
||||||
res.send(500);
|
res.send(500);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user