summaryrefslogtreecommitdiff
path: root/wrappers/python/eduvpn_common
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroen.wijenbergh@geant.org>2025-09-03 10:13:46 +0200
committerJeroen Wijenbergh <jeroen.wijenbergh@geant.org>2025-09-03 10:53:42 +0200
commitc3318fb386096170282e831eb3b616a5a7e9dda8 (patch)
tree0367fdad43a02da49b278f38db9b8e15d3de908a /wrappers/python/eduvpn_common
parent5e05784cab953b0e24609398106dd33da7738d21 (diff)
Revert "All: Remove ProxyGuard integration"
This partially reverts commit 6b939462fb1064abd42e8cb8316700ec844172ea. It keeps the proxyguard functions but leaves GetConfig alone. E.g. no WireGuard config replacing and querying is happening for ProxyGuard. Needed for the Linux client as I have not found a good way to have a daemon with NetworkManager integration
Diffstat (limited to 'wrappers/python/eduvpn_common')
-rw-r--r--wrappers/python/eduvpn_common/loader.py31
-rw-r--r--wrappers/python/eduvpn_common/main.py44
-rw-r--r--wrappers/python/eduvpn_common/types.py1
3 files changed, 75 insertions, 1 deletions
diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py
index 888b53f..d902453 100644
--- a/wrappers/python/eduvpn_common/loader.py
+++ b/wrappers/python/eduvpn_common/loader.py
@@ -6,6 +6,7 @@ from eduvpn_common.types import (
BoolError,
DataError,
HandlerError,
+ ProxySetup,
ReadRxBytes,
RefreshList,
TokenGetter,
@@ -131,3 +132,33 @@ def initialize_functions(lib: CDLL) -> None:
],
BoolError,
)
+ lib.NewProxyguard.argtypes, lib.NewProxyguard.restype = (
+ [
+ c_int,
+ c_int,
+ c_int,
+ c_char_p,
+ ProxySetup,
+ ],
+ HandlerError,
+ )
+ lib.ProxyguardRestart.argtypes, lib.ProxyguardRestart.restype = (
+ [
+ c_int,
+ ],
+ c_char_p,
+ )
+ lib.ProxyguardTunnel.argtypes, lib.ProxyguardTunnel.restype = (
+ [
+ c_int,
+ c_int,
+ c_int,
+ ],
+ c_char_p,
+ )
+ lib.ProxyguardPeerIPs.argtypes, lib.ProxyguardPeerIPs.restype = (
+ [
+ c_int,
+ ],
+ DataError,
+ )
diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py
index 2bd221d..e63ea92 100644
--- a/wrappers/python/eduvpn_common/main.py
+++ b/wrappers/python/eduvpn_common/main.py
@@ -1,12 +1,13 @@
import ctypes
import json
from enum import IntEnum
-from typing import Any, Callable, Iterator, Optional
+from typing import Any, Callable, Iterator, List, Optional
from eduvpn_common.event import EventHandler
from eduvpn_common.loader import initialize_functions, load_lib
from eduvpn_common.state import State
from eduvpn_common.types import (
+ ProxySetup,
ReadRxBytes,
RefreshList,
TokenGetter,
@@ -19,6 +20,29 @@ from eduvpn_common.types import (
global_object = None
+class Proxyguard(object):
+ def __init__(self, parent, handler):
+ self.parent = parent
+ self.handler = handler
+
+ def tunnel(self, wglisten: int):
+ tunnel_err = self.parent.go_cookie_function(self.parent.lib.ProxyguardTunnel, self.handler, wglisten)
+ if tunnel_err:
+ forwardError(tunnel_err)
+
+ @property
+ def peer_ips(self) -> List[str]:
+ peer_ips, peer_ips_err = self.parent.go_function(self.parent.lib.ProxyguardPeerIPs, self.handler)
+ if peer_ips_err:
+ forwardError(peer_ips_err)
+ return json.loads(peer_ips)
+
+ def restart(self):
+ restart_err = self.parent.go_function(self.parent.lib.ProxyguardRestart, self.handler)
+ if restart_err:
+ forwardError(restart_err)
+
+
class WrappedError(Exception):
def __init__(self, translations, language, misc):
self.translations = translations
@@ -350,6 +374,24 @@ class EduVPN(object):
forwardError(dropped_err)
return dropped
+ def new_proxyguard(
+ self,
+ listen_port: int,
+ tcp_source_port: int,
+ peer: str,
+ setup: ProxySetup,
+ ) -> Proxyguard:
+ proxy, proxy_err = self.go_cookie_function(
+ self.lib.NewProxyguard,
+ listen_port,
+ tcp_source_port,
+ peer,
+ setup,
+ )
+ if proxy_err:
+ forwardError(proxy_err)
+ return Proxyguard(self, proxy)
+
def cancel(self):
self.jar.cancel()
diff --git a/wrappers/python/eduvpn_common/types.py b/wrappers/python/eduvpn_common/types.py
index 999fbdd..5e23d61 100644
--- a/wrappers/python/eduvpn_common/types.py
+++ b/wrappers/python/eduvpn_common/types.py
@@ -45,6 +45,7 @@ class BoolError(Structure):
# The type for a Go state change callback
VPNStateChange = CFUNCTYPE(c_int, c_int, c_int, c_char_p)
+ProxySetup = CFUNCTYPE(c_void_p, c_int)
ReadRxBytes = CFUNCTYPE(c_ulonglong)
RefreshList = CFUNCTYPE(c_void_p)
TokenGetter = CFUNCTYPE(c_void_p, c_char_p, c_int, POINTER(c_char), c_size_t)