Skip to content

Split ipv6 addresses properly. - #66

Merged
timflyio merged 3 commits into
mainfrom
split-hostport
Nov 18, 2026
Merged

timflyio merged 3 commits into
mainfrom
split-hostport

Conversation

@timflyio

Copy link
Copy Markdown
Contributor

Use net.SplitHostPort for splitting hosts and ports, instead of doing string splitting operations directly. This handles IPv6 literals properly, which can contain colons. However, we also need to allow for port defaulting. So detect the cases where SplitHostPort fails because of a missing port, and fill in the default port in these cases. Wrap it up in a tidy API that works like net.SplitHostPort, with some test cases, so that this code could be reused and the code modifications are isolated.

Use net.SplitHostPort for splitting hosts and ports, instead of doing string splitting operations directly. This handles IPv6 literals properly, which can contain colons. However, we also need to allow for port defaulting. So detect the cases where SplitHostPort fails because of a missing port, and fill in the default port in these cases. Wrap it up in a tidy API that works like net.SplitHostPort, with some test cases, so that this code could be reused and the code modifications are isolated.
@timflyio
timflyio marked this pull request as ready for review November 18, 2026 00:16
@timflyio
timflyio requested a review from a team as a code owner November 18, 2026 00:16
@timflyio

Copy link
Copy Markdown
Contributor Author

Based on ideas from #65.

Comment thread tokenizer.go Resolved
Dialfunc is always called with a specified port number, so handling the case where the port is not specified and filled in implicitly is not needed.
@timflyio
timflyio merged commit b6d819b into main Nov 18, 2026
1 check passed
@timflyio
timflyio deleted the split-hostport branch November 18, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants