This commit is contained in:
Karl 2021-09-24 11:34:49 +00:00
parent 334ccf268e
commit bc63d15636

View File

@ -13,6 +13,16 @@ const tor = tor_axios.torSetup({
controlPassword: process.env.TORSPWD, controlPassword: process.env.TORSPWD,
}) })
const inst = axios.create({
httpAgent: tor.httpAgent(),
httpsagent: tor.httpsAgent(),
});
let axiosOptions = {
headers: {
'User-Agent': 'IPTV Smarters Pro'
}
}
// axios.defaults.timeout = 10000; // axios.defaults.timeout = 10000;
// tor.defaults.timeout = 10000 // tor.defaults.timeout = 10000
@ -76,35 +86,26 @@ async function addNewAccount(userAccount, data, url) {
} }
async function urlChecker(userAccounts, urlList) { async function urlChecker(userAccounts, urlList) {
await tor.torNewSession(); //change tor ip // await tor.torNewSession(); //change tor ip
let ip = await tor.get('http://api.ipify.org') let ip = await inst.get('http://api.ipify.org')
console.log(ip.data); console.log(ip.data);
await Promise.all(urlList.map(async (url) => { await Promise.all(urlList.map(async (url) => {
try { try {
let response let response
url url
if (url.includes('https')) { response = await inst.get(url, axiosOptions)
try {
response = await axios.get(url)
} catch (error) {
// console.log(error)
}
} else {
response = await tor.get(url)
}
if (response.status == 200 && response.data !== "") { if (response.status == 200 && response.data !== "") {
try { try {
let data = response.data let data = response.data
if (data.user_info.auth) { if (data.user_info.auth) {
// console.log(url) console.log(url)
updateAccounts(userAccounts, data, url) updateAccounts(userAccounts, data, url)
return true return true
} }
} catch { } catch {
} }
} }
} catch (error) { } catch {
// console.log(error)
} }
})).then((values) => { })).then((values) => {
endresponse = values endresponse = values
@ -114,7 +115,8 @@ async function urlChecker(userAccounts, urlList) {
async function userCheck(accountData) { async function userCheck(accountData) {
console.log(Date.now()) let start = Date.now()
console.log(start)
streamURLS = await getStreamsNew() streamURLS = await getStreamsNew()
let userAccounts = await getUserAccountsCheck(accountData.userId) let userAccounts = await getUserAccountsCheck(accountData.userId)
@ -142,7 +144,7 @@ async function userCheck(accountData) {
return value === true; return value === true;
}).length }).length
console.log('true ' + updatedCount) console.log('true ' + updatedCount)
console.log((Date.now() - start) / 1000)
return endresponse = { return endresponse = {
"update": true, "update": true,
"count": updatedCount "count": updatedCount
@ -156,7 +158,6 @@ async function userCheck(accountData) {
async function singleAccountCheck(accountData) { async function singleAccountCheck(accountData) {
let endresponse let endresponse
console.log(Date.now())
streamURLS = await getStreamsNew() streamURLS = await getStreamsNew()
urlList = [] urlList = []
@ -167,16 +168,13 @@ async function singleAccountCheck(accountData) {
} }
urlList urlList
let ip = await inst.get('http://api.ipify.org')
console.log(ip.data);
await Promise.all(urlList.map(async (url) => { await Promise.all(urlList.map(async (url) => {
try { try {
const response = await axios.get({ response = await inst.get(url, axiosOptions)
method: 'GET',
headers: {
'User-Agent': 'GoldPlayer',
'Accept': '*/*'
},
url: url,
})
if (response.status == 200 && response.data !== "") { if (response.status == 200 && response.data !== "") {
try { try {
let data = response.data let data = response.data