Brozy123 commited on
Commit
c658a8f
·
verified ·
1 Parent(s): 55cf5d2

Update ultimate_fix.js

Browse files
Files changed (1) hide show
  1. ultimate_fix.js +31 -15
ultimate_fix.js CHANGED
@@ -61,25 +61,41 @@ tls.DEFAULT_CIPHERS = 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_A
61
  // 4. Force a fake Browser Identity globally
62
  process.env.UNDICI_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
63
 
64
- // 5. Build and set a Global Network Agent with massive timeouts
65
  let dispatcher = null;
66
  try {
67
- const { setGlobalDispatcher, Agent } = require('undici');
68
- dispatcher = new Agent({
69
- connect: {
70
- timeout: 120000, // 2 minutes
71
- family: 4,
72
- rejectUnauthorized: false,
73
- keepAliveTimeout: 60000,
74
- },
75
- headersTimeout: 120000,
76
- bodyTimeout: 120000,
77
- pipelining: 0,
78
- maxRedirections: 5
79
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  setGlobalDispatcher(dispatcher);
81
  global.fixedDispatcher = dispatcher;
82
- console.log(">>> [ULTIMATE FIX] Global Undici Dispatcher active (v4.1).");
83
  } catch (e) {
84
  console.warn(">>> [ULTIMATE FIX] Undici setup error:", e.message);
85
  }
 
61
  // 4. Force a fake Browser Identity globally
62
  process.env.UNDICI_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';
63
 
64
+ // 5. Build and set a Global Network Agent (With Transparent Proxy Support)
65
  let dispatcher = null;
66
  try {
67
+ const { setGlobalDispatcher, Agent, ProxyAgent } = require('undici');
68
+ const proxyUrl = process.env.DISCORD_PROXY || process.env.http_proxy || process.env.https_proxy;
69
+
70
+ if (proxyUrl) {
71
+ console.log(`>>> [ULTIMATE FIX] Proxy detected! Tunneling through: ${proxyUrl}`);
72
+ dispatcher = new ProxyAgent({
73
+ uri: proxyUrl.startsWith('http') ? proxyUrl : `http://${proxyUrl}`,
74
+ token: 'Basic ' + Buffer.from('user:pass').toString('base64'), // Support auth if needed
75
+ requestTimeout: 120000,
76
+ connect: {
77
+ timeout: 120000,
78
+ rejectUnauthorized: false
79
+ }
80
+ });
81
+ } else {
82
+ dispatcher = new Agent({
83
+ connect: {
84
+ timeout: 120000,
85
+ family: 4,
86
+ rejectUnauthorized: false,
87
+ keepAliveTimeout: 60000,
88
+ },
89
+ headersTimeout: 120000,
90
+ bodyTimeout: 120000,
91
+ pipelining: 0,
92
+ maxRedirections: 5
93
+ });
94
+ }
95
+
96
  setGlobalDispatcher(dispatcher);
97
  global.fixedDispatcher = dispatcher;
98
+ console.log(`>>> [ULTIMATE FIX] Global Dispatcher active (${proxyUrl ? 'PROXY MODE' : 'ROTATION MODE'}).`);
99
  } catch (e) {
100
  console.warn(">>> [ULTIMATE FIX] Undici setup error:", e.message);
101
  }