Skip to content

[Bug] VLESS links with security=tls and type=httpupgrade are parsed incorrectly #2609

Open

Description

@Slaviro

验证步骤

  • 我已经阅读了 文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我仔细看过 文档 并未解决问题
  • 我已在 Issue Tracker 中寻找过我要提出的问题,并且没有找到
  • 我是中文用户,而非其他语言用户
  • 我已经使用最新的 Alpha 分支版本测试过,问题依旧存在
  • 我提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
  • 我提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器或者堆砌大量对于复现无用的配置等。
  • 我提供了完整的日志,而不是出于对自身智力的自信而仅提供了部分认为有用的部分。
  • 我直接使用 Mihomo 命令行程序重现了错误,而不是使用其他工具或脚本。

操作系统

Linux

系统版本

Raspberry Pi OS

Mihomo 版本

1.19.21

配置文件

proxy-providers:
    TrustZone:
        type: http
        url: 'https://trustzone.online/get_subscription_data.php?u=[NUM]&c=[STRING]&s=vless#Trust.Zone'
        path: ./subs/trustzone.txt
        interval: 3600
        health-check:
            enable: true
            interval: 300
            url: 'https://www.google.com/generate_204'
        headers:
            User-Agent:
              - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36"

描述

I have a subscription on one of VPN services named TrustZone. When this subscription is added, a VPN engine gets a txt file with a list of vless:// links, each on a new line.

Each link has a format of:

vless://[UUID]@[IP ADDRESS]:443?security=tls&type=httpupgrade&headerType=&path=%2F[PATH]%2F&host=[HOST]&sni=[HOST]&fp=chrome#[TAG]

When these links are parsed, a node for each server is added to the MetacubeX UI, but these servers are not working - url-test does nothing, selecting a server leads to an non-working network.

If I do curl -s http://127.0.0.1:9090/proxies I get something like:

                "[NAME]": {
                    "alive": false,
                    "dialer-proxy": "",
                    "extra": {
                        "https://www.google.com/generate_204": {
                            "alive": false,
                            "history": [
                                {
                                    "time": "2026-03-10T03:57:49.550513759+04:00",
                                    "delay": 0
                                }
                            ]
                        },
                        "https://www.gstatic.com/generate_204": {
                            "alive": false,
                            "history": [
                                {
                                    "time": "2026-03-10T03:57:49.926629235+04:00",
                                    "delay": 0
                                }
                            ]
                        }
                    },
                    "history": [
                        {
                            "time": "2026-03-10T03:57:49.550513759+04:00",
                            "delay": 0
                        },
                        {
                            "time": "2026-03-10T03:57:49.926629235+04:00",
                            "delay": 0
                        }
                    ],
                    "id": "[UUID]",
                    "interface": "",
                    "mptcp": false,
                    "name": "[NAME]",
                    "provider-name": "TrustZone",
                    "routing-mark": 0,
                    "smux": false,
                    "tfo": false,
                    "type": "Vless",
                    "udp": true,
                    "uot": true,
                    "xudp": true
                },

where alive: false seems to tell me that Mihomo can't work with this server.

However if I convert a server configuration like this:

proxies:
  - name: "TrustZone-Manual"
    type: vless
    server: [IP]
    port: 443
    uuid: [UUID]
    network: ws
    tls: true
    sni: [SNI]
    client-fingerprint: chrome
    alpn:
      - h2
      - http/1.1
    ws-opts:
      path: "/[PATH]/"
      headers:
        Host: [HOST]
      v2ray-http-upgrade: true  

url-test starts working and server can be chosen and used.

After some debugging I found out that if type is httpupgrade but the link doesn't contaion a "ed" parameter, the v2ray-http-upgrade: true option is not added to the server configuration, and also it seems like proxy["network"] is also set to "httpupgrade" while should be "ws".

I fixed this locally by this patch and it seems to work as intended.

diff --git a/common/convert/v.go b/common/convert/v.go
index a9039c5a..6eebb4dd 100644
--- a/common/convert/v.go
+++ b/common/convert/v.go
@@ -111,6 +111,11 @@ func handleVShareLink(names map[string]int, url *url.URL, scheme string, proxy m
                wsOpts["path"] = query.Get("path")
                wsOpts["headers"] = headers
 
+               if network == "httpupgrade" {
+                       wsOpts["v2ray-http-upgrade"] = true
+                       proxy["network"] = "ws"
+               }
+
                if earlyData := query.Get("ed"); earlyData != "" {
                        med, err := strconv.Atoi(earlyData)
                        if err != nil {

重现方式

  1. Add subsription
  2. Select server in MetacubeX
  3. Network is unreachable, url-test doesn't work.

日志

Activity

  1. added
    bug
    on Mar 10, 2026
  2. wwqgtxx commented on Mar 11, 2026

    @wwqgtxx
    Collaborator

    Your findings are very helpful. You can send us a PR directly (in fact, besides v.go, converter.go should also make corresponding modifications).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions