diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-02-14 11:41:12 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-05 12:26:11 +0200 |
| commit | d306d7b27ee1df60bf32f03b6160856e78d1b02c (patch) | |
| tree | 17ead8a0b05fe02817c5be954782fdb53c5fb7ac /exports | |
| parent | abe952080b01be4524fd03462236b6a3e63589f8 (diff) | |
Expose list retrieval by returning a JSON string
Signed-off-by: jwijenbergh <jeroenwijenbergh@protonmail.com>
Diffstat (limited to 'exports')
| -rw-r--r-- | exports/exports.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/exports/exports.go b/exports/exports.go index acf02e1..c4943f1 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -1,6 +1,10 @@ package main +/* +#include <stdlib.h> +*/ import "C" +import "unsafe" import "github.com/jwijenbergh/eduvpn-common/src" @@ -8,15 +12,27 @@ import "github.com/jwijenbergh/eduvpn-common/src" // GetOrganizationsList gets the list of organizations from the disco server. // Returns the unix timestamp of the data. This is used as key for looking up data. //export GetOrganizationsList -//func GetOrganizationsList() uint64 { -// return eduvpn.GetOrganizationsList() -//} +func GetOrganizationsList() (*C.char, int8) { + body, err := eduvpn.GetOrganizationsList() + if err != nil { + return nil, int8(err.(eduvpn.RequestError).Code) + } + return C.CString(body), 0 +} + +//export FreeString +func FreeString(addr *C.char) { + C.free(unsafe.Pointer(addr)) +} // //// GetServerList gets the list of servers from the disco server. //// Returns the unix timestamp of the data. This is used as key for looking up data. -////export GetServerList -//func GetServerList() uint64 { -// return eduvpn.GetServerList() +//func GetServersList() ([]byte, int8) { +// body, err := eduvpn.GetServersList() +// if err != nil { +// return nil, int8(err.(eduvpn.RequestError).Code) +// } +// return body, 0 //} // Verify verifies a signature on a JSON file. See eduvpn.Verify for more details. |
