status vpn verbunden abfragen ?

Post your questions and help other users.

Moderator: Martin

Post Reply
joeko
Posts: 34
Joined: 17 Jan 2017 19:21

status vpn verbunden abfragen ?

Post by joeko » 02 Aug 2018 11:15

hallo,
kann ich den Status der vpn Verbindung abfragen um davon weitere flows ausführen zu lassen ?

User avatar
schuster666
Posts: 52
Joined: 13 Nov 2013 14:03
Location: Germany / Neuss

Re: status vpn verbunden abfragen ?

Post by schuster666 » 29 Dec 2019 12:57

Ich würde mich da anschließen wollen.
Durch ein Datenleck (bei Win10) bin ich auf dieses Thema aufmerksam geworden und würde gerne checken ob das VPN (Android) in Betrieb ist oder nicht.

Könnte man alternativ abfragen welche Symbole in der Statusleiste angezeigt werden?
-- the world would be better without people--
-- but boring --

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: status vpn verbunden abfragen ?

Post by Desmanto » 01 Jan 2020 12:58

It seems somehow I missed this post from 2018. Maybe because translation failed at that time.

You can detect the network config and check if tunneling interface is in use. use action execute command

Code: Select all

ifconfig | grep tun
If the stdout show something, then tunneling is in use, VPN is connected. But if blank, then no VPN connected. Check it using expression

Code: Select all

std != '""
If true, then stdout not blank, VPN Connected. If false, stdout is empty, tunneling interface not detected, VPN is not connected.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: status vpn verbunden abfragen ?

Post by anuraag » 01 Jan 2020 14:18

anuraag wrote:
13 Apr 2019 08:38
Below code works on my oreo. vpnconnected will return true or false

Code: Select all

ctx=getContext();
cm=callJavaMethod(ctx, "android.content.Context", "getSystemService(java.lang.String)", "connectivity");

vpnconnected=callJavaMethod(callJavaMethod(cm, "android.net.ConnectivityManager", "getNetworkInfo(int)", getJavaStaticField("android.net.ConnectivityManager", "TYPE_VPN")), "android.net.NetworkInfo", "isConnectedOrConnecting()");

Horschte
Posts: 56
Joined: 03 Nov 2014 18:00

Re: status vpn verbunden abfragen ?

Post by Horschte » 04 Jan 2020 01:22

Thank you for both approaches Desmanto and anuraag.

But in my tests the java way is much faster than the execute command action:

java: about 5 ms
execute command: about 100 ms

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: status vpn verbunden abfragen ?

Post by Desmanto » 04 Jan 2020 12:36

@anuraag : Thank you always for the java code. I wish i really spent my time to learn java properly.

@Horschte : Thanks for the testing. So in most cases, when speed is important, calling java method is always preferred than using terminal emulator command. But this seems only happen in Automagic, as maybe for the action execute command (and root command), Automagic need to setup the environment first before executing the command. While script is already built-in.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
schuster666
Posts: 52
Joined: 13 Nov 2013 14:03
Location: Germany / Neuss

Re: status vpn verbunden abfragen ?

Post by schuster666 » 06 Jan 2020 05:38

Thank you all.
With this script/code all of my flows working perfekt.

Coding Java is next on my todo List.

I'm always very impressed about the possibilitys.

In hope that my mind will do the trick….. 😂😂
-- the world would be better without people--
-- but boring --

Post Reply