Advertisement
Suadlove4

Resdri8564

Apr 13th, 2023
1,894
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
FreeSWITCH 2.81 KB | Cryptocurrency | 0 0
  1. const subLink = 'https://raw.githubusercontent.com/mahdibland/ShadowsocksAggregator/master/sub/splitted/vmess.txt';
  2.  
  3.  
  4.  
  5. export default {
  6.  
  7. async fetch(request) {
  8.  
  9. let url = new URL(request.url);
  10.  
  11. let realhostname = url.pathname.split('/')[1];
  12.  
  13. let realpathname = url.pathname.split('/')[2];
  14.  
  15. if (url.pathname.startsWith('/sub')) {
  16.  
  17. let newConfigs = '';
  18.  
  19. let resp = await fetch(subLink);
  20.  
  21. let subConfigs = await resp.text();
  22.  
  23. subConfigs = subConfigs.split('\n');
  24.  
  25. for (let subConfig of subConfigs) {
  26.  
  27. if (subConfig.search('vmess') != -1) {
  28.  
  29. subConfig = subConfig.replace('vmess://', '');
  30.  
  31. subConfig = atob(subConfig);
  32.  
  33. subConfig = JSON.parse(subConfig);
  34.  
  35. if (subConfig.port == 443) {
  36.  
  37. var configNew = new Object();
  38.  
  39. configNew.v = '2';
  40.  
  41.  
  42.  
  43. //شرط جدید برای اسم کانفیگ
  44.  
  45. if (subConfig.sni !== '') {
  46.  
  47. configNew.ps = subConfig.sni;
  48.  
  49. } else if (subConfig.host !== '') {
  50.  
  51. configNew.ps = subConfig.host;
  52.  
  53. } else {
  54.  
  55. configNew.ps = subConfig.add;
  56.  
  57. };
  58.  
  59. //پایان شرط
  60.  
  61.  
  62.  
  63. //if for pathname
  64.  
  65. if (subConfig.host !== '') {
  66.  
  67. configNew.path = '/' + subConfig.host + subConfig.path;
  68.  
  69. } else if (subConfig.sni !== '') {
  70.  
  71. configNew.path = '/' + subConfig.sni + subConfig.path;
  72.  
  73. } else {
  74.  
  75. configNew.path = '/' + subConfig.add + subConfig.path;
  76.  
  77. };
  78.  
  79.  
  80.  
  81. //پایان شرط
  82.  
  83.  
  84.  
  85. if (realpathname == '') {
  86.  
  87. configNew.add = url.hostname;
  88.  
  89. } else {
  90.  
  91. configNew.add = realpathname;
  92.  
  93. };
  94.  
  95. configNew.port = subConfig.port;
  96.  
  97. configNew.id = subConfig.id;
  98.  
  99. configNew.net = subConfig.net;
  100.  
  101. configNew.host = url.hostname;
  102.  
  103. //configNew.path = '/' + subConfig.add + subConfig.path;
  104.  
  105. configNew.tls = subConfig.tls;
  106.  
  107. configNew.sni = url.hostname;
  108.  
  109. configNew.aid = '0';
  110.  
  111. configNew.scy = 'auto';
  112.  
  113. configNew.type = 'auto';
  114.  
  115. configNew.fp = 'chrome';
  116.  
  117. configNew.alpn = 'http/1.1';
  118.  
  119. configNew = 'vmess://' + btoa(JSON.stringify(configNew));
  120.  
  121. newConfigs = newConfigs + configNew+ '\n';
  122.  
  123. }
  124.  
  125. }
  126.  
  127. }
  128.  
  129. return new Response(newConfigs);
  130.  
  131. } else {
  132.  
  133. const url = new URL(request.url);
  134.  
  135. const splitted = url.pathname.replace(/^\/*/, '').split('/');
  136.  
  137. const address = splitted[0];
  138.  
  139. url.pathname = splitted.slice(1).join('/');
  140.  
  141. url.hostname = address;
  142.  
  143. url.protocol = 'https';
  144.  
  145. return fetch(new Request(url, request));
  146.  
  147. }
  148.  
  149. },
  150.  
  151. };
  152.  
  153.  
  154.  
  155.  
  156.  
  157. function isIp(ipstr) {
  158.  
  159. try {
  160.  
  161. if (ipstr == "" || ipstr == undefined) return false;
  162.  
  163. if (!/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){2}\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-4])$/.test(ipstr)) {
  164.  
  165. return false;
  166.  
  167. }
  168.  
  169. var ls = ipstr.split('.');
  170.  
  171. if (ls == null || ls.length != 4 || ls[3] == "0" || parseInt(ls[3]) === 0) {
  172.  
  173. return false;
  174.  
  175. }
  176.  
  177. return true;
  178.  
  179. } catch (ee) { }
  180.  
  181. return false;
  182.  
  183. }
  184.  
  185.  
  186.  
Tags: Resdri
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement