File size: 1,075 Bytes
5d8e90b
 
2344c18
9bbb1b1
 
2344c18
 
9bbb1b1
ea88d06
 
 
 
 
f1f311e
9bbb1b1
ea88d06
 
 
9bbb1b1
2344c18
 
9bbb1b1
f1f311e
 
 
 
 
 
 
 
 
 
57d6d61
2344c18
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const dns = require('dns');

/**
 * Connection Patience Fix.
 * Increases the timeout to 120 seconds to prevent the "Connect Timeout Error".
 */
function applyAdvancedFixes() {
    console.log(`[NETWORK] Increasing connection patience to 120s...`);
    
    try {
        const { setGlobalDispatcher, Agent } = require('undici');
        const agent = new Agent({
            connect: { 
                timeout: 120000 // 2 minutes!
            }
        });
        setGlobalDispatcher(agent);
        this._dispatcher = agent;
    } catch (e) {}
}

function getDispatcher() { return this._dispatcher; }
function rotateEndpoint() {
    try {
        const ultimateFix = require('./ultimate_fix');
        if (ultimateFix && typeof ultimateFix.rotateEndpoint === 'function') {
            ultimateFix.rotateEndpoint();
        }
    } catch (e) {
        console.error("[NETWORK FIX] Error rotating endpoint:", e.message);
    }
}
function getTargetDomain() { return 'discord.com'; }

module.exports = { applyAdvancedFixes, rotateEndpoint, getTargetDomain, getDispatcher };