From eb8b5975739fba0b9065f974275ff7f0b51ef3c2 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 13 Dec 2022 20:25:00 +0100 Subject: [PATCH] Skip PresharedKey generation Helpful for those who already have users deployed. Enter `-` in the Preshared Key field at user creation time to skip its creation. The template conf takes care of the rest. Fixes issue #235 --- handler/routes.go | 3 +++ templates/base.html | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/handler/routes.go b/handler/routes.go index ea34b8a..9439977 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -231,6 +231,9 @@ func NewClient(db store.IStore) echo.HandlerFunc { }) } client.PresharedKey = presharedKey.String() + } else if client.PresharedKey == "-" { + client.PresharedKey = "" + log.Infof("skipped PresharedKey generation for user: %v", client.Name) } else { _, err := wgtypes.ParseKey(client.PresharedKey) if err != nil { diff --git a/templates/base.html b/templates/base.html index d92e107..03d91bf 100644 --- a/templates/base.html +++ b/templates/base.html @@ -206,7 +206,7 @@ Public and Preshared Keys @@ -220,7 +220,7 @@ - +