Skip to content

Bug Report:Shadowrocket订阅返回中vless enc没有携带encryption字段 #997

Description

@FeulerLoup

⚠️ 请务必按照模板填写完整信息,没有详细描述的issue可能会被忽略或关闭
⚠️ Please follow the template to provide complete information, issues without detailed description may be ignored or closed

基本信息 | Basic Info

XBoard版本 | Version: v20260618-8e4864b
部署方式 | Deployment: [Docker/手动部署] Docker
PHP版本 | Version:
数据库 | Database:

问题描述 | Description

Shadowrocket VLESS 节点缺失 encryption 参数问题分析

问题描述

订阅链接响应中,当 UA 为 Shadowrocket 时,VLESS 类型节点没有返回 encryption 参数。

根本原因

当 UA 为 Shadowrocket 时,VLESS 节点由 app/Protocols/Shadowrocket.phpbuildVless() 方法生成 URI。该方法从头到尾都没有往 $config 中写入 encryption 字段

buildVless()$config 数组初始化时只有两个字段:

public static function buildVless($uuid, $server)
{
    $protocol_settings = $server['protocol_settings'];
    $userinfo = base64_encode('auto:' . $uuid . '@' . Helper::wrapIPv6($server['host']) . ':' . $server['port']);
    $config = [
        'tfo' => 1,
        'remark' => $server['name'],
    ];

之后整个方法(TLS 处理、network 传输协议处理)都没有再添加 encryption,因此最终 http_build_query($config) 生成的 vless 链接里不会带 encryption 参数。

对比:其他协议实现均包含 encryption

General.php(通用 / v2rayN 等)和 ClashMeta.php 中,buildVless 都显式处理了 encryption

'encryption' => match (data_get($protocol_settings, 'encryption.enabled')) {
    true => data_get($protocol_settings, 'encryption.encryption', 'none'),
    default => 'none'
},

它们会根据服务器的 protocol_settings.encryption.enabled 决定输出实际加密方式,未开启时输出 none。而 Shadowrocket 的实现漏掉了这段逻辑。

影响

  • 服务器未开启 VLESS encryption 时:Shadowrocket 端因为链接里没有 encryption 参数,通常会按默认处理,可能勉强能连,但不符合标准。
  • 服务器开启了 VLESS encryption(新版 VLESS 加密特性)时:链接缺少 encryption 值,Shadowrocket 无法得知服务端要求的加密方式,导致握手 / 连接失败——这就是"没有返回 encryption"的直接后果。

修复方向

app/Protocols/Shadowrocket.phpbuildVless() 中,参照 General.php,在 $config 初始化时补上 encryption 字段:

$config = [
    'tfo' => 1,
    'remark' => $server['name'],
    'encryption' => match (data_get($protocol_settings, 'encryption.enabled')) {
        true => data_get($protocol_settings, 'encryption.encryption', 'none'),
        default => 'none'
    },
];

涉及文件

文件 说明
app/Protocols/Shadowrocket.php buildVless() 缺少 encryption 字段(问题所在)
app/Protocols/General.php buildVless() 正确处理了 encryption(参考实现)
app/Protocols/ClashMeta.php buildVless() 正确处理了 encryption(参考实现)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions