btlqql opened a new pull request, #7135: URL: https://github.com/apache/rocketmq-dashboard/pull/7135
## What is the purpose of the change rmqctl permits plain HTTP for loopback, private-network and link-local literal addresses, but a correctly escaped scoped IPv6 endpoint such as `http://[fe80::1%25eth0]:6789` was rejected with "studio server must use HTTPS". `url.Parse` reports that host as `fe80::1%eth0`, zone included, and `isPrivateHost` (`rmqctl/internal/studio/auth.go`) classified it with `net.ParseIP`, which fails on the `%eth0` suffix. Every scoped loopback, link-local or ULA endpoint therefore looked like a public host and the request was refused before dispatch. The host is now parsed with `net/netip`, which keeps the zone and judges the address by its actual bits; the zone stays untouched in the outgoing URL, and public hosts (with or without a zone) and malformed literals are still rejected. ## Brief changelog - `rmqctl/internal/studio/auth.go`: classify hosts with `net/netip` scoped-address parsing (`parseHostAddress`) instead of `net.ParseIP`; IPv4-mapped IPv6 literals are unmapped so they stay classified like their IPv4 form, and the `isLoopbackHost`/`isPrivateHost` policy is otherwise unchanged. - `rmqctl/internal/studio/client_test.go`: table-driven `TestValidateServerSchemeScopedIPv6` (named and numeric link-local zones, scoped loopback, scoped private ULA, HTTPS with a zone, public IPv6 with/without a zone rejected, empty zone / malformed / unbracketed literals rejected) and `TestRequestPreservesScopedIPv6Zone` (`Client.request` with a recording transport: the zone survives in the request URL as `%25eth0`). ## Verifying this change - red: `cd rmqctl && go test ./internal/studio/ -run 'TestValidateServerSchemeScopedIPv6|TestRequestPreservesScopedIPv6Zone' -v` -> `client_test.go:153: validate("http://[fe80::1%25eth0]:6789") = studio server must use HTTPS (HTTP is allowed only for loopback or private-network addresses), want nil` and `client_test.go:190: request to scoped link-local endpoint returned error: studio server must use HTTPS ...`; `FAIL github.com/apache/rocketmq-dashboard/rmqctl/internal/studio 0.076s` (log: `net6zone-red.log`) - green: the same targeted command -> all 11 subtests `--- PASS`, `PASS`, `ok github.com/apache/rocketmq-dashboard/rmqctl/internal/studio 0.077s`; `go test ./internal/...` -> `ok` for catalog, catalog/generate, config, output and studio, `[no test files]` for types, no failures (Go prints an `ok`/`FAIL` line per package instead of a `Tests run: N, Failures: 0` summary) (logs: `net6zone-green-targeted.log`, `net6zone-green.log`) - regressions run: `go test ./internal/...` (whole rmqctl module) all packages ok; `go build ./...` and `go vet ./internal/studio/` clean. ## Checklist - [x] one issue, one PR: Fixes #7131 - [x] regression test added - [x] targeted suites re-run Not verified here: no live IPv6 interface, Studio server or broker was involved (the regression uses `Target.validate` and a recording `RoundTripper` only), and `go test ./...` was run for `./internal/...` rather than the `cmd/` packages. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
