diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-03-20 13:48:47 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | 40705474e1998bf4a59b82c96d343e13247a9926 (patch) | |
| tree | b5c69aaab75ad485a2c82e452d98113b78a05b41 /client | |
| parent | de403deed73340f8068739dc240ebebfa1053872 (diff) | |
Types: Split protocol into its own
Diffstat (limited to 'client')
| -rw-r--r-- | client/client.go | 8 | ||||
| -rw-r--r-- | client/server.go | 12 |
2 files changed, 7 insertions, 13 deletions
diff --git a/client/client.go b/client/client.go index 0cc6b3e..49c8bc1 100644 --- a/client/client.go +++ b/client/client.go @@ -15,6 +15,7 @@ import ( "github.com/eduvpn/eduvpn-common/internal/oauth" "github.com/eduvpn/eduvpn-common/internal/server" "github.com/eduvpn/eduvpn-common/types" + "github.com/eduvpn/eduvpn-common/types/protocol" "github.com/go-errors/errors" ) @@ -309,9 +310,10 @@ func (c *Client) ExpiryTimes() (*types.Expiry, error) { func convertProfiles(profiles server.ProfileInfo) types.Profiles { m := make(map[string]types.Profile) for _, p := range profiles.Info.ProfileList { - var protocols []types.Protocol - for _, protocol := range p.VPNProtoList { - protocols = append(protocols, getProtocol(protocol)) + var protocols []protocol.Protocol + // loop through all protocol strings + for _, ps := range p.VPNProtoList { + protocols = append(protocols, protocol.New(ps)) } m[p.ID] = types.Profile{ DisplayName: map[string]string{ diff --git a/client/server.go b/client/server.go index 6e399c9..74f441a 100644 --- a/client/server.go +++ b/client/server.go @@ -9,18 +9,10 @@ import ( "github.com/eduvpn/eduvpn-common/internal/oauth" "github.com/eduvpn/eduvpn-common/internal/server" "github.com/eduvpn/eduvpn-common/types" + "github.com/eduvpn/eduvpn-common/types/protocol" "github.com/go-errors/errors" ) -func getProtocol(protocol string) types.Protocol { - if protocol == "openvpn" { - return types.PROTOCOL_OPENVPN - } else if protocol == "wireguard" { - return types.PROTOCOL_WIREGUARD - } - return types.PROTOCOL_UNKNOWN -} - // TODO: This should not be reliant on an internal type func getTokens(tok oauth.Token) types.Tokens { return types.Tokens{ @@ -68,7 +60,7 @@ func (c *Client) getConfigAuth(srv server.Server, preferTCP bool, t types.Tokens pCfg := &types.Configuration{ VPNConfig: cfg.Config, - Protocol: getProtocol(cfg.Type), + Protocol: protocol.New(cfg.Type), DefaultGateway: p.DefaultGateway, Tokens: getTokens(cfg.Tokens), } |
