diff options
| author | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-09-03 10:13:46 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <jeroen.wijenbergh@geant.org> | 2025-09-03 10:53:42 +0200 |
| commit | c3318fb386096170282e831eb3b616a5a7e9dda8 (patch) | |
| tree | 0367fdad43a02da49b278f38db9b8e15d3de908a /wrappers/python/eduvpn_common/main.py | |
| parent | 5e05784cab953b0e24609398106dd33da7738d21 (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/main.py')
| -rw-r--r-- | wrappers/python/eduvpn_common/main.py | 44 |
1 files changed, 43 insertions, 1 deletions
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() |
