[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

@@ -1,7 +1,7 @@
const AllDebridClient = require('all-debrid-api');
const { isVideo, isArchive } = 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) {
@@ -101,8 +101,9 @@ async function _unrestrictLink(AD, torrent, encodedFileName, fileIndex) {
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 } };
}
function statusError(statusCode) {

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 };

View File

@@ -3,7 +3,7 @@ const { encode } = require('magnet-uri');
const { isVideo, isArchive } = require('../lib/extension');
const delay = require('./delay');
const StaticResponse = require('./static');
const { getRandomProxy, getRandomUserAgent, blacklistProxy } = require('../lib/request_helper');
const { getRandomProxy, getProxyAgent, getRandomUserAgent, blacklistProxy } = require('../lib/requestHelper');
const { cacheWrapProxy, cacheUserAgent, uncacheProxy } = require('../lib/cache');
const MIN_SIZE = 15728640; // 15 MB
@@ -204,8 +204,9 @@ function statusReady(status) {
async function getDefaultOptions(id) {
const userAgent = await cacheUserAgent(id, () => getRandomUserAgent()).catch(() => getRandomUserAgent());
const proxy = await cacheWrapProxy('moch', () => getRandomProxy()).catch(() => getRandomProxy());
const agent = getProxyAgent(proxy);
return { timeout: 30000, proxy: proxy, headers: { 'User-Agent': userAgent } };
return { timeout: 30000, agent: agent, headers: { 'User-Agent': userAgent } };
}
module.exports = { getCachedStreams, resolve };