mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	subscription: add shadowsocks SIP008 subscription support
Signed-off-by: Beta Soft <betaxab@gmail.com>
This commit is contained in:
		| @@ -50,6 +50,9 @@ class ClientController extends Controller | ||||
|                 if (strpos($flag, 'shadowrocket') !== false) { | ||||
|                     die($this->shadowrocket($user, $servers)); | ||||
|                 } | ||||
|                 if (strpos($flag, 'shadowsocks') !== false) { | ||||
|                     die($this->shaodowsocksSIP008($user, $servers)); | ||||
|                 } | ||||
|             } | ||||
|             die($this->origin($user, $servers)); | ||||
|         } | ||||
| @@ -135,6 +138,25 @@ class ClientController extends Controller | ||||
|         return base64_encode($uri); | ||||
|     } | ||||
|  | ||||
|     private function shaodowsocksSIP008($user, $servers = []) | ||||
|     { | ||||
|         $configs = []; | ||||
|         $subs = []; | ||||
|         $subs['servers'] = []; | ||||
|  | ||||
|         foreach ($servers as $item) { | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|                 array_push($configs, URLSchemes::buildShadowsocksSIP008($item, $user)); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $subs['version'] = 1; | ||||
|         $subs['remark'] = config('v2board.app_name', 'V2Board'); | ||||
|         $subs['servers'] = array_merge($subs['servers'] ? $subs['servers'] : [], $configs); | ||||
|  | ||||
|         return json_encode($subs, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); | ||||
|     } | ||||
|  | ||||
|     private function surge($user, $servers = []) | ||||
|     { | ||||
|         $proxies = ''; | ||||
|   | ||||
| @@ -17,6 +17,18 @@ class URLSchemes | ||||
|         return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n"; | ||||
|     } | ||||
|  | ||||
|     public static function buildShadowsocksSIP008($server, User $user) | ||||
|     { | ||||
|         $config = [ | ||||
|             "id" => $server['id'], | ||||
|             "remark" => $server['name'], | ||||
|             "server" => $server['host'], | ||||
|             "server_port" => $server['port'], | ||||
|             "password" => $user['uuid'], | ||||
|             "method" => $server['cipher'] | ||||
|         ]; | ||||
|         return $config; | ||||
|     } | ||||
|  | ||||
|     public static function buildVmess($server, User $user) | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user