summaryrefslogtreecommitdiff
path: root/wrappers/python
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-02-14 13:32:02 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-05 12:26:11 +0200
commitc961faa8d7ba02e601586c3ce531b2329c7b258e (patch)
tree6afe9fa6141f3b32f9eb0fe7516b6b24d0796356 /wrappers/python
parentba16e07ca74e2d0211808718dd1ffc9611b36ec2 (diff)
Python: Expose getting servers list
Signed-off-by: jwijenbergh <jeroenwijenbergh@protonmail.com>
Diffstat (limited to 'wrappers/python')
-rw-r--r--wrappers/python/eduvpncommon/discovery.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/wrappers/python/eduvpncommon/discovery.py b/wrappers/python/eduvpncommon/discovery.py
index 48089da..8559eb1 100644
--- a/wrappers/python/eduvpncommon/discovery.py
+++ b/wrappers/python/eduvpncommon/discovery.py
@@ -1,17 +1,19 @@
from . import lib, GoSlice, DataError
from ctypes import *
+from typing import Callable
from enum import Enum
# We have to use c_void_p instead of c_char_p to free it properly
# See https://stackoverflow.com/questions/13445568/python-ctypes-how-to-free-memory-getting-invalid-pointer-error
lib.GetOrganizationsList.argtypes, lib.GetOrganizationsList.restype = [], DataError
+lib.GetServersList.argtypes, lib.GetServersList.restype = [], DataError
lib.FreeString.argtypes, lib.FreeString.restype = [c_void_p], None
lib.Verify.argtypes, lib.Verify.restype = [GoSlice, GoSlice, GoSlice, c_uint64], c_int64
lib.InsecureTestingSetExtraKey.argtypes, lib.InsecureTestingSetExtraKey.restype = [GoSlice], None
-def getOrganizationsList() -> str:
- dataError = lib.GetOrganizationsList()
+def getList(func: Callable) -> str:
+ dataError = func()
ptr = dataError.data
error = dataError.error
body = ""
@@ -22,6 +24,12 @@ def getOrganizationsList() -> str:
raise RequestError(error)
return body
+def GetOrganizationsList() -> str:
+ return getList(lib.GetOrganizationsList)
+
+def GetServersList() -> str:
+ return getList(lib.GetServersList)
+
class GoError(Exception):
message_dict: dict