summaryrefslogtreecommitdiff
path: root/wrappers/python/eduvpn_common
diff options
context:
space:
mode:
Diffstat (limited to 'wrappers/python/eduvpn_common')
-rw-r--r--wrappers/python/eduvpn_common/loader.py3
-rw-r--r--wrappers/python/eduvpn_common/main.py16
-rw-r--r--wrappers/python/eduvpn_common/types.py1
3 files changed, 19 insertions, 1 deletions
diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py
index 3de3de5..1090619 100644
--- a/wrappers/python/eduvpn_common/loader.py
+++ b/wrappers/python/eduvpn_common/loader.py
@@ -7,6 +7,7 @@ from eduvpn_common import __version__
from eduvpn_common.types import (
ConfigError,
DataError,
+ ReadRxBytes,
VPNStateChange,
)
@@ -151,3 +152,5 @@ def initialize_functions(lib: CDLL) -> None:
c_int,
], c_void_p
lib.ShouldRenewButton.argtypes, lib.ShouldRenewButton.restype = [], int
+ lib.StartFailover.argtypes, lib.StartFailover.restype = [c_char_p, c_char_p, c_int, ReadRxBytes], DataError
+ lib.CancelFailover.argtypes, lib.CancelFailover.restype = [c_char_p], c_void_p
diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py
index 20d646f..3cb45e1 100644
--- a/wrappers/python/eduvpn_common/main.py
+++ b/wrappers/python/eduvpn_common/main.py
@@ -7,7 +7,7 @@ from eduvpn_common.event import EventHandler
from eduvpn_common.loader import initialize_functions, load_lib
from eduvpn_common.server import Profiles, Server, get_transition_server, get_servers
from eduvpn_common.state import State, StateType
-from eduvpn_common.types import VPNStateChange, decode_res, encode_args, get_data_error
+from eduvpn_common.types import ReadRxBytes, VPNStateChange, decode_res, encode_args, get_data_error, get_bool
class EduVPN(object):
@@ -502,6 +502,20 @@ class EduVPN(object):
return servers
+ def start_failover(self, gateway: str, wg_mtu: int, readrxbytes: ReadRxBytes) -> bool:
+ dropped, dropped_err = self.go_function(
+ self.lib.StartFailover, gateway, wg_mtu, readrxbytes,
+ decode_func=lambda lib, x: get_data_error(lib, x, get_bool),
+ )
+ if dropped_err:
+ raise dropped_err
+ return dropped
+
+ def cancel_failover(self):
+ cancel_err = self.go_function(self.lib.CancelFailover)
+ if cancel_err:
+ raise cancel_err
+
eduvpn_objects: Dict[str, EduVPN] = {}
diff --git a/wrappers/python/eduvpn_common/types.py b/wrappers/python/eduvpn_common/types.py
index 07a02d3..7e3ce9a 100644
--- a/wrappers/python/eduvpn_common/types.py
+++ b/wrappers/python/eduvpn_common/types.py
@@ -166,6 +166,7 @@ class ConfigError(Structure):
# The type for a Go state change callback
VPNStateChange = CFUNCTYPE(c_int, c_char_p, c_int, c_int, c_void_p)
+ReadRxBytes = CFUNCTYPE(c_ulonglong)
def encode_args(args: List[Any], types: List[Any]) -> Iterator[Any]: