Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Adding support for PersistentKeepalive in user configs (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
suom1 authored Jul 22, 2020
1 parent 709fb14 commit 8839df6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
wgEndpoint = kingpin.Flag("wg-endpoint", "WireGuard endpoint address").Default("127.0.0.1:51820").String()
wgAllowedIPs = kingpin.Flag("wg-allowed-ips", "WireGuard client allowed ips").Default("0.0.0.0/0").Strings()
wgDNS = kingpin.Flag("wg-dns", "WireGuard client DNS server (optional)").Default("").String()
wgKeepAlive = kingpin.Flag("wg-keepalive", "WireGuard Keepalive for peers, defined in seconds (optional)").Default("").String()

devUIServer = kingpin.Flag("dev-ui-server", "Developer mode: If specified, proxy all static assets to this endpoint").String()

Expand Down Expand Up @@ -463,15 +464,22 @@ func (s *Server) GetClient(w http.ResponseWriter, r *http.Request, ps httprouter
dns = fmt.Sprint("DNS = ", *wgDNS)
}

keepAlive := ""
if *wgKeepAlive != "" {
keepAlive = fmt.Sprint("PersistentKeepalive = ", *wgKeepAlive)
}

configData := fmt.Sprintf(`[Interface]
%s
Address = %s
PrivateKey = %s
%s
[Peer]
PublicKey = %s
AllowedIPs = %s
Endpoint = %s
`, dns, client.IP.String(), client.PrivateKey, s.Config.PublicKey, allowedIPs, *wgEndpoint)
%s
`, client.IP.String(), client.PrivateKey, dns, s.Config.PublicKey, allowedIPs, *wgEndpoint, keepAlive)

format := r.URL.Query().Get("format")

Expand Down

0 comments on commit 8839df6

Please sign in to comment.