Skip to content

Commit b71b4d5

Browse files
fix net.Dial issue with ipv6
1 parent 800ff07 commit b71b4d5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cmd/client/ping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type PingResult struct {
2323
}
2424

2525
func Ping(host string, port int) (*PingResult, error) {
26-
conn, err := net.Dial("udp", fmt.Sprintf("%s:%d", host, port))
26+
conn, err := net.Dial("udp", net.JoinHostPort(host, fmt.Sprintf("%d", port)))
2727
if err != nil {
2828
return nil, err
2929
}

commandclient/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewCommandClient(host string, port int) *CommandClient {
3232
}
3333

3434
func (c *CommandClient) Connect() error {
35-
conn, err := net.Dial("udp", fmt.Sprintf("%s:%d", c.Host, c.Port))
35+
conn, err := net.Dial("udp", net.JoinHostPort(c.Host, fmt.Sprintf("%d", c.Port)))
3636
if err != nil {
3737
return err
3838
}

0 commit comments

Comments
 (0)