update getwgpeerconfgs

This commit is contained in:
Callan Bryant 2020-10-27 21:42:21 +00:00
parent 047a0dc7be
commit a6bacff44d
No known key found for this signature in database
GPG Key ID: C31FA9DF3ACBFFAA

View File

@ -232,11 +232,15 @@ func (conf DsnetConfig) GetWgPeerConfigs() []wgtypes.PeerConfig {
presharedKey := peer.PresharedKey.Key presharedKey := peer.PresharedKey.Key
// AllowedIPs = private IP + defined networks // AllowedIPs = private IP + defined networks
allowedIPs := make([]net.IPNet, len(peer.Networks)+1) allowedIPs := make([]net.IPNet, len(peer.Networks)+2)
allowedIPs[0] = net.IPNet{ allowedIPs[0] = net.IPNet{
IP: peer.IP, IP: peer.IP,
Mask: net.IPMask{255, 255, 255, 255}, Mask: net.IPMask{255, 255, 255, 255},
} }
allowedIPs[1] = net.IPNet{
IP: peer.IP6,
Mask: net.IPMask{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
}
for i, net := range peer.Networks { for i, net := range peer.Networks {
allowedIPs[i+1] = net.IPNet allowedIPs[i+1] = net.IPNet