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
3 changes: 2 additions & 1 deletion pkg/port/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package port

import (
"fmt"
"net"
"strconv"
"strings"
)
Expand Down Expand Up @@ -36,7 +37,7 @@ func toAddress(host, port string) (Address, error) {

return Address{
Protocol: "tcp",
Address: host + ":" + port,
Address: net.JoinHostPort(host, port),
}, nil
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/port/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading