2
0
Эх сурвалжийг харах

add extclient extraAlllowedIPs to peer updates

Matthew R Kasun 2 жил өмнө
parent
commit
afc4060383
1 өөрчлөгдсөн 10 нэмэгдсэн , 0 устгасан
  1. 10 0
      logic/peers.go

+ 10 - 0
logic/peers.go

@@ -13,6 +13,7 @@ import (
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/servercfg"
 	"golang.org/x/exp/slices"
+	"golang.org/x/exp/slog"
 	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
 )
 
@@ -910,6 +911,15 @@ func getIngressIPs(peer *models.Client) []net.IPNet {
 				cidr.IP = ip
 				ingressIPs = append(ingressIPs, *cidr)
 			}
+			for _, extra := range ec.ExtraAllowedIPs {
+				ip, cidr, err := net.ParseCIDR(extra)
+				if err != nil {
+					slog.Warn("invalid extra allowed ip", "extraIP", extra, "for ext client", ec.ClientID)
+					continue
+				}
+				cidr.IP = ip
+				ingressIPs = append(ingressIPs, *cidr)
+			}
 		}
 	}
 	return ingressIPs