| 905 | |
| 906 | |
| 907 | function createVLESSSub(userID_Path, hostName) { |
| 908 | let portArray_http = [80, 8080, 8880, 2052, 2086, 2095]; |
| 909 | let portArray_https = [443, 8443, 2053, 2096, 2087, 2083]; |
| 910 | |
| 911 | // Split the userIDs into an array |
| 912 | let userIDArray = userID_Path.includes(',') ? userID_Path.split(',') : [userID_Path]; |
| 913 | |
| 914 | // Prepare output array |
| 915 | let output = []; |
| 916 | |
| 917 | // Generate output string for each userID |
| 918 | userIDArray.forEach((userID) => { |
| 919 | // Check if the hostName is a Cloudflare Pages domain, if not, generate HTTP configurations |
| 920 | // reasons: pages.dev not support http only https |
| 921 | if (!hostName.includes('pages.dev')) { |
| 922 | // Iterate over all ports for http |
| 923 | portArray_http.forEach((port) => { |
| 924 | const commonUrlPart_http = `:${port}?encryption=none&security=none&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}-HTTP`; |
| 925 | const vlessMainHttp = `vless://${userID}@${hostName}${commonUrlPart_http}`; |
| 926 | |
| 927 | // For each proxy IP, generate a VLESS configuration and add to output |
| 928 | proxyIPs.forEach((proxyIP) => { |
| 929 | const vlessSecHttp = `vless://${userID}@${proxyIP}${commonUrlPart_http}-${proxyIP}-pp-worker`; |
| 930 | output.push(`${vlessMainHttp}`); |
| 931 | output.push(`${vlessSecHttp}`); |
| 932 | }); |
| 933 | }); |
| 934 | } |
| 935 | // Iterate over all ports for https |
| 936 | portArray_https.forEach((port) => { |
| 937 | const commonUrlPart_https = `:${port}?encryption=none&security=tls&sni=${hostName}&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}-HTTPS`; |
| 938 | const vlessMainHttps = `vless://${userID}@${hostName}${commonUrlPart_https}`; |
| 939 | |
| 940 | // For each proxy IP, generate a VLESS configuration and add to output |
| 941 | proxyIPs.forEach((proxyIP) => { |
| 942 | const vlessSecHttps = `vless://${userID}@${proxyIP}${commonUrlPart_https}-${proxyIP}-pp-worker`; |
| 943 | output.push(`${vlessMainHttps}`); |
| 944 | output.push(`${vlessSecHttps}`); |
| 945 | }); |
| 946 | }); |
| 947 | }); |
| 948 | |
| 949 | // Join output with newlines |
| 950 | return output.join('\n'); |
| 951 | } |