Skip to content

fix(port): bracket IPv6 hosts in tcp address - #1060

Open
devsy-app[bot] wants to merge 4 commits into
mainfrom
pkg-tunnel-network/ipv6-joinhostport
Open

fix(port): bracket IPv6 hosts in tcp address#1060
devsy-app[bot] wants to merge 4 commits into
mainfrom
pkg-tunnel-network/ipv6-joinhostport

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/port (tunneling/networking category).

Issue found

toAddress built TCP listen addresses with plain string concatenation:

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.

-       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:testpkg/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.

## 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.
@netlify

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 0359c52
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a82a1563a764a0008a02566

@netlify

netlify Bot commented Aug 15, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 0359c52
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a82a156a7468e0009be819a

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@skevetter
skevetter marked this pull request as ready for review August 17, 2026 05:43
Signed-off-by: Samuel K <skevetter@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant