diff options
Diffstat (limited to 'wrappers/python/src')
| -rw-r--r-- | wrappers/python/src/__init__.py | 6 | ||||
| -rw-r--r-- | wrappers/python/src/main.py | 13 |
2 files changed, 11 insertions, 8 deletions
diff --git a/wrappers/python/src/__init__.py b/wrappers/python/src/__init__.py index e417371..c028f09 100644 --- a/wrappers/python/src/__init__.py +++ b/wrappers/python/src/__init__.py @@ -33,15 +33,15 @@ class DataError(Structure): VPNStateChange = CFUNCTYPE(None, c_char_p, c_char_p, c_char_p) # Exposed functions -lib.Connect.argtypes, lib.Connect.restype = [c_char_p, c_char_p], DataError +# 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.GetConnectConfig.argtypes, lib.GetConnectConfig.restype = [c_char_p, c_char_p, c_int, c_int], DataError lib.Deregister.argtypes, lib.Deregister.restype = [c_char_p], c_void_p lib.Register.argtypes, lib.Register.restype = [c_char_p, c_char_p, VPNStateChange, c_int], c_void_p lib.GetOrganizationsList.argtypes, lib.GetOrganizationsList.restype = [c_char_p], DataError lib.GetServersList.argtypes, lib.GetServersList.restype = [c_char_p], DataError lib.CancelOAuth.argtypes, lib.CancelOAuth.restype = [c_char_p], c_void_p lib.SetProfileID.argtypes, lib.SetProfileID.restype = [c_char_p, c_char_p], c_void_p -# 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.SetConnected.argtypes, lib.SetConnected.restype = [c_char_p], c_void_p lib.SetDisconnected.argtypes, lib.SetDisconnected.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 9c2fb41..2b346e3 100644 --- a/wrappers/python/src/main.py +++ b/wrappers/python/src/main.py @@ -36,11 +36,10 @@ def GetDiscoServers(name): organizations, organizationsErr = GetDataError(lib.GetOrganizationsList(name_bytes)) return servers, serversErr, organizations, organizationsErr - -def Connect(name, url): +def GetConnectConfig(name, url, is_secure_internet, force_tcp): name_bytes = name.encode("utf-8") url_bytes = url.encode("utf-8") - data_error = lib.Connect(name_bytes, url_bytes) + data_error = lib.GetConnectConfig(name_bytes, url_bytes, is_secure_internet, force_tcp) return GetDataError(data_error) def SetConnected(name): @@ -95,8 +94,12 @@ class EduVPN(object): def get_disco(self): return GetDiscoServers(self.name) - def connect(self, url): - return Connect(self.name, url) + def get_config_institute_access(self, url, force_tcp=False): + return GetConnectConfig(self.name, url, False, force_tcp) + + def get_config_secure_internet(self, url, force_tcp=False): + return GetConnectConfig(self.name, url, True, force_tcp) + def set_disconnected(self): return SetDisconnected(self.name) |
