summaryrefslogtreecommitdiff
path: root/exports
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-10-26 17:09:52 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-10-26 17:09:52 +0200
commit516a25eb926a8b9a879e4f38c86d4dbb9b9e0948 (patch)
tree5e1adb12ebab7b6f770102a179afb2a7db9e479f /exports
parentb4be281671ecfe5c1e6f831614ca1dde48522cd7 (diff)
Client + Exports + Python: Add a function for getting the current server
Diffstat (limited to 'exports')
-rw-r--r--exports/servers.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/exports/servers.go b/exports/servers.go
index 36763b4..381c0dd 100644
--- a/exports/servers.go
+++ b/exports/servers.go
@@ -305,6 +305,28 @@ func GetSavedServers(name *C.char) (*C.servers, *C.error) {
return servers, nil
}
+
+//export GetCurrentServer
+// This function takes the name as input which is the name of the client
+// It gets the state by name and then returns the current server as a c struct belonging to it
+func GetCurrentServer(name *C.char) (*C.server, *C.error) {
+ nameStr := C.GoString(name)
+ state, stateErr := GetVPNState(nameStr)
+ if stateErr != nil {
+ return nil, getError(stateErr)
+ }
+ server, serverErr := state.Servers.GetCurrentServer()
+ if serverErr != nil {
+ return nil, getError(serverErr)
+ }
+ base, baseErr := server.GetBase()
+ if baseErr != nil {
+ return nil, getError(baseErr)
+ }
+ cServer := getCPtrServer(state, base)
+ return cServer, nil
+}
+
// This function takes the state as input which is the main state
// It also takes the data as an interface and if it has the servers type gets the data as a c struct otherwise nil
func getTransitionDataServers(state *client.Client, data interface{}) *C.servers {