Skip to content

fix(protocol): preserve VLESS HTTP upgrade URI options#263

Merged
ZeroDeng01 merged 1 commit into
ZeroDeng01:devfrom
cesaryuan:fix/vless-http-upgrade-uri
Jul 23, 2026
Merged

fix(protocol): preserve VLESS HTTP upgrade URI options#263
ZeroDeng01 merged 1 commit into
ZeroDeng01:devfrom
cesaryuan:fix/vless-http-upgrade-uri

Conversation

@cesaryuan

Copy link
Copy Markdown
Contributor

描述

修复 VLESS URI 编码未保留 HTTP Upgrade 扩展的问题,确保 Mihomo 节点经过“配置 → URI → 配置”往返转换后仍使用原有传输方式。

关联 Issue

Fixes #262

更改类型

  • 🐛 修复 Bug (Bug)
  • ✨ 新功能 (Feature)
  • 📝 文档更新 (Docs)
  • 🎨 样式或界面改进 (UI)
  • ♻️ 代码重构 (Refactor)
  • ⚡ 性能优化 (Perf)
  • 🔧 配置更改 (Config)
  • 🧪 测试更新 (Test)

更改内容

  • HttpUpgrade 启用时,在 VLESS URI 中写入 httpUpgrade=1
  • HttpUpgradeFastOpen 启用时,在 VLESS URI 中写入 httpUpgradeFastOpen=1
  • 扩展现有 VLESS 编解码测试,验证两个字段均可无损往返

截图

不适用。

检查清单

  • 我的代码遵循项目代码风格

  • 后端检查已通过

    golangci-lint run
    go test ./...
    
  • 前端改动已运行 yarn run lint

  • UI 改动已检查 light/dark 和响应式状态

  • 已按需补充或更新后端测试、注释和文档

  • 行为或契约变化时,已检查跨层同步

  • 本次更改不会引入安全漏洞

已运行命令或检查:

gofmt -l <all Go files>                                  # 通过,无输出
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2 run  # 通过,0 issues
go test ./node/protocol -run TestVlessEncodeDecode -count=1                # 通过
go test <all packages except sublink/api>                                  # 通过
go test ./...                                                               # node/protocol 通过;Windows 下既有 api 测试失败

本地全量测试的 api 失败与本改动无关:部分测试将 Windows t.TempDir() 返回的反斜杠路径直接拼入 JSON,随后返回“配置读取错误”。PR 的 Linux GitHub Actions 将继续执行仓库规定的完整 go test ./...

其他说明

这是编码器层面的最小修复。URI 解码、Mihomo 导入和 Mihomo 输出路径已经支持这两个字段,无需修改 API、前端、配置或文档。

Encode HTTP Upgrade and fast-open flags into VLESS URIs so Mihomo configurations survive round-trip conversion. Extend the VLESS encode/decode regression test to cover both options.

Fixes ZeroDeng01#262
Copilot AI review requested due to automatic review settings July 22, 2026 11:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes VLESS URI encoding so that Mihomo nodes retain the v2ray-http-upgrade and v2ray-http-upgrade-fast-open transport semantics after a “config → URI → config” roundtrip, preventing unintended downgrade back to plain WebSocket.

Changes:

  • Update EncodeVLESSURL to emit httpUpgrade=1 when Query.HttpUpgrade == 1.
  • Update EncodeVLESSURL to emit httpUpgradeFastOpen=1 when Query.HttpUpgradeFastOpen == 1.
  • Extend the VLESS encode/decode roundtrip test to assert both fields are preserved.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
node/protocol/vless.go Adds encoding of httpUpgrade and httpUpgradeFastOpen query parameters when enabled to preserve HTTP Upgrade transport options.
node/protocol/vless_test.go Extends the roundtrip test to cover HttpUpgrade and HttpUpgradeFastOpen so regressions are caught.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ZeroDeng01
ZeroDeng01 merged commit 6af42f1 into ZeroDeng01:dev Jul 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants