diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-09 14:18:23 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-05-09 14:18:23 +0200 |
| commit | 1ef27cc47ad56a2c66aaa40e398a0063be2573d4 (patch) | |
| tree | fff365577d82274f2b05878e702238b8a575c5c8 /wrappers | |
| parent | fd0753c5463b4c54d09712336301e174f05e05ab (diff) | |
FSM/State: Profile correctness and connect name change
Also add a force tcp flag
Diffstat (limited to 'wrappers')
| -rw-r--r-- | wrappers/python/main.py | 2 | ||||
| -rw-r--r-- | wrappers/python/src/__init__.py | 6 | ||||
| -rw-r--r-- | wrappers/python/src/main.py | 13 |
3 files changed, 12 insertions, 9 deletions
diff --git a/wrappers/python/main.py b/wrappers/python/main.py index be9ab6c..1c1afd7 100644 --- a/wrappers/python/main.py +++ b/wrappers/python/main.py @@ -24,7 +24,7 @@ if not success: print(_eduvpn.get_disco()) -config, error = _eduvpn.connect("https://eduvpn.jwijenbergh.com") +config, error = _eduvpn.get_config_institute_access("https://eduvpn.jwijenbergh.com") if error: print("Got connect error", error) 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) |
