summaryrefslogtreecommitdiff
path: root/internal/wireguard.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-03 14:10:40 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-05-03 14:10:40 +0200
commit43604f7ffcbbf5b06ae481d2af7e66f6423f183f (patch)
tree6eb74ed54929edcfac61e5ca55078ab6670e0081 /internal/wireguard.go
parent466450f0c47bdc614e66326d90e5fc6fb56ae732 (diff)
Refactor: Secure internet into a different type but with interface
Diffstat (limited to 'internal/wireguard.go')
-rw-r--r--internal/wireguard.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/wireguard.go b/internal/wireguard.go
index 7977dbc..318e0dc 100644
--- a/internal/wireguard.go
+++ b/internal/wireguard.go
@@ -30,8 +30,14 @@ func wireguardConfigAddKey(config string, key wgtypes.Key) string {
return interface_re.ReplaceAllString(config, to_replace)
}
-func (server *Server) WireguardGetConfig() (string, error) {
- profile_id := server.Profiles.Current
+func WireguardGetConfig(server Server) (string, error) {
+ base, baseErr := server.GetBase()
+
+ if baseErr != nil {
+ return "", &WireguardGetConfigError{Err: baseErr}
+ }
+
+ profile_id := base.Profiles.Current
wireguardKey, wireguardErr := wireguardGenerateKey()
if wireguardErr != nil {
@@ -39,7 +45,7 @@ func (server *Server) WireguardGetConfig() (string, error) {
}
wireguardPublicKey := wireguardKey.PublicKey().String()
- configWireguard, _, configErr := server.APIConnectWireguard(profile_id, wireguardPublicKey)
+ configWireguard, _, configErr := APIConnectWireguard(server, profile_id, wireguardPublicKey)
if configErr != nil {
return "", &WireguardGetConfigError{Err: wireguardErr}