diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-10 11:53:08 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-10 11:53:08 +0200 |
| commit | 9e3e7f22892c3504e6de9827af0fabd9b4b098ea (patch) | |
| tree | 0d16b63dae17f73bccfe720d9c03c25166856497 /internal/wireguard.go | |
| parent | 113de64ac73f529af14da3e0aff12b05c2edd3a7 (diff) | |
API/Server: Correctly handle multiple protocol preference
Diffstat (limited to 'internal/wireguard.go')
| -rw-r--r-- | internal/wireguard.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/internal/wireguard.go b/internal/wireguard.go index 318e0dc..7f8da38 100644 --- a/internal/wireguard.go +++ b/internal/wireguard.go @@ -30,7 +30,7 @@ func wireguardConfigAddKey(config string, key wgtypes.Key) string { return interface_re.ReplaceAllString(config, to_replace) } -func WireguardGetConfig(server Server) (string, error) { +func WireguardGetConfig(server Server, supportsOpenVPN bool) (string, error) { base, baseErr := server.GetBase() if baseErr != nil { @@ -45,20 +45,22 @@ func WireguardGetConfig(server Server) (string, error) { } wireguardPublicKey := wireguardKey.PublicKey().String() - configWireguard, _, configErr := APIConnectWireguard(server, profile_id, wireguardPublicKey) + config, content, _, configErr := APIConnectWireguard(server, profile_id, wireguardPublicKey, supportsOpenVPN) if configErr != nil { return "", &WireguardGetConfigError{Err: wireguardErr} } - // FIXME: Store expiry - // This needs the go code a way to identify a connection - // Use the uuid of the connection e.g. on Linux - // This needs the client code to call the go code + if content == "wireguard" { + // FIXME: Store expiry + // This needs the go code a way to identify a connection + // Use the uuid of the connection e.g. on Linux + // This needs the client code to call the go code - configWireguardKey := wireguardConfigAddKey(configWireguard, wireguardKey) + config = wireguardConfigAddKey(config, wireguardKey) + } - return configWireguardKey, nil + return config, nil } type WireguardGenerateKeyError struct { |
