Skip to content

版本更新合入主分支 - #44

Merged
shl6688 merged 47 commits into
masterfrom
develop
Nov 4, 2026
Merged

shl6688 merged 47 commits into
masterfrom
develop

Conversation

@17673651504

Copy link
Copy Markdown
Collaborator

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style/formatting change
  • ♻️ Code refactoring
  • ⚡ Performance improvement
  • ✅ Test addition/update

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

Screenshots (if applicable)

anruostyle and others added 30 commits October 9, 2026 15:02
…n quota rejection

- host.go: readPortNotification uses readWithTimeout (2s, below the 5s
  gatewayPortTimeout); on timeout close the stream to unblock the read
  goroutine and avoid it hanging until connection teardown
- websocket.go: map concurrent-connection rejection (4001 from new
  gateways, 1008+reason from old ones) to ErrQuotaExceeded so the
  reconnect loop stops instead of retry storming
- annotate the 429 branch as defensive (gateway handshake never returns
  429 today; visitor HTTP paths only)
…nglish and add zh site

- config.mjs introduces VitePress locales: root locale switched to English, add zh Chinese site, base path changed to devspace-devbridge-test
- original Chinese docs moved to zh/, root docs translated to English (guide/reference/integrations/changelog/404/index)
- add Layout.vue and TranslationNotice.vue theme components; English pages show a machine/AI-translation notice banner at the top
- add contributing guide and disclaimer reference docs (reference/contributing, reference/disclaimer, bilingual)
- custom.css refines thin scrollbars, translucent navbar background, and nav menu icons
- add custom audit script scripts/audit.mjs to filter advisories with no fix available; package.json bumps markdownlint-cli2/smol-toml and adds katex override
- batch-add executable permission bits to files
# Conflicts:
#	docs/package-lock.json
#	docs/package.json
- revert base, sitemap hostname, and nav-icon CSS selectors from devspace-devbridge-test back to devspace-devbridge
- these were test-deployment overrides that should not have been committed
- revert spurious executable-bit flips introduced when staging from a workspace whose filesystem marked docs files executable
- modes now match upstream: 26 root docs files at 100644, 11 canonical files remain 100755, zh/ copies mirror their root counterparts
- no content changes
- Top-level README becomes a repository overview: add cli/ and go-sdk/ to
  the structure tree, add a Components section linking to cli/README.md and
  go-sdk/README.md, and fix the publishing trigger (main -> master/develop).
- Sink the docs contribution details (local preview, adding pages, dependency
  policy, content ownership, publishing) into a new docs/README.md; the top
  README now links to it.
- Make every README English by default and add a separate README.zh-CN.md
  (top-level, docs/, cli/, go-sdk/) with bidirectional language links.
- Translate code-block comments, diagram labels and example strings in the
  English cli/ and go-sdk/ READMEs; keep commands, paths, URLs and syntax
  intact.
- Exclude docs/README.md and docs/README.zh-CN.md from the VitePress build
  via srcExclude so they do not become stray site pages.
Revert index.js to use default VitePress Layout instead of custom
Layout.vue that injects TranslationNotice. Files kept for re-enabling.
- Import order: drop the "blank line" mentions; groups are stdlib ->
  third-party -> internal packages, sorted with goimports.
- Release tags: remove the standalone "Release tags" subsection (it
  duplicated the Go SDK release steps) and fold its immutability note into
  the Go SDK release flow.
- Go SDK release: describe the actual mechanism -- a maintainer triggers
  build-sdk.yml via workflow_dispatch with a version, the workflow creates
  the GitHub Release (--latest=false) and syncs the go-sdk/v* tag to GitCode;
  the module proxy then indexes and permanently caches it. It is not a
  manual tag push.
- CI triggers: drop `main` from the build-cli.yml PR trigger description;
  the repository only has develop and master.
Follow the eduSwarm README framework to turn the sparse overview into a
real landing page, while keeping module specifics sunk in their own
READMEs and linked from the top.

