summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exports/exports.go11
-rw-r--r--internal/fsm/fsm.go10
-rw-r--r--wrappers/python/src/__init__.py1
-rw-r--r--wrappers/python/src/main.py13
4 files changed, 33 insertions, 2 deletions
diff --git a/exports/exports.go b/exports/exports.go
index 17a9a9b..1081754 100644
--- a/exports/exports.go
+++ b/exports/exports.go
@@ -174,6 +174,17 @@ func SetIdentifier(name *C.char, identifier *C.char) *C.char {
return C.CString("")
}
+//export SetSearchServer
+func SetSearchServer(name *C.char) *C.char {
+ nameStr := C.GoString(name)
+ state, stateErr := GetVPNState(nameStr)
+ if stateErr != nil {
+ return C.CString(ErrorToString(stateErr))
+ }
+ setSearchErr := state.SetSearchServer()
+ return C.CString(ErrorToString(setSearchErr))
+}
+
//export SetDisconnected
func SetDisconnected(name *C.char) *C.char {
nameStr := C.GoString(name)
diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go
index 3d0bfd6..b77ea7e 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 is currently selecting a server in the UI
+ SEARCH_SERVER
+
// Chosen Server means the user has chosen a server to connect to
CHOSEN_SERVER
@@ -51,7 +54,7 @@ const (
// Has config means the user has gotten a config
HAS_CONFIG
- // Ask profile means the go code is asking for a profile selection from the ui
+ // Ask profile means the go code is asking for a profile selection from the UI
ASK_PROFILE
// Connected means the user has been connected to the server
@@ -64,6 +67,8 @@ func (s FSMStateID) String() string {
return "Deregistered"
case NO_SERVER:
return "No_Server"
+ case SEARCH_SERVER:
+ return "Search_Server"
case CHOSEN_SERVER:
return "Chosen_Server"
case OAUTH_STARTED:
@@ -108,7 +113,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"}},
+ NO_SERVER: {{CHOSEN_SERVER, "User chooses a server"}, {SEARCH_SERVER, "The user is trying to choose a Server in the UI"}},
+ 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"}},
AUTHORIZED: {{OAUTH_STARTED, "Re-authorize with OAuth"}, {REQUEST_CONFIG, "Client requests a config"}},
diff --git a/wrappers/python/src/__init__.py b/wrappers/python/src/__init__.py
index bc9b3df..d260916 100644
--- a/wrappers/python/src/__init__.py
+++ b/wrappers/python/src/__init__.py
@@ -63,6 +63,7 @@ lib.SetConnected.argtypes, lib.SetConnected.restype = [c_char_p], c_void_p
lib.SetDisconnected.argtypes, lib.SetDisconnected.restype = [c_char_p], c_void_p
lib.GetIdentifier.argtypes, lib.GetIdentifier.restype = [c_char_p], DataError
lib.SetIdentifier.argtypes, lib.SetIdentifier.restype = [c_char_p, c_char_p], c_void_p
+lib.SetSearchServer.argtypes, lib.SetSearchServer.restype = [c_char_p], c_void_p
lib.FreeString.argtypes, lib.FreeString.restype = [c_void_p], None
diff --git a/wrappers/python/src/main.py b/wrappers/python/src/main.py
index 687f40f..4117a86 100644
--- a/wrappers/python/src/main.py
+++ b/wrappers/python/src/main.py
@@ -105,6 +105,13 @@ def SetDisconnected(name: str) -> str:
return err_string
+def SetSearchServer(name: str) -> str:
+ name_bytes = name.encode("utf-8")
+ ptr_err = lib.SetSearchServer(name_bytes)
+ err_string = GetPtrString(ptr_err)
+ return err_string
+
+
def SetIdentifier(name: str, identifier: str) -> str:
name_bytes = name.encode("utf-8")
identifier_bytes = identifier.encode("utf-8")
@@ -230,6 +237,12 @@ class EduVPN(object):
if identifier_err:
raise Exception(identifier_err)
+ def set_search_server(self) -> None:
+ search_err = SetSearchServer(self.name)
+
+ if search_err:
+ raise Exception(search_err)
+
@property
def event(self) -> EventHandler:
return self.event_handler