Starting OpenVPN in background and how to stop it

116 views
Skip to first unread message

Mo B

unread,
Jul 27, 2023, 1:52:42 AM7/27/23
to Automate
This is my first Automate flow and my first community submission. I just started to learn Automate. I already pushed to the community but for discussion I keep this thread in parallel:


Description:
I keep a dictionary of trusted Wifis. The VPN tunnel is only established for untrusted Wifis. I trust my mobile connections. This flow is only comparing SSIDs, not BSSIDs, and not safe against spoofed network names.
For now I like to keep it simple, compact and understandable without 100s of SQL blocks, according to my basic skill, which might increase in the future...

Open points, questions and things not working:

* I like to check against trusted SSIDs via a dictionary setting value 1 for each key. Is that a good approach? How would I implement a way to have "SSID is like MYNET*" because all my network names are starting with the same name prefix?

* Starting VPN via shortcut opens the OpenVPN app in foreground, can I do that in background?

* Disconnect VPN activity for shutting down VPN does not work. I get an exception with
com.android.server.wm.ActivityStarter.executeRequest(Unknown Source:673)
I also don't see a shortcut option for shutdown.

Best regards,
Mo
OpenVPN for untrusted networks [incomplete].flo

Henrik "The Developer" Lindqvist

unread,
Jul 28, 2023, 9:12:14 AM7/28/23
to Automate
To start stop, see:

Example, using App start block:
  • Package: net.openvpn.openvpn
  • Activity class: net.openvpn.unified.MainActivity
  • Action= "net.openvpn.openvpn.CONNECT"
  • Extras= { "net.openvpn.openvpn.AUTOSTART_PROFILE_ID": your_profile_id, "net.openvpn.openvpn.AUTOCONNECT" as Boolean: 1 }

Mo B

unread,
Aug 9, 2023, 10:38:51 AM8/9/23
to Automate
Does that mean I can't use my favourite de.blinkt.openvpn with Automate and need to switch to net.openvpn.openvpn?
It already provides functions to start a VPN, I just can't close it.

In general, does an App need to provide an API for Automate to call functions on it?

Henrik "The Developer" Lindqvist

unread,
Aug 10, 2023, 5:03:06 AM8/10/23
to Automate
Yes, an app needs to provide or expose some way for another app to access its features, otherwise simulating the UI click is the only alternative.
Seems like your version of OpenVPN also expose an API, see: https://github.com/schwabe/ics-openvpn
Example, using App start block:
  • Action: Main
  • Package: de.blinkt.openvpn
  • Activity class: de.blinkt.openvpn.api.ConnectVPN
  • Extras= { "de.blinkt.openvpn.api.profileName": "myvpnprofile" }
Reply all
Reply to author
Forward
0 new messages