mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 01:11:46 +08:00 
			
		
		
		
	update: support grpc for clash & shadowrocket
This commit is contained in:
		| @@ -32,7 +32,7 @@ class Clash | ||||
|  | ||||
|         if ($server['tls']) { | ||||
|             $array['tls'] = true; | ||||
|             if ($server['tlsSettings']) { | ||||
|             if (isset($server['tlsSettings'])) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure'])) | ||||
|                     $array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false); | ||||
| @@ -42,7 +42,7 @@ class Clash | ||||
|         } | ||||
|         if ($server['network'] === 'ws') { | ||||
|             $array['network'] = 'ws'; | ||||
|             if ($server['networkSettings']) { | ||||
|             if (isset($server['networkSettings'])) { | ||||
|                 $wsSettings = json_decode($server['networkSettings'], true); | ||||
|                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) | ||||
|                     $array['ws-path'] = $wsSettings['path']; | ||||
| @@ -50,6 +50,14 @@ class Clash | ||||
|                     $array['ws-headers'] = ['Host' => $wsSettings['headers']['Host']]; | ||||
|             } | ||||
|         } | ||||
|         if ($server['network'] === 'grpc') { | ||||
|             $array['network'] = 'grpc'; | ||||
|             if (isset($server['networkSettings'])) { | ||||
|                 $grpcObject = json_decode($server['networkSettings'], true); | ||||
|                 $array['grpc-opts'] = []; | ||||
|                 $array['grpc-opts']['grpc-service-name'] = $grpcObject['serviceName']; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return $array; | ||||
|     } | ||||
|   | ||||
| @@ -44,6 +44,18 @@ class Shadowrocket | ||||
|                     $config['obfsParam'] = $wsSettings['headers']['Host']; | ||||
|             } | ||||
|         } | ||||
|         if ($server['network'] === 'grpc') { | ||||
|             $config['obfs'] = "grpc"; | ||||
|             if (isset($server['networkSettings'])) { | ||||
|                 $grpcObject = json_decode($server['networkSettings'], true); | ||||
|                 if (isset($grpcObject['serviceName'])) { | ||||
|                     $config['obfsParam'] = json_decode([ | ||||
|                         'Host' => $grpcObject['serviceName'] | ||||
|                     ]); | ||||
|                     $config['path'] = '/'; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         $query = http_build_query($config, '', '&', PHP_QUERY_RFC3986); | ||||
|         $uri = "vmess://{$userinfo}?{$query}"; | ||||
|         $uri .= "\r\n"; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user