Skip to content

Commit

Permalink
Try to fix lost allowip on new peer
Browse files Browse the repository at this point in the history
  • Loading branch information
duyleekun committed Jun 25, 2021
1 parent 1ec5cea commit 23f4bc6
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions wgapi/mywgserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,10 @@ func (s *WGServer) AddClientPeer(subdomain string) []byte {
Peers: []wgtypes.PeerConfig{
{
PublicKey: peerKey.PublicKey(),
Remove: false,
UpdateOnly: false,
ReplaceAllowedIPs: true,
PersistentKeepaliveInterval: &s.duration,
AllowedIPs: []net.IPNet{{
IP: clientIP,
Mask: s.ipPool.CurrentIPMask(),
Mask: net.CIDRMask(32, 32),
}},
}},
})
Expand All @@ -186,26 +183,22 @@ func (s *WGServer) AddClientPeer(subdomain string) []byte {
wgQuickConfig := util.WgQuickConfig{

Config: wgtypes.Config{
PrivateKey: &peerKey,
ListenPort: nil,
ReplacePeers: true,
PrivateKey: &peerKey,
Peers: []wgtypes.PeerConfig{
{
PublicKey: d.PublicKey,
Remove: false,
UpdateOnly: false,
PresharedKey: nil,
Endpoint: s.endpoint,
PersistentKeepaliveInterval: &s.duration,
ReplaceAllowedIPs: true,
AllowedIPs: []net.IPNet{{
IP: serverIP,
Mask: s.ipPool.CurrentIPMask(),
}},
},
}},
Address: []net.IPNet{{IP: clientIP,
Mask: net.CIDRMask(32, 32)}},
Address: []net.IPNet{{
IP: clientIP,
Mask: s.ipPool.CurrentIPMask(),
}},
}

configs, err := wgQuickConfig.MarshalText()
Expand Down

0 comments on commit 23f4bc6

Please sign in to comment.