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