Skip to content

Commit

Permalink
Fix deleting users
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Oct 17, 2024
1 parent 539e9b2 commit 09c3408
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions internal/router/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,8 @@ func (f *Firewall) RemoveUser(username string) error {
delete(f.userPolicies, username)

for _, d := range f.userToDevices[username] {
delete(f.addressToPolicies, d.address)
delete(f.addressToDevice, d.address)
delete(f.deviceToUser, d.address)

f._removePeer(d.public.String(), d.address.String())
}
delete(f.userToDevices, username)

Expand Down
4 changes: 3 additions & 1 deletion internal/router/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ func (f *Firewall) _removePeer(publickey, address string) error {

deviceToRemove, ok := f.addressToDevice[addressNetAddr]
if !ok {
return fmt.Errorf("device with address %q not found", address)
// If the device has already been removed, ignore this
// Happens if we delete a user, then etcd registers the device key has been deleted
return nil
}

delete(f.addressToPolicies, deviceToRemove.address)
Expand Down

0 comments on commit 09c3408

Please sign in to comment.