pkg/wireguard: edge case when endpoints are nil

Peers may have nil endpoints, a case which must be gracefully handled.

Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
Lucas Servén Marín 2020-03-06 15:21:30 +01:00
parent 6947eb4154
commit 810dae695e
No known key found for this signature in database
GPG Key ID: 586FEAF680DA74AD
1 changed files with 3 additions and 0 deletions

View File

@ -83,6 +83,9 @@ type Endpoint struct {
// String prints the string representation of the endpoint.
func (e *Endpoint) String() string {
if e == nil {
return ""
}
dnsOrIP := e.DNSOrIP.String()
if e.IP != nil && len(e.IP) == net.IPv6len {
dnsOrIP = "[" + dnsOrIP + "]"