Brozy123 commited on
Commit
590919a
·
verified ·
1 Parent(s): e1ed246

Update network_fix.js

Browse files
Files changed (1) hide show
  1. network_fix.js +29 -63
network_fix.js CHANGED
@@ -3,85 +3,42 @@ const http = require('http');
3
  const dns = require('dns');
4
 
5
  const DOMAINS = [
6
- "discordapp.com",
7
  "ptb.discord.com",
 
8
  "canary.discord.com",
9
  "discord.com"
10
  ];
11
  let current_index = 0;
 
12
 
13
  /**
14
- * Ultimate Network Fix (God-Mode).
15
- * Intercepts all low-level connections including WebSockets and Native Fetch.
16
  */
17
  function applyAdvancedFixes() {
18
  const target_domain = DOMAINS[current_index];
19
- console.log(`[*] NetworkFix: Forcing Path -> ${target_domain}`);
20
-
21
- // 1. DNS Hijacking
22
- dns.setDefaultResultOrder('ipv4first');
23
- const _oldLookup = dns.lookup;
24
- dns.lookup = function(hostname, options, callback) {
25
- let targetHost = hostname;
26
- if (hostname.includes('discord') && hostname !== target_domain) targetHost = target_domain;
27
- return _oldLookup(targetHost, options || { family: 4 }, callback);
28
- };
29
 
30
  const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36';
31
 
32
- // 2. HTTPS/HTTP Hijacking (WebSocket Handshake)
33
- const patchRequest = (mod) => {
34
- const _old = mod.request;
35
- mod.request = function(options, callback) {
36
- let opt = options;
37
- const host = typeof opt === 'string' ? opt : (opt.hostname || opt.host);
38
- if (host && host.includes('discord') && !host.includes(target_domain)) {
39
- if (typeof opt === 'string') {
40
- opt = opt.replace(/discord\.com|discordapp\.com|dis\.gd|discord\.gg/, target_domain);
41
- } else {
42
- opt.hostname = target_domain;
43
- if (opt.host) opt.host = target_domain;
44
- opt.servername = target_domain;
45
- if (!opt.headers) opt.headers = {};
46
- opt.headers['User-Agent'] = UA;
47
- }
48
  }
49
- return _old.call(mod, opt, callback);
50
  };
51
  };
52
- patchRequest(https);
53
- patchRequest(http);
54
-
55
- // 3. Undici/Fetch Hijacking
56
- try {
57
- const undici = require('undici');
58
- const connector = undici.buildConnector({ timeout: 60000 });
59
- undici.setGlobalDispatcher(new undici.Agent({
60
- connect: (opts, cb) => {
61
- let t = { ...opts };
62
- if (t.hostname.includes('discord')) { t.hostname = target_domain; t.servername = target_domain; }
63
- return connector(t, cb);
64
- },
65
- pipelining: 1
66
- }));
67
- } catch (e) {}
68
 
69
- // 4. Native WebSocket Hijacking (Node 20+)
70
  const globalObj = typeof globalThis !== 'undefined' ? globalThis : global;
71
- if (globalObj.WebSocket) {
72
- const _OldWS = globalObj.WebSocket;
73
- globalObj.WebSocket = class extends _OldWS {
74
- constructor(url, protocols) {
75
- let newUrl = url.toString();
76
- if (newUrl.includes('discord')) {
77
- newUrl = newUrl.replace(/discord\.com|discordapp\.com|dis\.gd|discord\.gg/, target_domain);
78
- }
79
- super(newUrl, protocols);
80
- }
81
- };
82
- }
83
-
84
- // 5. Native Fetch Hijacking
85
  if (globalObj.fetch) {
86
  const _oldFetch = globalObj.fetch;
87
  globalObj.fetch = async function(input, init) {
@@ -90,12 +47,21 @@ function applyAdvancedFixes() {
90
  urlStr = urlStr.replace(/discord\.com|discordapp\.com|dis\.gd|discord\.gg/, target_domain);
91
  }
92
  let newInit = { ...(init || {}) };
93
- newInit.headers = { ...(newInit.headers || {}), 'User-Agent': UA };
 
94
  return _oldFetch.call(this, urlStr, newInit);
95
  };
96
  }
97
  }
98
 
99
- function rotateEndpoint() { current_index = (current_index + 1) % DOMAINS.length; applyAdvancedFixes(); }
 
 
 
 
 
 
 
100
  function getTargetDomain() { return DOMAINS[current_index]; }
 
101
  module.exports = { applyAdvancedFixes, rotateEndpoint, getTargetDomain };
 
3
  const dns = require('dns');
4
 
5
  const DOMAINS = [
 
6
  "ptb.discord.com",
7
+ "discordapp.com",
8
  "canary.discord.com",
9
  "discord.com"
10
  ];
11
  let current_index = 0;
12
+ let last_rotate = 0;
13
 
14
  /**
15
+ * Silent Deep-Level Network Fix.
16
+ * Patches the base Agent to ensure all connections follow the stealth route.
17
  */
18
  function applyAdvancedFixes() {
19
  const target_domain = DOMAINS[current_index];
20
+ console.log(`[*] NetworkFix: Active Route -> ${target_domain}`);
 
 
 
 
 
 
 
 
 
21
 
22
  const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36';
23
 
24
+ // 1. Patch the base Agent createConnection (Universal Fix)
25
+ const patchAgent = (AgentClass) => {
26
+ const _old = AgentClass.prototype.createConnection;
27
+ AgentClass.prototype.createConnection = function(options, callback) {
28
+ if (options.hostname && options.hostname.includes('discord') && !options.hostname.includes(target_domain)) {
29
+ options.hostname = target_domain;
30
+ options.servername = target_domain;
31
+ if (!options.headers) options.headers = {};
32
+ options.headers['User-Agent'] = UA;
 
 
 
 
 
 
 
33
  }
34
+ return _old.call(this, options, callback);
35
  };
36
  };
37
+ patchAgent(https.Agent);
38
+ patchAgent(http.Agent);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ // 2. Patch global fetch
41
  const globalObj = typeof globalThis !== 'undefined' ? globalThis : global;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  if (globalObj.fetch) {
43
  const _oldFetch = globalObj.fetch;
44
  globalObj.fetch = async function(input, init) {
 
47
  urlStr = urlStr.replace(/discord\.com|discordapp\.com|dis\.gd|discord\.gg/, target_domain);
48
  }
49
  let newInit = { ...(init || {}) };
50
+ if (!newInit.headers) newInit.headers = {};
51
+ newInit.headers['User-Agent'] = UA;
52
  return _oldFetch.call(this, urlStr, newInit);
53
  };
54
  }
55
  }
56
 
57
+ function rotateEndpoint() {
58
+ const now = Date.now();
59
+ if (now - last_rotate < 10000) return; // Prevent rotation flood
60
+ last_rotate = now;
61
+ current_index = (current_index + 1) % DOMAINS.length;
62
+ applyAdvancedFixes();
63
+ }
64
+
65
  function getTargetDomain() { return DOMAINS[current_index]; }
66
+
67
  module.exports = { applyAdvancedFixes, rotateEndpoint, getTargetDomain };