Skip to content

Commit

Permalink
Merge pull request #28 from devilcove/feature/virt-subnet
Browse files Browse the repository at this point in the history
bugfixes when adding/deleting peers
  • Loading branch information
mattkasun committed Apr 22, 2024
2 parents 209bef7 + 8be36fa commit 6231693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions internal/agent/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log/slog"
"net"
"slices"
"strconv"
"time"

"github.com/devilcove/boltdb"
Expand Down Expand Up @@ -372,8 +373,13 @@ func convertPeerToWG(netPeer plexus.NetworkPeer, peers []plexus.NetworkPeer) (wg
if err != nil {
return wgtypes.PeerConfig{}, err
}
addr, err := net.ResolveUDPAddr("udp", netPeer.Endpoint.String()+":"+strconv.Itoa(netPeer.PublicListenPort))
if err != nil {
return wgtypes.PeerConfig{}, err
}
return wgtypes.PeerConfig{
PublicKey: key,
Endpoint: addr,
PersistentKeepaliveInterval: &keepalive,
ReplaceAllowedIPs: true,
AllowedIPs: getAllowedIPs(netPeer, peers),
Expand Down
4 changes: 2 additions & 2 deletions wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ func (wg *wireguard) ReplacePeer(newPeer wgtypes.PeerConfig) {
}

func (wg *wireguard) DeletePeer(key string) {
for _, peer := range wg.Config.Peers {
for i, peer := range wg.Config.Peers {
if peer.PublicKey.String() == key {
peer.Remove = true
wg.Config.Peers[i].Remove = true
break
}
}
Expand Down

0 comments on commit 6231693

Please sign in to comment.