Skip to content

feat(port): accept hostnames in SSH port forwarding#294

Merged
skevetter merged 3 commits into
mainfrom
5bfc-remote-hostname-ports
May 15, 2026
Merged

feat(port): accept hostnames in SSH port forwarding#294
skevetter merged 3 commits into
mainfrom
5bfc-remote-hostname-ports

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Summary

  • Removes the net.ParseIP gate in toAddress() that rejected non-IP hostnames, allowing hostnames like database.internal to pass through for resolution at SSH connection time
  • Updates the splitParts() 3-part disambiguation to use a numeric check (strconv.Atoi) instead of net.ParseIP, so hostname-based container addresses (e.g. 8080:redis:6379) are correctly parsed
  • Adds comprehensive unit tests for ParsePortSpec, toAddress, and splitParts covering hostnames, IPs, localhost, unix sockets, and error cases (29 tests)

Devcontainer spec alignment

The devcontainer spec explicitly supports hostnames in forwardPorts:

An array of port numbers or "host:port" values (e.g. [3000, "db:5432"])

The "db:5432" example confirms hostnames are a first-class format. This PR aligns the CLI's --forward-ports / --reverse-forward-ports parsing (ParsePortSpec) with the spec. The config-based forwardPorts path (parseForwardPort in pkg/tunnel/services.go) already accepted hostnames — this PR closes the gap in the CLI path.

Deviation note: The 2-part "host:port" format from the spec (e.g. "db:5432") is handled by parseForwardPort for config values, not by ParsePortSpec which interprets 2-part specs as hostPort:containerPort. This is unchanged pre-existing behavior — ParsePortSpec serves the CLI's host:hostPort:containerHost:containerPort format, not the devcontainer config format.

The devcontainer spec's forwardPorts property supports host:port format
with hostnames (e.g. "db:5432"), but toAddress rejected anything that
wasn't a literal IP or "localhost". Remove the net.ParseIP gate so
hostnames pass through to be resolved at connection time. Also update
the splitParts 3-part disambiguation to use a numeric check instead of
net.ParseIP, allowing hostname-based container addresses.
@netlify

netlify Bot commented May 14, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit eb87fe3
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a06601e9cdc6a0008757008

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@skevetter has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 1 second before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b6122595-9bc1-4922-91a1-ec46fed6d5db

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4b112 and eb87fe3.

📒 Files selected for processing (3)
  • e2e/tests/up-docker-compose/up_docker_compose.go
  • pkg/port/parse.go
  • pkg/port/parse_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

skevetter added 2 commits May 14, 2026 18:43
…ames

Verify that `--forward-ports <localPort>:nginx:8080` correctly forwards
traffic through a hostname-addressed compose service, exercising the
hostname support added in the previous commit.
Extract repeated string literals into package-level constants to satisfy
the goconst linter for new code introduced in the hostname support commit.
@skevetter
skevetter marked this pull request as ready for review May 14, 2026 23:52
@skevetter
skevetter enabled auto-merge (squash) May 14, 2026 23:53
@skevetter
skevetter merged commit 6832043 into main May 15, 2026
103 of 104 checks passed
@skevetter
skevetter deleted the 5bfc-remote-hostname-ports branch May 15, 2026 01:13
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