[addon] updates to use https proxy agent

This commit is contained in:
TheBeastLT
2020-09-09 20:36:18 +02:00
parent 7ff2a3e208
commit 1b7dda53d5
6 changed files with 65 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ const PremiumizeClient = require('premiumize-api');
const { encode } = require('magnet-uri');
const { isVideo } = require('../lib/extension');
const StaticResponse = require('./static');
const { getRandomProxy, getRandomUserAgent } = require('../lib/request_helper');
const { getRandomProxy, getProxyAgent, getRandomUserAgent } = require('../lib/requestHelper');
const { cacheWrapProxy, cacheUserAgent } = require('../lib/cache');
async function getCachedStreams(streams, apiKey) {
@@ -107,8 +107,9 @@ function statusReady(status) {
async function getDefaultOptions(id, ip) {
const userAgent = await cacheUserAgent(id, () => getRandomUserAgent()).catch(() => getRandomUserAgent());
const proxy = await cacheWrapProxy('moch', () => getRandomProxy()).catch(() => getRandomProxy());
const agent = getProxyAgent(proxy);
return { proxy: proxy, headers: { 'User-Agent': userAgent } };
return { timeout: 30000, agent: agent, headers: { 'User-Agent': userAgent } };
}
module.exports = { getCachedStreams, resolve };