summaryrefslogtreecommitdiff
path: root/internal/wireguard
diff options
context:
space:
mode:
authorAleksandar Pesic <peske.nis@gmail.com>2022-12-04 21:48:20 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-12 13:26:51 +0100
commit3ac1d35257b56cca92ad0eb7f4d18abb366cf105 (patch)
tree432db14d1f92a252518f371be420fa0d3ef044c8 /internal/wireguard
parent37bca013bd4405548b274ac473acf959ad661ee6 (diff)
simplify error handling
fixes #6 Signed-off-by: Aleksandar Pesic <peske.nis@gmail.com>
Diffstat (limited to 'internal/wireguard')
-rw-r--r--internal/wireguard/wireguard.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/internal/wireguard/wireguard.go b/internal/wireguard/wireguard.go
index 7da2623..0419ff6 100644
--- a/internal/wireguard/wireguard.go
+++ b/internal/wireguard/wireguard.go
@@ -1,24 +1,21 @@
-// package wireguard implements a few helpers for the WireGuard protocol
+// Package wireguard implements a few helpers for the WireGuard protocol
package wireguard
import (
"fmt"
"regexp"
- "github.com/eduvpn/eduvpn-common/types"
+ "github.com/go-errors/errors"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
)
// GenerateKey generates a WireGuard private key using wgctrl
// It returns an error if key generation failed.
func GenerateKey() (wgtypes.Key, error) {
- key, keyErr := wgtypes.GeneratePrivateKey()
+ key, err := wgtypes.GeneratePrivateKey()
- if keyErr != nil {
- return key, types.NewWrappedError(
- "failed generating WireGuard key",
- keyErr,
- )
+ if err != nil {
+ return key, errors.WrapPrefix(err, "failed generating WireGuard key", 0)
}
return key, nil
}