Explorar el Código

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>
Lucas Servén Marín hace 6 años
padre
commit
810dae695e
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      pkg/wireguard/conf.go

+ 3 - 0
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 + "]"