From 810dae695e18cc2ed77518406bf130ca1514e480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Fri, 6 Mar 2020 15:21:30 +0100 Subject: [PATCH] pkg/wireguard: edge case when endpoints are nil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Peers may have nil endpoints, a case which must be gracefully handled. Signed-off-by: Lucas Servén Marín --- pkg/wireguard/conf.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/wireguard/conf.go b/pkg/wireguard/conf.go index 04e2ddd..0733751 100644 --- a/pkg/wireguard/conf.go +++ b/pkg/wireguard/conf.go @@ -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 + "]"