- Header: add license / Go / platform / docs badges and the online docs
  link.
- Introduction: explain the Host <-> Gateway <-> Connect relay model and
  the two entry points (CLI, Go SDK).
- Architecture: add the relay diagram plus control/data channel, JWT and
  SNI notes.
- Quick Start: minimal install -> login -> host -> connect flow, linking
  to cli/README.md and the online quickstart for the full reference.
- Core Capabilities: a CLI/SDK capability matrix with per-row links to the
  module README anchors.
- Repository Structure / Components: directory tree plus a CLI / Go SDK /
  Docs table linking each module README.
- Documentation: online site link, a key-pages table, and docs/README.md
  for site development.
- Contributing / License: link the contributing guide; Apache-2.0.

Mirrored in README.zh-CN.md.
- Header: add a placeholder logo (docs/assets/images/devbridge_logo.svg,
  relay motif) and a centered tagline + nav row (中文 · English · Online
  Docs · Quick Start · Architecture · CLI · Go SDK), mirroring the
  eduSwarm header. The nav row replaces the redundant language blockquote.
- Introduction: condense to three sentences. Present Host and Connect as
  the two usage modes (listener / sender side), not as "the service" vs
  "a client"; drop the unsupported "CI runner" example.
- Disclaimer: add a brief one-line disclaimer (non-production, "as is" /
  no SLA, user-side security responsibility, compliance) linking the full
  terms, between Contributing and License.

Mirrored in README.zh-CN.md.
The Chinese README previously linked to English module READMEs and the
English docs site. Make it consistently "中文跳转中文":

