This commit is contained in:
Elysia
2024-02-14 08:14:01 +07:00
parent 077f087ca0
commit 08f822e48a
3 changed files with 25 additions and 9 deletions

View File

@@ -1,7 +1,6 @@
'use strict';
const Buffer = require('node:buffer').Buffer;
const http = require('node:http');
const https = require('node:https');
const { setTimeout } = require('node:timers');
const makeFetchCookie = require('fetch-cookie');
@@ -9,6 +8,7 @@ const FormData = require('form-data');
const fetchOriginal = require('node-fetch');
const { CookieJar } = require('tough-cookie');
const { ciphers } = require('../util/Constants');
const Util = require('../util/Util');
const cookieJar = new CookieJar();
const fetch = makeFetchCookie(fetchOriginal, cookieJar);
@@ -40,11 +40,17 @@ class APIRequest {
make(captchaKey, captchaRqToken) {
if (!agent) {
if (this.client.options.http.agent instanceof http.Agent) {
this.client.options.http.agent.options.keepAlive = true;
this.client.options.http.agent.options.honorCipherOrder = true;
this.client.options.http.agent.options.minVersion = 'TLSv1.2';
this.client.options.http.agent.options.ciphers = ciphers.join(':');
if (Util.verifyProxyAgent(this.client.options.http.agent)) {
// Bad code
for (const [k, v] of Object.entries({
keepAlive: true,
honorCipherOrder: true,
minVersion: 'TLSv1.2',
ciphers: ciphers.join(':'),
})) {
this.client.options.http.agent.options[k] = v;
this.client.options.http.agent.httpsAgent.options.options[k] = v;
}
agent = this.client.options.http.agent;
} else {
agent = new https.Agent({