mirror of
				https://github.com/v2board/v2board.git
				synced 2025-11-04 19:31:45 +08:00 
			
		
		
		
	完善VLESS对接和部分客户端订阅链接
This commit is contained in:
		@@ -35,6 +35,9 @@ class Shadowrocket
 | 
			
		||||
            if ($item['type'] === 'vmess') {
 | 
			
		||||
                $uri .= self::buildVmess($user['uuid'], $item);
 | 
			
		||||
            }
 | 
			
		||||
            if ($item['type'] === 'vless') {
 | 
			
		||||
                $uri .= self::buildVless($user['uuid'], $item);
 | 
			
		||||
            }
 | 
			
		||||
            if ($item['type'] === 'trojan') {
 | 
			
		||||
                $uri .= self::buildTrojan($user['uuid'], $item);
 | 
			
		||||
            }
 | 
			
		||||
@@ -120,6 +123,48 @@ class Shadowrocket
 | 
			
		||||
        return $uri;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function buildVless($uuid, $server)
 | 
			
		||||
    {
 | 
			
		||||
        $config = [
 | 
			
		||||
            "v" => "2",
 | 
			
		||||
            "ps" => $server['name'],
 | 
			
		||||
            "add" => $server['host'],
 | 
			
		||||
            "port" => (string)$server['port'],
 | 
			
		||||
            "id" => $uuid,
 | 
			
		||||
            "aid" => '0',
 | 
			
		||||
            "net" => $server['network'],
 | 
			
		||||
            "type" => "none",
 | 
			
		||||
            "host" => "",
 | 
			
		||||
            "path" => "",
 | 
			
		||||
            "tls" => $server['tls'] ? "tls" : "",
 | 
			
		||||
            "flow" => $server['flow'],
 | 
			
		||||
            "sni" => "",
 | 
			
		||||
        ];
 | 
			
		||||
        if ($server['tls']) {
 | 
			
		||||
            if ($server['tls_settings']) {
 | 
			
		||||
                $tlsSettings = $server['tls_settings'];
 | 
			
		||||
                if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
 | 
			
		||||
                    $config['sni'] = $tlsSettings['serverName'];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if ((string)$server['network'] === 'tcp') {
 | 
			
		||||
            $tcpSettings = $server['network_settings'];
 | 
			
		||||
            if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
 | 
			
		||||
            if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = $tcpSettings['header']['request']['path'][0];
 | 
			
		||||
        }
 | 
			
		||||
        if ((string)$server['network'] === 'ws') {
 | 
			
		||||
            $wsSettings = $server['network_settings'];
 | 
			
		||||
            if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
 | 
			
		||||
            if (isset($wsSettings['headers']['Host'])) $config['host'] = $wsSettings['headers']['Host'];
 | 
			
		||||
        }
 | 
			
		||||
        if ((string)$server['network'] === 'grpc') {
 | 
			
		||||
            $grpcSettings = $server['network_settings'];
 | 
			
		||||
            if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
 | 
			
		||||
        }
 | 
			
		||||
//realit继续修
 | 
			
		||||
        return "vless://{$uuid}@{$server['host']}:{$server['port']}?security={$config['tls']}&encryption=none&headerType={$config['type']}&type={$server['network']}&flow={$server['flow']}&fp=chrome#${server['name']}"  . "\r\n";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function buildTrojan($password, $server)
 | 
			
		||||
    {
 | 
			
		||||
        $name = rawurlencode($server['name']);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user