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.
This commit is contained in:
Genteure
2023-01-12 18:40:14 +01:00
committed by Steffen Vogel
parent 6bdf0696be
commit 3fe1ae7c2b
+1 -1
View File
@@ -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