summaryrefslogtreecommitdiff
path: root/wrappers/python/main.py
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-07 16:18:03 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-07 16:18:03 +0200
commitc67b8f64438d439d52a9e4955ff1bdf30363dbb1 (patch)
treed54cc9b11bc5cfd9cfef375f4742987193050658 /wrappers/python/main.py
parent7d67ce7f6a15970677b7d0b8f4912fe379862515 (diff)
Secure Internet: Implement the Ask Location transition callback
Diffstat (limited to 'wrappers/python/main.py')
-rw-r--r--wrappers/python/main.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/wrappers/python/main.py b/wrappers/python/main.py
index 5422d93..d75504f 100644
--- a/wrappers/python/main.py
+++ b/wrappers/python/main.py
@@ -1,6 +1,7 @@
import eduvpncommon.main as eduvpn
import webbrowser
import json
+import sys
# Asks the user for a profile index
# It loops up until a valid input is given
@@ -31,6 +32,11 @@ def setup_callbacks(_eduvpn: eduvpn.EduVPN) -> None:
print(f"Got OAuth URL {url}, old state: {old_state}")
webbrowser.open(url)
+ @_eduvpn.event.on("Ask_Location", eduvpn.StateType.Enter)
+ def ask_location(old_state: str, locations: str):
+ print("Locations: ", locations)
+ _eduvpn.set_secure_location("NL")
+
# The callback which asks the user for a profile
@_eduvpn.event.on("Ask_Profile", eduvpn.StateType.Enter)
def ask_profile(old_state: str, profiles: str):
@@ -79,9 +85,12 @@ if __name__ == "__main__":
# Get a Wireguard/OpenVPN config
try:
config, config_type = _eduvpn.get_config_custom_server(server)
+ print(f"Got a config with type: {config_type} and contents:\n{config}")
except Exception as e:
print("Failed to connect:", e)
- print(f"Got a config with type: {config_type} and contents:\n{config}")
+ # Save and exit
+ _eduvpn.deregister()
+ sys.exit(1)
# Set the internal FSM state to connected
try: