From 23f4bc66fcd089ef8f2c3ee3a1554f7da0f2456d Mon Sep 17 00:00:00 2001 From: duyle Date: Fri, 25 Jun 2021 09:58:20 +0700 Subject: [PATCH] Try to fix lost allowip on new peer --- wgapi/mywgserver/server.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/wgapi/mywgserver/server.go b/wgapi/mywgserver/server.go index b4a985a..30c432a 100644 --- a/wgapi/mywgserver/server.go +++ b/wgapi/mywgserver/server.go @@ -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), }}, }}, }) @@ -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()