mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	rules: let's support surge3 configuration
Signed-off-by: Beta Soft <betaxab@gmail.com>
This commit is contained in:
		| @@ -39,7 +39,7 @@ class ClientController extends Controller | ||||
|                 die($this->clash($user, $server)); | ||||
|             } | ||||
|             if (strpos($_SERVER['HTTP_USER_AGENT'], 'Surfboard') !== false) { | ||||
|                 die($this->surge($user, $server)); | ||||
|                 die($this->surge2($user, $server)); | ||||
|             } | ||||
|             if (strpos($_SERVER['HTTP_USER_AGENT'], 'Surge') !== false) { | ||||
|                 die($this->surge($user, $server)); | ||||
| @@ -112,7 +112,7 @@ class ClientController extends Controller | ||||
|         $proxyGroup = ''; | ||||
|         foreach ($server as $item) { | ||||
|             // [Proxy] | ||||
|             $proxies .= $item->name . ' = vmess, ' . $item->host . ', ' . $item->port . ', username=' . $user->v2ray_uuid; | ||||
|             $proxies .= $item->name . ' = vmess, ' . $item->host . ', ' . $item->port . ', username=' . $user->v2ray_uuid . ', tfo=true'; | ||||
|             if ($item->tls) { | ||||
|                 $tlsSettings = json_decode($item->tlsSettings); | ||||
|                 $proxies .= ', tls=' . ($item->tls ? "true" : "false"); | ||||
| @@ -158,6 +158,58 @@ class ClientController extends Controller | ||||
|         return $rules; | ||||
|     } | ||||
|  | ||||
|     private function surge2($user, $server) | ||||
|     { | ||||
|         $proxies = ''; | ||||
|         $proxyGroup = ''; | ||||
|         foreach ($server as $item) { | ||||
|             // [Proxy] | ||||
|             $proxies .= $item->name . ' = vmess, ' . $item->host . ', ' . $item->port . ', username=' . $user->v2ray_uuid; | ||||
|             if ($item->tls) { | ||||
|                 $tlsSettings = json_decode($item->tlsSettings); | ||||
|                 $proxies .= ', tls=' . ($item->tls ? "true" : "false"); | ||||
|                 if (isset($tlsSettings->allowInsecure)) { | ||||
|                   $proxies .= ', skip-cert-verify=' . ($tlsSettings->allowInsecure ? "true" : "false"); | ||||
|                 } | ||||
|             } | ||||
|             if ($item->network == 'ws') { | ||||
|                 $proxies .= ', ws=true'; | ||||
|                 if ($item->networkSettings) { | ||||
|                     $wsSettings = json_decode($item->networkSettings); | ||||
|                     if (isset($wsSettings->path)) $proxies .= ', ws-path=' . $wsSettings->path; | ||||
|                     if (isset($wsSettings->headers->Host)) $proxies .= ', ws-headers=host:' . $wsSettings->headers->Host; | ||||
|                 } | ||||
|             } | ||||
|             $proxies .= "\r\n"; | ||||
|             // [Proxy Group] | ||||
|             $proxyGroup .= $item->name . ', '; | ||||
|         } | ||||
|  | ||||
|         try { | ||||
|             $rules = ''; | ||||
|             foreach (glob(base_path() . '/resources/rules/' . '*.surge2.conf') as $file) { | ||||
|                 $rules = file_get_contents("$file"); | ||||
|             } | ||||
|         } catch (\Exception $e) {} | ||||
|  | ||||
|         // Subscription link | ||||
|         $subsURL = 'http'; | ||||
|         if (isset( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) == 'on') { | ||||
|             $subsURL .= 's'; | ||||
|         } | ||||
|         $subsURL .= '://'; | ||||
|         if ($_SERVER['SERVER_PORT'] != ('80' || '443')) { | ||||
|             $subsURL .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']; | ||||
|         } else { | ||||
|             $subsURL .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; | ||||
|         } | ||||
|  | ||||
|         $rules = str_replace('{subs_link}',$subsURL,$rules); | ||||
|         $rules = str_replace('{proxies}',$proxies,$rules); | ||||
|         $rules = str_replace('{proxy_group}',rtrim($proxyGroup, ', '),$rules); | ||||
|         return $rules; | ||||
|     } | ||||
|  | ||||
|     private function clash($user, $server) | ||||
|     { | ||||
|         $proxy = []; | ||||
|   | ||||
| @@ -73,10 +73,10 @@ class TutorialController extends Controller | ||||
|             array('-', '_', ''), | ||||
|             base64_encode($response['data']['safe_area_var']['subscribe_url']) | ||||
|         ); | ||||
| 	// end | ||||
| 	// fuck support surge urlencode subscribe | ||||
| 	$response['data']['safe_area_var']['ue_subscribe_url'] = urlencode($response['data']['safe_area_var']['subscribe_url']); | ||||
| 	// end | ||||
|         // end | ||||
|         // fuck support surge urlencode subscribe | ||||
|         $response['data']['safe_area_var']['ue_subscribe_url'] = urlencode($response['data']['safe_area_var']['subscribe_url']); | ||||
|         // end | ||||
|         return response($response); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user