diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/discovery/discovery.go | 11 | ||||
| -rw-r--r-- | internal/fsm/fsm.go | 8 |
2 files changed, 16 insertions, 3 deletions
diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index 2331491..b4163a8 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -73,14 +73,21 @@ func (discovery *Discovery) DetermineOrganizationsUpdate() bool { return discovery.Organizations.Timestamp == 0 } -func (discovery *Discovery) GetSecureLocationList() []string { +func (discovery *Discovery) GetSecureLocationList() (string, error) { var locations []string for _, server := range discovery.Servers.List { if server.Type == "secure_internet" { locations = append(locations, server.CountryCode) } } - return locations + + jsonBytes, jsonErr := json.Marshal(locations) + + if jsonErr != nil { + return "", &types.WrappedErrorMessage{Message: "failed getting Secure Internet locations list", Err: jsonErr} + } + + return string(jsonBytes), nil } func (discovery *Discovery) GetServerByURL(url string, _type string) (*types.DiscoveryServer, error) { diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go index 2042977..1ba8133 100644 --- a/internal/fsm/fsm.go +++ b/internal/fsm/fsm.go @@ -36,6 +36,9 @@ const ( // No Server means the user has not chosen a server yet NO_SERVER + // The user selected a Secure Internet server but needs to choose a location + ASK_LOCATION + // The user is currently selecting a server in the UI SEARCH_SERVER @@ -67,6 +70,8 @@ func (s FSMStateID) String() string { return "Deregistered" case NO_SERVER: return "No_Server" + case ASK_LOCATION: + return "Ask_Location" case SEARCH_SERVER: return "Search_Server" case CHOSEN_SERVER: @@ -113,7 +118,8 @@ type FSM struct { func (fsm *FSM) Init(name string, callback func(string, string, string), logger *log.FileLogger, directory string, debug bool) { fsm.States = FSMStates{ DEREGISTERED: {{NO_SERVER, "Client registers"}}, - NO_SERVER: {{CHOSEN_SERVER, "User chooses a server"}, {SEARCH_SERVER, "The user is trying to choose a Server in the UI"}}, + NO_SERVER: {{CHOSEN_SERVER, "User chooses a server"}, {SEARCH_SERVER, "The user is trying to choose a Server in the UI"}, {ASK_LOCATION, "User chooses a Secure Internet server but no location is configured"}}, + ASK_LOCATION: {{CHOSEN_SERVER, "Location chosen"}, {NO_SERVER, "Cancel or Error"}}, SEARCH_SERVER: {{CHOSEN_SERVER, "User clicks a server in the UI"}, {NO_SERVER, "Cancel or Error"}}, CHOSEN_SERVER: {{AUTHORIZED, "Found tokens in config"}, {OAUTH_STARTED, "No tokens found in config"}}, OAUTH_STARTED: {{AUTHORIZED, "User authorizes with browser"}, {NO_SERVER, "Cancel or Error"}}, |
