diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-26 17:09:52 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-26 17:09:52 +0200 |
| commit | 516a25eb926a8b9a879e4f38c86d4dbb9b9e0948 (patch) | |
| tree | 5e1adb12ebab7b6f770102a179afb2a7db9e479f /wrappers/python/eduvpn_common/main.py | |
| parent | b4be281671ecfe5c1e6f831614ca1dde48522cd7 (diff) | |
Client + Exports + Python: Add a function for getting the current server
Diffstat (limited to 'wrappers/python/eduvpn_common/main.py')
| -rw-r--r-- | wrappers/python/eduvpn_common/main.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index 1467adb..a77015c 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple from eduvpn_common.discovery import DiscoOrganizations, DiscoServers, get_disco_organizations, get_disco_servers from eduvpn_common.event import EventHandler from eduvpn_common.loader import initialize_functions, load_lib -from eduvpn_common.server import Profiles, Server, get_servers +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 @@ -470,6 +470,22 @@ class EduVPN(object): """ return self.go_function(self.lib.InFSMState, state_id) + def get_current_server(self) -> Optional[Server]: + """Get the current server + + :return: The current servers if there is any + :rtype: Optional[List[Servers]] + """ + server, server_err = self.go_function( + self.lib.GetCurrentServer, + decode_func=lambda lib, x: get_data_error(lib, x, get_transition_server), + ) + + if server_err: + raise server_err + + return server + def get_saved_servers(self) -> Optional[List[Server]]: """Get a list of saved servers |
