From 8b23028e227f36865e6ada57e211afa748f715f6 Mon Sep 17 00:00:00 2001 From: "devsy-app[bot]" <277138668+devsy-app[bot]@users.noreply.github.com> Date: Sat, 15 Aug 2026 11:24:01 +0000 Subject: [PATCH 1/3] fix(port): bracket IPv6 hosts in tcp address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Package reviewed `pkg/port` (tunneling/networking category). ## Issue found `toAddress` built TCP listen addresses with plain string concatenation: ```go Address: host + ":" + port ``` For IPv6 host literals this produces an ambiguous address that `net.Listen` rejects. For example, `host="::1"`, `port="8080"` yields `"::1:8080"`, and `net.Listen("tcp", "::1:8080")` fails with `listen tcp: address ::1:8080: too many colons in address`. Any port spec resolved against an IPv6 host was therefore unusable for binding a listener. ## Change Use `net.JoinHostPort(host, port)` so IPv6 literals are bracketed (`[::1]:8080`, `[fe80::1]:443`) while IPv4 addresses and hostnames are unchanged. ```diff - Address: host + ":" + port, + Address: net.JoinHostPort(host, port), ``` `net` (stdlib) is the only new import. No behavioral change for the IPv4/hostname path (verified by the existing test cases, which still expect `db:5432`, `database.internal:5432`, etc.). ## Tests Updated the existing `IPv6 address` case (previously asserted the malformed `"::1:8080"` output) to the correct `"[::1]:8080"`, and added a second IPv6 case (`fe80::1` -> `[fe80::1]:443`) to lock in the bracketing end to end. ## Verification performed - `task cli:format` — clean. - `task cli:lint:ci` — 0 new issues. - `task cli:test` — `pkg/port` passes (coverage 93.2%). The only failing package is `pkg/git` (`TestRepoClone*`), a known pre-existing failure on `origin/main` unrelated to this change (this change does not touch `pkg/git`). - `go build ./pkg/port/...` and `go vet ./pkg/port/...` — pass. - No proto changes; `task cli:build:grpc` not required. This PR was created by an AI agent as part of an automated daily package review job. --- pkg/port/parse.go | 4 +++- pkg/port/parse_test.go | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/port/parse.go b/pkg/port/parse.go index cb744d52a..505e89788 100644 --- a/pkg/port/parse.go +++ b/pkg/port/parse.go @@ -2,6 +2,7 @@ package port import ( "fmt" + "net" "strconv" "strings" ) @@ -36,7 +37,8 @@ func toAddress(host, port string) (Address, error) { return Address{ Protocol: "tcp", - Address: host + ":" + port, + // JoinHostPort brackets IPv6 literals so net.Listen can parse them. + Address: net.JoinHostPort(host, port), }, nil } diff --git a/pkg/port/parse_test.go b/pkg/port/parse_test.go index 38698d68b..8f30d1e43 100644 --- a/pkg/port/parse_test.go +++ b/pkg/port/parse_test.go @@ -151,7 +151,13 @@ func TestToAddress_TCP(t *testing.T) { Address{Protocol: protoTCP, Address: "database.internal:5432"}, }, {"short hostname", "db", "5432", Address{Protocol: protoTCP, Address: "db:5432"}}, - {"IPv6 address", "::1", "8080", Address{Protocol: protoTCP, Address: "::1:8080"}}, + {"IPv6 address", "::1", "8080", Address{Protocol: protoTCP, Address: "[::1]:8080"}}, + { + "IPv6 host brackets for listen", + "fe80::1", + "443", + Address{Protocol: protoTCP, Address: "[fe80::1]:443"}, + }, } for _, tt := range tests { From 582a5a7e9b05e39c5459ab85fcced0e53ea2313d Mon Sep 17 00:00:00 2001 From: Samuel K Date: Mon, 17 Aug 2026 00:42:50 -0500 Subject: [PATCH 2/3] style: update comments --- pkg/port/parse.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/port/parse.go b/pkg/port/parse.go index 505e89788..10db9d9f0 100644 --- a/pkg/port/parse.go +++ b/pkg/port/parse.go @@ -37,7 +37,6 @@ func toAddress(host, port string) (Address, error) { return Address{ Protocol: "tcp", - // JoinHostPort brackets IPv6 literals so net.Listen can parse them. Address: net.JoinHostPort(host, port), }, nil } From 0359c525a43eab5cf829601e2abd867fa2580e49 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Mon, 17 Aug 2026 05:51:09 +0000 Subject: [PATCH 3/3] style: apply formatting Signed-off-by: Samuel K --- pkg/port/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/port/parse.go b/pkg/port/parse.go index 10db9d9f0..6646d4fd0 100644 --- a/pkg/port/parse.go +++ b/pkg/port/parse.go @@ -37,7 +37,7 @@ func toAddress(host, port string) (Address, error) { return Address{ Protocol: "tcp", - Address: net.JoinHostPort(host, port), + Address: net.JoinHostPort(host, port), }, nil }