- Core Capabilities table: cli/go-sdk detail links now use the Chinese
  module READMEs with Chinese heading anchors (e.g. #隧道管理, #快速开始).
- Nav row, intro, Quick Start, Repository Structure components table and
  Documentation section: cli/go-sdk/docs README links now use the .zh-CN
  versions.
- All online docs URLs now use the /zh/ locale prefix
  (https://huaweicloud.github.io/devspace-devbridge/zh/...), including the
  key-pages table, contributing and disclaimer links.

The EN README is unchanged (English links stay English).
docs: enrich top-level README overview and add DevBridge logo / 丰富顶层 README 总览并新增
CLI auth login/status 的 API Key 校验原来打 /auth/check,该路由已随
relay-controller 前缀一起下线(测试环境返回 503)。改为 POST
/v1/api-keys/check——这是 mgmt-service 提供的专用校验接口,与
relay-gateway、bridge-service 共用,X-API-Key 头鉴权,200=有效、
401=无效,端侧已实测通过。

配套改动:
- config.go: RelayControllerPath 从 /open-api-inner/v1/relay-controller
  收敛为 /v1(去掉 open-api-inner 与 relay-controller 中间段)
- go-sdk/client.go: DefaultAPIBaseURL 去掉旧前缀,与新 /v1 路径对齐
- go-sdk/models.go: createTunnelRequest.ClusterID 的 json tag 由
  ClusterId 修正为 clusterId,与后端字段大小写一致

测试:go vet、go test ./... 通过;test 环境验证 auth login 有效 key
200、无效 key 401,list/limits/create/show/update/token/port/delete
全接口回归通过。
- setup-devbridge-ssh.sh: Linux ECS 一键配置 SSH 隧道 (systemd 自启, 加密存 API Key, 自动续期)
- setup-devbridge-ssh-windows.txt: Windows ECS 一键配置 RDP 隧道 (计划任务自启)
- 一键安装预启动指导.md: 安装指导文档

从 gitcode.com/anruostyle/devbridge-ssh-setup 原样并入,未改 URL 引用。
在 CLI 和 go-sdk 的错误输出中区分「隧道内服务 / 网关 / 网络层拦截」三类来源。

改动点:

1. go-sdk/internal/httpclient (Do)
   - 非 2xx 时:parseAPIError 仍优先(typed APIError 胜出)
   - X-Served-By 为空 → 判定「请求未到达隧道服务」(防火墙/LB/CDN 拦截)
   - 有 X-Served-By → 附「来源: <cluster>,请求 ID: <id>」
   - 新增 MsgServerHTTPErrorWithMeta / MsgNotReachedTunnel,删除已成死代码的
     MsgServerHTTPError

2. cli/internal/netutil/ping (PingURI)
   - 传输层错误(DNS/TLS/reset/EOF)统一归为「隧道连接断开」,
     不再伪装成 Bad Gateway / Gateway Timeout
   - 4xx/5xx 且无 X-Served-By → 「请求未到达隧道服务」
   - 移除 isTimeout 及其 net 依赖
   - 新增 i18n Ping.Disconnected / Ping.NotServedByTun

3. go-sdk/websocket (dialWithRetry)
   - 握手失败追加 respMetaSuffix:无 X-Served-By 时为空(未到网关),
     否则附「(来源: <cluster>,请求 <id>)」,保留 lastResp 以携带响应头
   - 新增 MsgWSResponseOrigin

4. 测试
   - httpclient_test.go:NoServedByOnError / ServedByOnError / BusinessErrorWins
   - ping_test.go:NoServedByOnError / ServedByKeepsStatus / DisconnectedOnTransportError

验证:go build / go vet / go test -count=1 全绿(新增用例逐条通过)。
补齐之前遗漏的第三层判断:端侧此前只读 X-Served-By 判断「是否到达隧道」,
不读 Server,无法区分「隧道内服务错误」vs「网关自产错误」。现改用自定义头
X-DevBridge-Error-Origin(WAF/ELB 不改写,生产可靠)。

改动点:

1. go-sdk/internal/httpclient (Do)
   - 非 2xx 且 origin=service → 报「隧道内服务错误」(新 MsgServiceHTTPErrorWithMeta)
   - origin=gateway/空 → 保持原「服务端错误」文案
   - 新增 headerErrorOrigin 常量

2. cli/internal/netutil/ping (PingURI)
   - 有 X-Served-By 且 origin=service → 「隧道内服务错误: HTTP %s」
   - 有 X-Served-By 且 origin=gateway/空 → 「网关错误: HTTP %s」
   - 新增 Ping.GatewayError / Ping.ServiceError i18n 文案

3. 测试
   - ping_test.go 更新 ServedByKeepsStatus 语义 + 新增 ServiceOriginError
   - httpclient_test.go 新增 ServiceOriginOnError

验证:go build / go vet / go test -count=1 全绿。
- Add open-api.yaml with 3 API Key management endpoints:
  GET  /open-api-public/v1/relay/api-keys        (list keys)
  POST /open-api-public/v1/relay/api-key         (create key)
  POST /open-api-public/v1/relay/api-keys/{keyId} (delete key)
- Support IAM 3.0 (X-Auth-Token) and IAM 5.0 (AK/SK signing) auth
- Include dev, test, and production server environments
- 45 non-script files (cli/**/*.go, docs/**/*.md, cli/README.md,
  cli/install.ps1, .github/workflows/*.yml) had the executable bit
  baked into history from a workspace whose filesystem marked every
  file 0750; revert to 100644 to match upstream canonical modes
- 4 shebang shell scripts (cli/install.sh, cli/scripts/*.sh) kept at
  100755
- no content changes
replace hand-coded 256x256 placeholder with 80x80 vector logo
(gradient + path export)
docs: add OpenAPI spec for API Key management interfaces
…0.23.3->^0.24.0

Resolves 5 vulnerabilities blocking the Deploy documentation workflow:

vite / launch-editor (3 advisories, all fixed in? in vite 6.4.4):
  - GHSA-698v-4r3x-3vcv (medium)  launch-editor % escaping on Windows
  - GHSA-r825-w8mm-5pxw (medium)  launch-editor CLI flag injection
  - GHSA-587h-7wmj-h5pm (high)    launch-editor existsSync bypass on Windows
  @vitejs/plugin-vue & vitepress flagged transitively via vite; both clear
  once vite is patchedGHSAlifted to 6.4.4. vitepress stays at 1.6.4 (latest).

markdown-it (3 advisories, fixed in markdown-it 15.0.3):
  - GHSA-r7fv-28h4-cvq7 (high)    smartquotes quadratic complexity
  - GHSA-vfgh-jcmw-g37q (low)     inline HTML parsing DoS
  - GHSA-gfr2-rv44/ -rv44-r23c (high)    link reference definition O(n^2)
  markdownlint-cli2 ^0.23.3 -> ^0.24.0 brings markdown-it 15.0.3.
  braces GHSA-vfj7-8cjw-p6xm remains in the audit ignore list (no fix).

package-lock.json regenerated against registry.npmjs.org (all 270
resolved URLs point to the official registry). Verified: npm audit
against registry.npmjs.org reports 0 vulnerabilities.
ci(docs): fix npm audit — bump vite 6.4.3->6.4.4, markdownlint-cli2 ^…
anruostyle and others added 8 commits November 4, 2026 17:28
回退 SDK 里的版本逻辑,版本信息只保留在 CLI 层。

此前为让 relay-gateway 的 WS 路径也能做最低版本拦截,把版本上报
(WS 握手 User-Agent 头,881c0dc)和 426 识别(f82e5d0)都放进了
go-sdk。但版本上报与升级提示属于 CLI 职责,不应侵入共享 SDK 库。
本次只保留 CLI 层的 REST User-Agent 版本上报(versionTransport 一直
在 cli/internal/config/client.go),撤回 SDK 侧改动。

回退内容:
- go-sdk/client.go: 移除 Config.Version 字段、Devbridge.version 字段
  及 New() 中的透传
- go-sdk/websocket.go: buildWSHeader 去掉 version 参数与 WS 握手
  User-Agent 注入;dialWithRetry 移除 426 分支;删除 gatewayMessage
  辅助函数;恢复 encoding/json、runtime 导入
- go-sdk/host.go / connect.go: buildWSHeader 调用处去掉 d.version 实参
- go-sdk/reconnect.go: gatewayRejectedError 移除 IsUpgradeRequired
  分支,恢复仅判断 quota/tunnel-not-found
- cli/internal/config/client.go: NewClient 移除 Version: version 行

保留:UpgradeRequiredError 类型与 IsUpgradeRequired()(REST 426 仍
依赖,CLI updater.FormatError 需要用它们渲染升级提示);CLI 的
versionTransport REST User-Agent 上报不变。
…r-Agent

让 CLI 通过 host/connect 与网关交互时携带 User-Agent 版本头,而 SDK
直用时保持干净、不带任何版本语义。

做法:SDK 只暴露一个通用的 WS 握手 header 透传位,不理解也不关心
header 的内容;CLI 在 NewClient 里把自己拼好的 User-Agent 塞进去。
这样「版本」的知识完全留在 CLI 层,SDK 直用(零值 WSHeaders)不会
带任何额外 header。

改动点:
- go-sdk/client.go: Config 新增 WSHeaders (http.Header),Devbridge
  新增 wsHeaders 字段并在 New() 透传
- go-sdk/websocket.go: buildWSHeader 新增 extra 参数,把传入的
  header 逐项合并到手shaking header
- go-sdk/host.go / connect.go: buildWSHeader 调用处传入 d.wsHeaders
- go-sdk/websocket_test.go: 新增 TestBuildWSHeader,验证 extra
  header 注入 + nil map 不注入两种情况
- cli/internal/config/client.go: NewClient 通过 WSHeaders 注入
  User-Agent(复用 REST 侧同一 userAgent 格式)

验证:go build/vet/test 两模块全绿;test 包端到端 host/connect
握手成功。SDK 直用(不设 WSHeaders)不携带任何额外 header,向后
兼容。
端侧此前只在 REST 路径处理 426(bridge-service),WS 握手路径
(host/connect 连 relay-gateway)遇到 426 只报裸
"expected handshake response status code 101 but got 426",随后
进入 5 次 dial 重试 + reconnectLoop 反复重连风暴,用户看不到
有效信息,也无法停止重试。

本次在 SDK 的 dial 层补上 WS 握手 426 识别,复用已有的
UpgradeRequiredError 类型(与 REST 侧一致):
- websocket.go: dialWithRetry 新增 426 分支,读取响应体解析
  message 字段并通过 gatewayMessage 提取,返回
  &UpgradeRequiredError{...} 立即退出(版本不会因重试而改变,
  重试无意义);gatewayMessage 无 message 时回退到原始 body
- reconnect.go: gatewayRejectedError 增加 IsUpgradeRequired(err)
  判断,使 reconnectLoop 将 426 视为终止性拒绝停止重连

对 SDK 直用方零破坏:正常/409/429/隧道不存在等场景行为不变,
仅 426 场景从「裸错误+重连风暴」优化为「明确的版本过期错误+
立即停止」。复用 SDK 已有类型,未引入新概念。

UA 上报(c20891a 的 WSHeaders)与本次层级正交:UA 是否携带由
WSHeaders 是否有值决定(仅 CLI 设置),与 426 识别无关。
@anruostyle anruostyle closed this Nov 4, 2026
@grapedev-bot grapedev-bot added bug Something isn't working spec-ready priority/high labels Nov 4, 2026
@grapedev-bot grapedev-bot self-assigned this Nov 4, 2026
@anruostyle anruostyle reopened this Nov 4, 2026
@huaweicloud huaweicloud deleted a comment from grapedev-bot Nov 4, 2026
@huaweicloud huaweicloud deleted a comment from grapedev-bot Nov 4, 2026
@huaweicloud huaweicloud deleted a comment from grapedev-bot Nov 4, 2026
@huaweicloud huaweicloud deleted a comment from grapedev-bot Nov 4, 2026
@anruostyle anruostyle removed the bug Something isn't working label Nov 4, 2026
@anruostyle

Copy link
Copy Markdown
Collaborator

SDK处已经修改,SDK 直用 host/connect 不会带 UA ,补 426 识别对 SDK 使用零破坏

@grapedev-bot

Copy link
Copy Markdown
Collaborator

[Coding Agent] 收到,并已在 PR #44(develop→master,head 9f49143)逐项核实:

SDK处已经修改,SDK 直用 host/connect 不会带 UA ,补 426 识别对 SDK 使用零破坏

核实结果与该结论一致:

  • WS 握手 426 识别已补齐(9f49143 fix(sdk): restore WS 426 upgrade recognition with immediate stop):go-sdk/websocket.go dialWithRetry 遇 426 返回 UpgradeRequiredError 立即退出(重试无法改变版本,避免 dial 重试 + 重连风暴);go-sdk/reconnect.go 将 426 视为终止性拒绝停止重连,与 REST 侧(internal/httpclient/httpclient.go)行为一致。
  • UA 仅由 CLI 注入:cli/internal/config/client.go 通过 versionTransport + WSHeaders 注入 devbridge-cli/<version>;SDK 直用 host/connect(零值 Config)不带 UA,网关版本检查不影响 SDK 直用流量——「补 426 识别对 SDK 使用零破坏」成立。
  • 此前交办的 4 项 P0 亦已在 PR 版本更新合入主分支 #44 内修复:重连退避钳制(e488324)、ping 连接泄漏(7e3836f)、安装脚本先校验后解压(980078c)、--allow-anonymous 语义修正(858b4ea),均在 master..develop 的 46 个提交范围内。

结论:coding 侧无需再提交代码,原交办作废;PR #44 可继续审查/合入。

@shl6688
shl6688 merged commit c889978 into master Nov 4, 2026
7 checks passed

This branch was previously deployed

1 inactive deployment
github-pages — f1d97a39 Deployed Nov 4, 2026 by shl6688 via Deploy #150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants