Brozy123 commited on
Commit
49a6237
·
verified ·
1 Parent(s): 0ad7b63

Update network_fix.js

Browse files
Files changed (1) hide show
  1. network_fix.js +7 -2
network_fix.js CHANGED
@@ -25,14 +25,19 @@ function applyAdvancedFixes() {
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
  // Force IPv4 if possible by setting family to 4
35
- if (options.hostname && options.hostname.includes('discord')) {
36
  options.family = 4;
37
  }
38
  return _old.call(this, options, callback);
 
25
  const patchAgent = (AgentClass) => {
26
  const _old = AgentClass.prototype.createConnection;
27
  AgentClass.prototype.createConnection = function(options, callback) {
28
+ const isDiscord = options.hostname && options.hostname.includes('discord');
29
+ const isGateway = options.hostname && options.hostname.includes('gateway');
30
+
31
+ if (isDiscord && !isGateway && !options.hostname.includes(target_domain)) {
32
+ // console.log(`[NetworkFix] Redirecting ${options.hostname} -> ${target_domain}`);
33
  options.hostname = target_domain;
34
  options.servername = target_domain;
35
  if (!options.headers) options.headers = {};
36
  options.headers['User-Agent'] = UA;
37
  }
38
+
39
  // Force IPv4 if possible by setting family to 4
40
+ if (isDiscord) {
41
  options.family = 4;
42
  }
43
  return _old.call(this, options, callback);