From eb0c7e7251a0038963436dcd77e6d92311f0bf8f Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Thu, 22 Feb 2024 16:04:05 +0100 Subject: Wrappers Python: Add necessary callbacks for proxyguard --- wrappers/python/eduvpn_common/loader.py | 5 ++++- wrappers/python/eduvpn_common/main.py | 7 +++++-- wrappers/python/eduvpn_common/types.py | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'wrappers/python/eduvpn_common') diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py index d608e71..c7c2233 100644 --- a/wrappers/python/eduvpn_common/loader.py +++ b/wrappers/python/eduvpn_common/loader.py @@ -6,6 +6,8 @@ from ctypes import CDLL, c_char_p, c_int, c_void_p, cdll from eduvpn_common import __version__ from eduvpn_common.types import ( BoolError, + GotProxyFD, + ProxyReady, DataError, ReadRxBytes, TokenGetter, @@ -130,5 +132,6 @@ def initialize_functions(lib: CDLL) -> None: c_char_p, c_int, c_char_p, - c_void_p, + GotProxyFD, + ProxyReady, ], c_void_p diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index cd26ca4..ea0ebb3 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -5,6 +5,8 @@ from typing import Any, Callable, Iterator, Optional from eduvpn_common.loader import initialize_functions, load_lib from eduvpn_common.types import ( + GotProxyFD, + ProxyReady, ReadRxBytes, TokenGetter, TokenSetter, @@ -345,13 +347,14 @@ class EduVPN(object): forwardError(dropped_err) return dropped - def start_proxyguard(self, listen: str, source_port: int, peer: str): + def start_proxyguard(self, listen: str, source_port: int, peer: str, gotfd: GotProxyFD, ready: ProxyReady): proxy_err = self.go_cookie_function( self.lib.StartProxyguard, listen, source_port, peer, - 0, + gotfd, + ready, ) if proxy_err: forwardError(proxy_err) diff --git a/wrappers/python/eduvpn_common/types.py b/wrappers/python/eduvpn_common/types.py index e2498b3..e46522a 100644 --- a/wrappers/python/eduvpn_common/types.py +++ b/wrappers/python/eduvpn_common/types.py @@ -34,6 +34,8 @@ class BoolError(Structure): # The type for a Go state change callback VPNStateChange = CFUNCTYPE(c_int, c_int, c_int, c_char_p) +GotProxyFD = CFUNCTYPE(c_void_p, c_int) +ProxyReady = CFUNCTYPE(c_void_p) ReadRxBytes = CFUNCTYPE(c_ulonglong) TokenGetter = CFUNCTYPE(c_void_p, c_char_p, c_int, POINTER(c_char), c_size_t) TokenSetter = CFUNCTYPE(c_void_p, c_char_p, c_int, c_char_p) -- cgit v1.2.3