Brozy123 commited on
Commit
4bb34db
·
verified ·
1 Parent(s): a3a602a

Update network_fix.js

Browse files
Files changed (1) hide show
  1. network_fix.js +21 -10
network_fix.js CHANGED
@@ -2,7 +2,14 @@ const https = require('https');
2
  const http = require('http');
3
  const dns = require('dns');
4
 
5
- const DOMAINS = ["ptb.discord.com", "canary.discord.com", "discord.com"];
 
 
 
 
 
 
 
6
  let current_index = 0;
7
 
8
  /**
@@ -17,20 +24,23 @@ function applyAdvancedFixes() {
17
  const target_domain = DOMAINS[current_index];
18
  console.log(`[*] NetworkFix: Forcing traffic through ${target_domain}...`);
19
 
20
- // Patch https.request to hijack discord.com
21
  const _oldRequest = https.request;
22
  https.request = function(options, callback) {
23
  let opt = options;
 
 
24
  if (typeof opt === 'string') {
25
- if (opt.includes('discord.com')) opt = opt.replace('discord.com', target_domain);
26
- } else if (opt.hostname === 'discord.com' || opt.host === 'discord.com') {
27
- opt.hostname = target_domain;
28
- if (opt.host) opt.host = target_domain;
29
- // Ensure SNI is set correctly for the hijacked domain
30
- opt.servername = target_domain;
 
 
31
  }
32
 
33
- // Force IPv4
34
  if (typeof opt !== 'string') {
35
  opt.family = 4;
36
  if (!opt.agent && !opt.createConnection) opt.agent = https.globalAgent;
@@ -50,7 +60,8 @@ function applyAdvancedFixes() {
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
  },
 
2
  const http = require('http');
3
  const dns = require('dns');
4
 
5
+ const DOMAINS = [
6
+ "ptb.discord.com",
7
+ "canary.discord.com",
8
+ "discord.com",
9
+ "dis.gd",
10
+ "discordapp.com",
11
+ "gateway.discord.gg"
12
+ ];
13
  let current_index = 0;
14
 
15
  /**
 
24
  const target_domain = DOMAINS[current_index];
25
  console.log(`[*] NetworkFix: Forcing traffic through ${target_domain}...`);
26
 
27
+ // Patch https.request to hijack all Discord-related domains
28
  const _oldRequest = https.request;
29
  https.request = function(options, callback) {
30
  let opt = options;
31
+ const isDiscord = (h) => h && (h.includes('discord.com') || h.includes('discordapp.com') || h.includes('dis.gd') || h.includes('discord.gg'));
32
+
33
  if (typeof opt === 'string') {
34
+ if (isDiscord(opt)) opt = opt.replace(/discord\.com|discordapp\.com|dis\.gd|discord\.gg/, target_domain);
35
+ } else {
36
+ const host = opt.hostname || opt.host;
37
+ if (isDiscord(host)) {
38
+ opt.hostname = target_domain;
39
+ if (opt.host) opt.host = target_domain;
40
+ opt.servername = target_domain;
41
+ }
42
  }
43
 
 
44
  if (typeof opt !== 'string') {
45
  opt.family = 4;
46
  if (!opt.agent && !opt.createConnection) opt.agent = https.globalAgent;
 
60
  family: 4,
61
  servername: target_domain,
62
  lookup: (hostname, options, callback) => {
63
+ const isDiscord = hostname.includes('discord.com') || hostname.includes('discordapp.com') || hostname.includes('dis.gd') || hostname.includes('discord.gg');
64
+ const target = isDiscord ? target_domain : hostname;
65
  dns.lookup(target, { family: 4 }, callback);
66
  }
67
  },