Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/tailcat/socks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ func TestNormalizeListenAddrPort(t *testing.T) {
input: "[2001:db8::1]",
want: "[2001:db8::1]:0",
},
{
name: "omit port with unbracketed IPv6 address",
input: "::1",
want: "[::1]:0",
},
{
name: "omit port with unbracketed IPv6 unspecified address",
input: "::",
want: "[::]:0",
},
{
name: "others",
input: "foo",
Expand Down
6 changes: 5 additions & 1 deletion cmd/tailcat/tailcat.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,8 +999,12 @@ func normalizeListenAddrPort(s string) string {
return net.JoinHostPort(host, port)
} else if port, err := strconv.ParseUint(s, 10, 16); err == nil {
return net.JoinHostPort("127.0.0.1", strconv.Itoa(int(port)))
} else if _, err := netip.ParseAddr(s); err == nil {
// A bare IP address. JoinHostPort brackets an IPv6 address
// such as "::1", which appending ":0" would leave ambiguous.
return net.JoinHostPort(s, "0")
}
// Assume it's a hostname or IP without a port.
// Assume it's a hostname without a port.
return s + ":0"
}

Expand Down