Browse Source

check for nil peer endpoint

Matthew R. Kasun 3 years ago
parent
commit
435258a4de
1 changed files with 6 additions and 0 deletions
  1. 6 0
      netclient/local/routes.go

+ 6 - 0
netclient/local/routes.go

@@ -34,6 +34,9 @@ func SetPeerRoutes(iface string, oldPeers map[string]bool, newPeers []wgtypes.Pe
 				delete(oldPeers, allowedIP.String())
 			}
 		}
+		if peer.Endpoint == nil {
+			continue
+		}
 		if hasRoute && !ncutils.IpIsPrivate(peer.Endpoint.IP) {
 			ipNet, err := ncutils.GetIPNetFromString(peer.Endpoint.IP.String())
 			if err != nil {
@@ -71,6 +74,9 @@ func SetCurrentPeerRoutes(iface, currentAddr string, peers []wgtypes.PeerConfig)
 		for _, allowedIP := range peer.AllowedIPs {
 			setRoute(iface, &allowedIP, currentAddr)
 		}
+		if peer.Endpoint == nil {
+			continue
+		}
 		if hasRoute && !ncutils.IpIsPrivate(peer.Endpoint.IP) {
 			ipNet, err := ncutils.GetIPNetFromString(peer.Endpoint.IP.String())
 			if err != nil {