diff --git a/cmd/dsnet.go b/cmd/dsnet.go index 22164e2..0e1291f 100644 --- a/cmd/dsnet.go +++ b/cmd/dsnet.go @@ -1,8 +1,9 @@ package main import ( - "os" "fmt" + "os" + "github.com/naggie/dsnet" ) diff --git a/configtypes.go b/configtypes.go index 6e3edc7..68697f3 100644 --- a/configtypes.go +++ b/configtypes.go @@ -185,6 +185,17 @@ func (conf DsnetConfig) GetWgPeerConfigs() []wgtypes.PeerConfig { // pointer to each peer (d'oh) presharedKey := peer.PresharedKey.Key + // AllowedIPs = private IP + defined networks + allowedIPs := make([]net.IPNet, len(peer.Networks)+1) + allowedIPs[0] = net.IPNet{ + IP: peer.IP, + Mask: net.IPMask{255, 255, 255, 255}, + } + + for i, net := range peer.Networks { + allowedIPs[i+1] = net.IPNet + } + wgPeers = append(wgPeers, wgtypes.PeerConfig{ PublicKey: peer.PublicKey.Key, Remove: false, @@ -192,12 +203,7 @@ func (conf DsnetConfig) GetWgPeerConfigs() []wgtypes.PeerConfig { PresharedKey: &presharedKey, Endpoint: nil, ReplaceAllowedIPs: true, - AllowedIPs: []net.IPNet{ - net.IPNet{ - IP: peer.IP, - Mask: net.IPMask{255, 255, 255, 255}, - }, - }, + AllowedIPs: allowedIPs, }) }