Spaces:
Runtime error
Runtime error
Update ultimate_fix.js
Browse files- ultimate_fix.js +15 -8
ultimate_fix.js
CHANGED
|
@@ -10,10 +10,14 @@ const https = require('https');
|
|
| 10 |
|
| 11 |
console.log(">>> [ULTIMATE FIX] Booting high-performance network bypass logic...");
|
| 12 |
|
| 13 |
-
// 1. Force the system to use IPv4 only everywhere
|
| 14 |
if (dns.setDefaultResultOrder) {
|
| 15 |
dns.setDefaultResultOrder('ipv4first');
|
| 16 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
// 2. Monkey-patch the global DNS system (Failsafe)
|
| 19 |
const originalLookup = dns.lookup;
|
|
@@ -27,18 +31,20 @@ dns.lookup = function(hostname, options, callback) {
|
|
| 27 |
options = { family: 4 };
|
| 28 |
} else {
|
| 29 |
options.family = 4;
|
|
|
|
| 30 |
}
|
| 31 |
return originalLookup(hostname, options, callback);
|
| 32 |
};
|
| 33 |
|
| 34 |
-
// 3. Disable all SSL/TLS verification
|
| 35 |
-
// We do this inside the agents now to avoid the global console warning.
|
| 36 |
tls.DEFAULT_MIN_VERSION = 'TLSv1.2';
|
| 37 |
tls.DEFAULT_MAX_VERSION = 'TLSv1.3';
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
// 4. Force a fake Browser Identity globally
|
| 41 |
-
process.env.UNDICI_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
| 42 |
|
| 43 |
// 5. Build and set a Global Network Agent with massive timeouts
|
| 44 |
let dispatcher = null;
|
|
@@ -53,20 +59,21 @@ try {
|
|
| 53 |
},
|
| 54 |
headersTimeout: 120000,
|
| 55 |
bodyTimeout: 120000,
|
| 56 |
-
pipelining: 0
|
|
|
|
| 57 |
});
|
| 58 |
setGlobalDispatcher(dispatcher);
|
| 59 |
global.fixedDispatcher = dispatcher;
|
| 60 |
-
console.log(">>> [ULTIMATE FIX] Global Undici Dispatcher active.");
|
| 61 |
} catch (e) {
|
| 62 |
console.warn(">>> [ULTIMATE FIX] Undici setup error:", e.message);
|
| 63 |
}
|
| 64 |
|
| 65 |
// 6. Fix legacy http/https modules too
|
| 66 |
http.globalAgent = new http.Agent({ family: 4, keepAlive: true });
|
| 67 |
-
https.globalAgent = new https.Agent({ family: 4, keepAlive: true, rejectUnauthorized: false });
|
| 68 |
|
| 69 |
-
console.log(">>> [ULTIMATE FIX] Network system hardened.
|
| 70 |
|
| 71 |
module.exports = {
|
| 72 |
dispatcher: dispatcher || global.fixedDispatcher || null
|
|
|
|
| 10 |
|
| 11 |
console.log(">>> [ULTIMATE FIX] Booting high-performance network bypass logic...");
|
| 12 |
|
| 13 |
+
// 1. Force the system to use IPv4 only everywhere and set custom DNS
|
| 14 |
if (dns.setDefaultResultOrder) {
|
| 15 |
dns.setDefaultResultOrder('ipv4first');
|
| 16 |
}
|
| 17 |
+
try {
|
| 18 |
+
// Use Cloudflare and Google as fallbacks
|
| 19 |
+
dns.setServers(['1.1.1.1', '8.8.8.8', '1.0.0.1']);
|
| 20 |
+
} catch(e) {}
|
| 21 |
|
| 22 |
// 2. Monkey-patch the global DNS system (Failsafe)
|
| 23 |
const originalLookup = dns.lookup;
|
|
|
|
| 31 |
options = { family: 4 };
|
| 32 |
} else {
|
| 33 |
options.family = 4;
|
| 34 |
+
options.hints = (options.hints || 0) | dns.ADDRCONFIG;
|
| 35 |
}
|
| 36 |
return originalLookup(hostname, options, callback);
|
| 37 |
};
|
| 38 |
|
| 39 |
+
// 3. Disable all SSL/TLS verification and set modern cipher suite
|
|
|
|
| 40 |
tls.DEFAULT_MIN_VERSION = 'TLSv1.2';
|
| 41 |
tls.DEFAULT_MAX_VERSION = 'TLSv1.3';
|
| 42 |
+
// Force modern ciphers to avoid handshake failures
|
| 43 |
+
tls.DEFAULT_CIPHERS = 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';
|
| 44 |
|
| 45 |
|
| 46 |
// 4. Force a fake Browser Identity globally
|
| 47 |
+
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';
|
| 48 |
|
| 49 |
// 5. Build and set a Global Network Agent with massive timeouts
|
| 50 |
let dispatcher = null;
|
|
|
|
| 59 |
},
|
| 60 |
headersTimeout: 120000,
|
| 61 |
bodyTimeout: 120000,
|
| 62 |
+
pipelining: 0,
|
| 63 |
+
maxRedirections: 5
|
| 64 |
});
|
| 65 |
setGlobalDispatcher(dispatcher);
|
| 66 |
global.fixedDispatcher = dispatcher;
|
| 67 |
+
console.log(">>> [ULTIMATE FIX] Global Undici Dispatcher active (v4.1).");
|
| 68 |
} catch (e) {
|
| 69 |
console.warn(">>> [ULTIMATE FIX] Undici setup error:", e.message);
|
| 70 |
}
|
| 71 |
|
| 72 |
// 6. Fix legacy http/https modules too
|
| 73 |
http.globalAgent = new http.Agent({ family: 4, keepAlive: true });
|
| 74 |
+
https.globalAgent = new https.Agent({ family: 4, keepAlive: true, rejectUnauthorized: false, timeout: 60000 });
|
| 75 |
|
| 76 |
+
console.log(">>> [ULTIMATE FIX] Network system hardened. Connection resilience increased.");
|
| 77 |
|
| 78 |
module.exports = {
|
| 79 |
dispatcher: dispatcher || global.fixedDispatcher || null
|