Hello, my goal is to be able to connect to a VPN via an .ovpn file using the OpenVPN API itself. My use case is executing some Python code in a serverless cloud environment to connect to a database behind this VPN. Since the environment is serverless, I can't install the client and execute it via shell, so I was trying to sort of use the code behind the client.
I build the source code from https://github.com/OpenVPN/openvpn3 and found out there is a Python wrapper at core/build/client/ovpncli.py. I tried to copy a CLI example in C++ from this repo, but I can't get it to work.
[
When i execute it, I get the error
. Why does this happen? How can I fix it? Is there any other more straightforward way to achieve this? (Btw, I have almost zero knowledge on networking)
Thanks
I build the source code from https://github.com/OpenVPN/openvpn3 and found out there is a Python wrapper at core/build/client/ovpncli.py. I tried to copy a CLI example in C++ from this repo, but I can't get it to work.
[
Code:
from ovpncli import ClientAPI_OpenVPNClientHelper as OpenVPNClientHelper, ClientAPI_OpenVPNClient as OpenVPNClient, ClientAPI_Config as Config import threading class Client(OpenVPNClient): pass def execute(client): status = client.connect() print(status.error) print(status.message) return status helper = OpenVPNClientHelper() merged_config = helper.merge_config('path_to_ovpn_file', True) config = Config() config.content = merged_config.profileContent client = Client() eval_config = client.eval_config(config) thread = threading.Thread(target=execute, args=(client,)) thread.start() thread.join()
Code:
SWIG director method error. Error detected when calling 'ClientAPI_OpenVPNClient.event'
Thanks