summaryrefslogtreecommitdiff
path: root/exports
diff options
context:
space:
mode:
Diffstat (limited to 'exports')
-rw-r--r--exports/disco.go20
-rw-r--r--exports/servers.go8
2 files changed, 12 insertions, 16 deletions
diff --git a/exports/disco.go b/exports/disco.go
index e28fb01..73bc1ac 100644
--- a/exports/disco.go
+++ b/exports/disco.go
@@ -168,17 +168,15 @@ func FreeDiscoOrganizations(cOrganizations *C.discoveryOrganizations) {
}
//export GetDiscoServers
-func GetDiscoServers(name *C.char) *C.discoveryServers {
+func GetDiscoServers(name *C.char) (*C.discoveryServers, *C.char) {
nameStr := C.GoString(name)
state, stateErr := GetVPNState(nameStr)
- // TODO
if stateErr != nil {
- panic(stateErr)
+ return nil, C.CString(ErrorToString(stateErr))
}
servers, serversErr := state.GetDiscoServers()
- // TODO
if serversErr != nil {
- panic(serversErr)
+ return nil, C.CString(ErrorToString(serversErr))
}
returnedStruct := (*C.discoveryServers)(
@@ -189,21 +187,19 @@ func GetDiscoServers(name *C.char) *C.discoveryServers {
state,
servers,
)
- return returnedStruct
+ return returnedStruct, nil
}
//export GetDiscoOrganizations
-func GetDiscoOrganizations(name *C.char) *C.discoveryOrganizations {
+func GetDiscoOrganizations(name *C.char) (*C.discoveryOrganizations, *C.char) {
nameStr := C.GoString(name)
state, stateErr := GetVPNState(nameStr)
- // TODO
if stateErr != nil {
- panic(stateErr)
+ return nil, C.CString(ErrorToString(stateErr))
}
organizations, organizationsErr := state.GetDiscoOrganizations()
- // TODO
if organizationsErr != nil {
- panic(organizationsErr)
+ return nil, C.CString(ErrorToString(organizationsErr))
}
returnedStruct := (*C.discoveryOrganizations)(
@@ -216,5 +212,5 @@ func GetDiscoOrganizations(name *C.char) *C.discoveryOrganizations {
organizations,
)
- return returnedStruct
+ return returnedStruct, nil
}
diff --git a/exports/servers.go b/exports/servers.go
index e5c9301..a487176 100644
--- a/exports/servers.go
+++ b/exports/servers.go
@@ -293,14 +293,14 @@ func getSavedServersWithOptions(state *eduvpn.VPNState, servers *server.Servers)
//export GetSavedServers
// This function takes the name as input which is the name of the client
// It gets the state by name and then returns the saved servers as a c struct belonging to it
-func GetSavedServers(name *C.char) *C.servers {
+func GetSavedServers(name *C.char) (*C.servers, *C.char) {
nameStr := C.GoString(name)
state, stateErr := GetVPNState(nameStr)
if stateErr != nil {
- // TODO: Remove this panic
- panic(stateErr)
+ return nil, C.CString(ErrorToString(stateErr))
}
- return getSavedServersWithOptions(state, &state.Servers)
+ servers := getSavedServersWithOptions(state, &state.Servers)
+ return servers, nil
}
// This function takes the state as input which is the main state