mirror of
				https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
				synced 2025-10-31 18:21:10 +08:00 
			
		
		
		
	feat: 支持 Trojan, VMess, VLESS httpupgrade(暂不支持 Shadowsocks v2ray-plugin)
This commit is contained in:
		
							parent
							
								
									f970ea3361
								
							
						
					
					
						commit
						d073dfeef8
					
				| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "sub-store", | ||||
|   "version": "2.14.307", | ||||
|   "version": "2.14.308", | ||||
|   "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", | ||||
|   "main": "src/main.js", | ||||
|   "scripts": { | ||||
|  | ||||
| @ -16,6 +16,7 @@ import { Base64 } from 'js-base64'; | ||||
| // Parse SS URI format (only supports new SIP002, legacy format is depreciated).
 | ||||
| // reference: https://github.com/shadowsocks/shadowsocks-org/wiki/SIP002-URI-Scheme
 | ||||
| function URI_SS() { | ||||
|     // TODO: 暂不支持 httpupgrade
 | ||||
|     const name = 'URI SS Parser'; | ||||
|     const test = (line) => { | ||||
|         return /^ss:\/\//.test(line); | ||||
| @ -299,6 +300,7 @@ function URI_VMess() { | ||||
|             if (proxy.tls && proxy.sni) { | ||||
|                 proxy.sni = params.sni; | ||||
|             } | ||||
|             let httpupgrade = false; | ||||
|             // handle obfs
 | ||||
|             if (params.net === 'ws' || params.obfs === 'websocket') { | ||||
|                 proxy.network = 'ws'; | ||||
| @ -309,6 +311,12 @@ function URI_VMess() { | ||||
|                 proxy.network = 'http'; | ||||
|             } else if (['grpc'].includes(params.net)) { | ||||
|                 proxy.network = 'grpc'; | ||||
|             } else if ( | ||||
|                 params.net === 'httpupgrade' || | ||||
|                 proxy.network === 'httpupgrade' | ||||
|             ) { | ||||
|                 proxy.network = 'ws'; | ||||
|                 httpupgrade = true; | ||||
|             } | ||||
|             if (proxy.network) { | ||||
|                 let transportHost = params.host ?? params.obfsParam; | ||||
| @ -341,10 +349,15 @@ function URI_VMess() { | ||||
|                             '_grpc-type': getIfNotBlank(params.type), | ||||
|                         }; | ||||
|                     } else { | ||||
|                         proxy[`${proxy.network}-opts`] = { | ||||
|                         const opts = { | ||||
|                             path: getIfNotBlank(transportPath), | ||||
|                             headers: { Host: getIfNotBlank(transportHost) }, | ||||
|                         }; | ||||
|                         if (httpupgrade) { | ||||
|                             opts['v2ray-http-upgrade'] = true; | ||||
|                             opts['v2ray-http-upgrade-fast-open'] = true; | ||||
|                         } | ||||
|                         proxy[`${proxy.network}-opts`] = opts; | ||||
|                     } | ||||
|                 } else { | ||||
|                     delete proxy.network; | ||||
| @ -444,10 +457,13 @@ function URI_VLESS() { | ||||
|                 proxy[`${params.security}-opts`] = opts; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         let httpupgrade = false; | ||||
|         proxy.network = params.type; | ||||
|         if (proxy.network === 'tcp' && params.headerType === 'http') { | ||||
|             proxy.network = 'http'; | ||||
|         } else if (proxy.network === 'httpupgrade') { | ||||
|             proxy.network = 'ws'; | ||||
|             httpupgrade = true; | ||||
|         } | ||||
|         if (!proxy.network && isShadowrocket && params.obfs) { | ||||
|             proxy.network = params.obfs; | ||||
| @ -485,6 +501,10 @@ function URI_VLESS() { | ||||
|             if (['grpc'].includes(proxy.network)) { | ||||
|                 opts['_grpc-type'] = params.mode || 'gun'; | ||||
|             } | ||||
|             if (httpupgrade) { | ||||
|                 opts['v2ray-http-upgrade'] = true; | ||||
|                 opts['v2ray-http-upgrade-fast-open'] = true; | ||||
|             } | ||||
|             if (Object.keys(opts).length > 0) { | ||||
|                 proxy[`${proxy.network}-opts`] = opts; | ||||
|             } | ||||
|  | ||||
| @ -89,7 +89,12 @@ params = "?" head:param tail:("&"@param)* { | ||||
|   } | ||||
|    | ||||
|   if (params["type"]) { | ||||
|     let httpupgrade | ||||
|     proxy.network = params["type"] | ||||
|     if(proxy.network === 'httpupgrade') { | ||||
|       proxy.network = 'ws' | ||||
|       httpupgrade = true | ||||
|     } | ||||
|     if (['grpc'].includes(proxy.network)) { | ||||
|         proxy[proxy.network + '-opts'] = { | ||||
|             'grpc-service-name': params["serviceName"], | ||||
| @ -102,6 +107,10 @@ params = "?" head:param tail:("&"@param)* { | ||||
|       if (params["host"]) { | ||||
|         $set(proxy, proxy.network+"-opts.headers.Host", decodeURIComponent(params["host"]));  | ||||
|       } | ||||
|       if (httpupgrade) { | ||||
|         $set(proxy, proxy.network+"-opts.v2ray-http-upgrade", true);  | ||||
|         $set(proxy, proxy.network+"-opts.v2ray-http-upgrade-fast-open", true);  | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -87,7 +87,12 @@ params = "?" head:param tail:("&"@param)* { | ||||
|   } | ||||
|    | ||||
|   if (params["type"]) { | ||||
|     let httpupgrade | ||||
|     proxy.network = params["type"] | ||||
|     if(proxy.network === 'httpupgrade') { | ||||
|       proxy.network = 'ws' | ||||
|       httpupgrade = true | ||||
|     } | ||||
|     if (['grpc'].includes(proxy.network)) { | ||||
|         proxy[proxy.network + '-opts'] = { | ||||
|             'grpc-service-name': params["serviceName"], | ||||
| @ -100,6 +105,10 @@ params = "?" head:param tail:("&"@param)* { | ||||
|       if (params["host"]) { | ||||
|         $set(proxy, proxy.network+"-opts.headers.Host", decodeURIComponent(params["host"]));  | ||||
|       } | ||||
|       if (httpupgrade) { | ||||
|         $set(proxy, proxy.network+"-opts.v2ray-http-upgrade", true);  | ||||
|         $set(proxy, proxy.network+"-opts.v2ray-http-upgrade-fast-open", true);  | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -84,6 +84,11 @@ export default function URI_Producer() { | ||||
|                 if (proxy.network === 'http') { | ||||
|                     net = 'tcp'; | ||||
|                     type = 'http'; | ||||
|                 } else if ( | ||||
|                     proxy.network === 'ws' && | ||||
|                     proxy['ws-opts']?.['v2ray-http-upgrade'] | ||||
|                 ) { | ||||
|                     net = 'httpupgrade'; | ||||
|                 } | ||||
|                 result = { | ||||
|                     v: '2', | ||||
| @ -172,9 +177,15 @@ export default function URI_Producer() { | ||||
|                 if (proxy.flow) { | ||||
|                     flow = `&flow=${encodeURIComponent(proxy.flow)}`; | ||||
|                 } | ||||
|                 let vlessTransport = `&type=${encodeURIComponent( | ||||
|                     proxy.network, | ||||
|                 )}`;
 | ||||
|                 let vlessType = proxy.network; | ||||
|                 if ( | ||||
|                     proxy.network === 'ws' && | ||||
|                     proxy['ws-opts']?.['v2ray-http-upgrade'] | ||||
|                 ) { | ||||
|                     vlessType = 'httpupgrade'; | ||||
|                 } | ||||
| 
 | ||||
|                 let vlessTransport = `&type=${encodeURIComponent(vlessType)}`; | ||||
|                 if (['grpc'].includes(proxy.network)) { | ||||
|                     // https://github.com/XTLS/Xray-core/issues/91
 | ||||
|                     vlessTransport += `&mode=${encodeURIComponent( | ||||
| @ -220,7 +231,14 @@ export default function URI_Producer() { | ||||
|             case 'trojan': | ||||
|                 let trojanTransport = ''; | ||||
|                 if (proxy.network) { | ||||
|                     trojanTransport = `&type=${proxy.network}`; | ||||
|                     let trojanType = proxy.network; | ||||
|                     if ( | ||||
|                         proxy.network === 'ws' && | ||||
|                         proxy['ws-opts']?.['v2ray-http-upgrade'] | ||||
|                     ) { | ||||
|                         trojanType = 'httpupgrade'; | ||||
|                     } | ||||
|                     trojanTransport = `&type=${encodeURIComponent(trojanType)}`; | ||||
|                     if (['grpc'].includes(proxy.network)) { | ||||
|                         let trojanTransportServiceName = | ||||
|                             proxy[`${proxy.network}-opts`]?.[ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 xream
						xream