bugfix: Free net.IP from pool on DeletePeer
This commit is contained in:
parent
11340e4d7a
commit
6c032e1d97
23
link.go
23
link.go
@ -142,7 +142,28 @@ func (wg *WGLink) DeletePeer(publickey string) error {
|
|||||||
|
|
||||||
func (wg *WGLink) deletePeer(publickey wgtypes.Key) error {
|
func (wg *WGLink) deletePeer(publickey wgtypes.Key) error {
|
||||||
rmCfg := createARemovePeerCfg(publickey)
|
rmCfg := createARemovePeerCfg(publickey)
|
||||||
return wg.ApplyConfig(rmCfg)
|
ip, err := wg.getPeerIP(publickey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = wg.ApplyConfig(rmCfg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = wg.Free(ip)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wg *WGLink) getPeerIP(publickey wgtypes.Key) (net.IP, error) {
|
||||||
|
peer, err := wg.getPeer(publickey)
|
||||||
|
if err != nil { return nil, err }
|
||||||
|
return peer.AllowedIPs[0].IP, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wg *WGLink) Exists(publicKey string) (bool, error) {
|
func (wg *WGLink) Exists(publicKey string) (bool, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user