| 825 | |
| 826 | |
| 827 | function createVLESSSub(userID_Path, hostName) { |
| 828 | let portArray_http = [80, 8080, 8880, 2052, 2086, 2095, 2082]; |
| 829 | let portArray_https = [443, 8443, 2053, 2096, 2087, 2083]; |
| 830 | |
| 831 | // Split the userIDs into an array |
| 832 | let userIDArray = userID_Path.includes(',') ? userID_Path.split(',') : [userID_Path]; |
| 833 | |
| 834 | // Prepare output array |
| 835 | let output = []; |
| 836 | |
| 837 | // Generate output string for each userID |
| 838 | userIDArray.forEach((userID) => { |
| 839 | // Check if the hostName is a Cloudflare Pages domain, if not, generate HTTP configurations |
| 840 | // reasons: pages.dev not support http only https |
| 841 | if (!hostName.includes('pages.dev')) { |
| 842 | // Iterate over all ports for http |
| 843 | portArray_http.forEach((port) => { |
| 844 | const commonUrlPart_http = `:${port}?encryption=none&security=none&fp=random&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}-HTTP-${port}`; |
| 845 | const vlessMainHttp = `vless://${userID}@${hostName}${commonUrlPart_http}`; |
| 846 | |
| 847 | // For each proxy IP, generate a VLESS configuration and add to output |
| 848 | proxyIPs.forEach((proxyIP) => { |
| 849 | const vlessSecHttp = `vless://${userID}@${proxyIP}${commonUrlPart_http}-${proxyIP}-EDtunnel`; |
| 850 | output.push(`${vlessMainHttp}`); |
| 851 | output.push(`${vlessSecHttp}`); |
| 852 | }); |
| 853 | }); |
| 854 | } |
| 855 | // Iterate over all ports for https |
| 856 | portArray_https.forEach((port) => { |
| 857 | const commonUrlPart_https = `:${port}?encryption=none&security=tls&sni=${hostName}&fp=random&type=ws&host=${hostName}&path=%2F%3Fed%3D2048#${hostName}-HTTPS-${port}`; |
| 858 | const vlessMainHttps = `vless://${userID}@${hostName}${commonUrlPart_https}`; |
| 859 | |
| 860 | // For each proxy IP, generate a VLESS configuration and add to output |
| 861 | proxyIPs.forEach((proxyIP) => { |
| 862 | const vlessSecHttps = `vless://${userID}@${proxyIP}${commonUrlPart_https}-${proxyIP}-EDtunnel`; |
| 863 | output.push(`${vlessMainHttps}`); |
| 864 | output.push(`${vlessSecHttps}`); |
| 865 | }); |
| 866 | }); |
| 867 | }); |
| 868 | |
| 869 | // Join output with newlines |
| 870 | return output.join('\n'); |
| 871 | } |
| 872 | |