From 565237c14a303a46d62d240b35c6f0082424256a Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Tue, 11 Oct 2022 10:19:56 +0200 Subject: Client: Refactor out adding a Server from getting a config --- cmd/cli/main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 14ab6ea..dbded2d 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -8,6 +8,7 @@ import ( eduvpn "github.com/eduvpn/eduvpn-common" "github.com/eduvpn/eduvpn-common/internal/server" + "github.com/eduvpn/eduvpn-common/types" ) type ServerTypes int8 @@ -97,10 +98,22 @@ func getConfig(state *eduvpn.Client, url string, serverType ServerTypes) (string } // Prefer TCP is set to False if serverType == ServerTypeInstituteAccess { + _, addErr := state.AddInstituteServer(url) + if addErr != nil { + return "", "", addErr + } return state.GetConfigInstituteAccess(url, false) } else if serverType == ServerTypeCustom { + _, addErr := state.AddCustomServer(url) + if addErr != nil { + return "", "", addErr + } return state.GetConfigCustomServer(url, false) } + _, addErr := state.AddSecureInternetHomeServer(url) + if addErr != nil { + return "", "", addErr + } return state.GetConfigSecureInternet(url, false) } @@ -128,8 +141,8 @@ func printConfig(url string, serverType ServerTypes) { if configErr != nil { // Show the usage of tracebacks and causes - fmt.Println("Error getting config:", eduvpn.GetErrorTraceback(configErr)) - fmt.Println("Error getting config, cause:", eduvpn.GetErrorCause(configErr)) + fmt.Println("Error getting config:", types.GetErrorTraceback(configErr)) + fmt.Println("Error getting config, cause:", types.GetErrorCause(configErr)) return } -- cgit v1.2.3