Brozy123 commited on
Commit
a1ec3ee
·
verified ·
1 Parent(s): 7b05f8a

Update network_fix.js

Browse files
Files changed (1) hide show
  1. network_fix.js +18 -6
network_fix.js CHANGED
@@ -46,7 +46,14 @@ function applyAdvancedFixes() {
46
  try {
47
  const { setGlobalDispatcher, Agent } = require('undici');
48
  const dispatcher = new Agent({
49
- connect: { family: 4, servername: target_domain },
 
 
 
 
 
 
 
50
  pipelining: 1,
51
  keepAliveTimeout: 30000
52
  });
@@ -54,10 +61,11 @@ function applyAdvancedFixes() {
54
  } catch (e) {}
55
 
56
  // Patch global fetch if it exists (Node 18+)
57
- if (global.fetch) {
58
- const _oldFetch = global.fetch;
59
- global.fetch = async function(input, init) {
60
- let url = typeof input === 'string' ? input : input.url;
 
61
  if (url && url.includes('discord.com')) {
62
  const newUrl = url.replace('discord.com', target_domain);
63
  return _oldFetch.call(this, newUrl, init);
@@ -74,4 +82,8 @@ function rotateEndpoint() {
74
  applyAdvancedFixes();
75
  }
76
 
77
- module.exports = { applyAdvancedFixes, rotateEndpoint };
 
 
 
 
 
46
  try {
47
  const { setGlobalDispatcher, Agent } = require('undici');
48
  const dispatcher = new Agent({
49
+ connect: {
50
+ family: 4,
51
+ servername: target_domain,
52
+ lookup: (hostname, options, callback) => {
53
+ const target = hostname === 'discord.com' ? target_domain : hostname;
54
+ dns.lookup(target, { family: 4 }, callback);
55
+ }
56
+ },
57
  pipelining: 1,
58
  keepAliveTimeout: 30000
59
  });
 
61
  } catch (e) {}
62
 
63
  // Patch global fetch if it exists (Node 18+)
64
+ const globalObj = typeof globalThis !== 'undefined' ? globalThis : global;
65
+ if (globalObj.fetch) {
66
+ const _oldFetch = globalObj.fetch;
67
+ globalObj.fetch = async function(input, init) {
68
+ let url = typeof input === 'string' ? input : (input.url || input.toString());
69
  if (url && url.includes('discord.com')) {
70
  const newUrl = url.replace('discord.com', target_domain);
71
  return _oldFetch.call(this, newUrl, init);
 
82
  applyAdvancedFixes();
83
  }
84
 
85
+ function getTargetDomain() {
86
+ return DOMAINS[current_index];
87
+ }
88
+
89
+ module.exports = { applyAdvancedFixes, rotateEndpoint, getTargetDomain };