support peer networks in allowedIPs
This commit is contained in:
parent
050749fbb6
commit
ea5ffaa4e2
@ -1,8 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/naggie/dsnet"
|
"github.com/naggie/dsnet"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -185,6 +185,17 @@ func (conf DsnetConfig) GetWgPeerConfigs() []wgtypes.PeerConfig {
|
|||||||
// pointer to each peer (d'oh)
|
// pointer to each peer (d'oh)
|
||||||
presharedKey := peer.PresharedKey.Key
|
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{
|
wgPeers = append(wgPeers, wgtypes.PeerConfig{
|
||||||
PublicKey: peer.PublicKey.Key,
|
PublicKey: peer.PublicKey.Key,
|
||||||
Remove: false,
|
Remove: false,
|
||||||
@ -192,12 +203,7 @@ func (conf DsnetConfig) GetWgPeerConfigs() []wgtypes.PeerConfig {
|
|||||||
PresharedKey: &presharedKey,
|
PresharedKey: &presharedKey,
|
||||||
Endpoint: nil,
|
Endpoint: nil,
|
||||||
ReplaceAllowedIPs: true,
|
ReplaceAllowedIPs: true,
|
||||||
AllowedIPs: []net.IPNet{
|
AllowedIPs: allowedIPs,
|
||||||
net.IPNet{
|
|
||||||
IP: peer.IP,
|
|
||||||
Mask: net.IPMask{255, 255, 255, 255},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user