Skip to content

Commit

Permalink
remove persistent keepalive from server side closes #64
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Sep 14, 2023
1 parent 91261c4 commit 76b29c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
1 change: 0 additions & 1 deletion commands/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func (g *genconfig) Run() error {
c.Wireguard.PrivateKey = k.String()
c.Wireguard.ListenPort = 5920
c.Wireguard.MTU = 1420
c.Wireguard.PersistentKeepAlive = 25

c.Acls.Groups = make(map[string][]string)
c.Acls.Policies = make(map[string]*config.Acl)
Expand Down
15 changes: 5 additions & 10 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,11 @@ type Config struct {
Webauthn *webauthn.WebAuthn `json:"-"`
}
Wireguard struct {
DevName string
ListenPort int
PrivateKey string
Address string
MTU int
PersistentKeepAlive int
DevName string
ListenPort int
PrivateKey string
Address string
MTU int

//Not externally configurable
External bool `json:"-"`
Expand Down Expand Up @@ -492,10 +491,6 @@ func load(path string) (c Config, err error) {
if c.Wireguard.MTU == 0 {
c.Wireguard.MTU = 1420
}

if c.Wireguard.PersistentKeepAlive == 0 {
c.Wireguard.PersistentKeepAlive = 25
}
}

if len(c.Acls.Policies) == 0 {
Expand Down
14 changes: 5 additions & 9 deletions internal/router/wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"net"
"sort"
"time"
"unsafe"

"github.com/NHAS/wag/internal/config"
Expand Down Expand Up @@ -97,17 +96,14 @@ func setupWireguard() error {
psk = &testKey
}

keepalive := time.Duration(time.Duration(config.Values().Wireguard.PersistentKeepAlive)) * time.Second

_, network, _ := net.ParseCIDR(device.Address + "/32")

c.Peers = append(c.Peers, wgtypes.PeerConfig{
PublicKey: pk,
PersistentKeepaliveInterval: &keepalive,
ReplaceAllowedIPs: true,
AllowedIPs: []net.IPNet{*network},
Endpoint: device.Endpoint,
PresharedKey: psk,
PublicKey: pk,
ReplaceAllowedIPs: true,
AllowedIPs: []net.IPNet{*network},
Endpoint: device.Endpoint,
PresharedKey: psk,
})
}

Expand Down

0 comments on commit 76b29c9

Please sign in to comment.