diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-24 14:05:45 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-24 14:05:45 +0200 |
| commit | 01cbb80b300f92c3456d3b2965630c0783607905 (patch) | |
| tree | ad162c4bc4bf5ebafac0d4ba44147437604c82d3 /client | |
| parent | 56f084389a3eb6b34df86af347ce60acdeb6106b (diff) | |
Client + Server + Exports: Implement optional WireGuard support
Diffstat (limited to 'client')
| -rw-r--r-- | client/client.go | 17 | ||||
| -rw-r--r-- | client/server.go | 4 |
2 files changed, 15 insertions, 6 deletions
diff --git a/client/client.go b/client/client.go index 5df2255..541883f 100644 --- a/client/client.go +++ b/client/client.go @@ -57,6 +57,9 @@ type Client struct { // The config Config config.Config `json:"-"` + // Whether or not this client supports WireGuard + SupportsWireguard bool `json:"-"` + // Whether to enable debugging Debug bool `json:"-"` } @@ -99,6 +102,11 @@ func (client *Client) Register( // Initialize the FSM client.FSM = newFSM(stateCallback, directory, debug) + + // By default we support wireguard + client.SupportsWireguard = true + + // Debug only if given client.Debug = debug // Initialize the Config @@ -148,11 +156,11 @@ func (client *Client) Deregister() { // askProfile asks the user for a profile by moving the FSM to the ASK_PROFILE state. func (client *Client) askProfile(chosenServer server.Server) error { - base, baseErr := chosenServer.GetBase() - if baseErr != nil { - return types.NewWrappedError("failed asking for profiles", baseErr) + profiles, profilesErr := server.GetValidProfiles(chosenServer, client.SupportsWireguard) + if profilesErr != nil { + return types.NewWrappedError("failed asking for profiles", profilesErr) } - client.FSM.GoTransitionWithData(STATE_ASK_PROFILE, &base.Profiles, false) + client.FSM.GoTransitionWithData(STATE_ASK_PROFILE, profiles, false) return nil } @@ -209,3 +217,4 @@ type LetsConnectNotSupportedError struct{} func (e LetsConnectNotSupportedError) Error() string { return "Any operation that involves discovery is not allowed with the Let's Connect! client" } + diff --git a/client/server.go b/client/server.go index 9ff895a..2274378 100644 --- a/client/server.go +++ b/client/server.go @@ -22,7 +22,7 @@ func (client *Client) getConfigAuth( } client.FSM.GoTransition(STATE_REQUEST_CONFIG) - validProfile, profileErr := server.HasValidProfile(chosenServer) + validProfile, profileErr := server.HasValidProfile(chosenServer, client.SupportsWireguard) if profileErr != nil { return "", "", profileErr } @@ -36,7 +36,7 @@ func (client *Client) getConfigAuth( } // We return the error otherwise we wrap it too much - return server.GetConfig(chosenServer, preferTCP) + return server.GetConfig(chosenServer, client.SupportsWireguard, preferTCP) } // retryConfigAuth retries the getConfigAuth function if the tokens are invalid. |
