From 3fe1ae7c2be05197aaaa843e1ccecc9eaa129c8a Mon Sep 17 00:00:00 2001 From: Genteure Date: Tue, 10 Jan 2023 11:41:49 +0000 Subject: [PATCH] Fix IPv6 formatting in Candidate.String() A Candidate with IPv6 address was formatted similar to fe80::1:51820 net.JoinHostPort will add [ ] around the address if it's IPv6, so it would look like [fe80::1]:51820 instead. --- candidate_base.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/candidate_base.go b/candidate_base.go index 4761d5a..289a0f4 100644 --- a/candidate_base.go +++ b/candidate_base.go @@ -344,7 +344,7 @@ func (c *candidateBase) Equal(other Candidate) bool { // String makes the candidateBase printable func (c *candidateBase) String() string { - return fmt.Sprintf("%s %s %s:%d%s", c.NetworkType(), c.Type(), c.Address(), c.Port(), c.relatedAddress) + return fmt.Sprintf("%s %s %s%s", c.NetworkType(), c.Type(), net.JoinHostPort(c.Address(), strconv.Itoa(c.Port())), c.relatedAddress) } // LastReceived returns a time.Time indicating the last time