henrichg/PhoneProfilesPlus

[Feature Request] Event: If connected to unknown/unsecure network / If not connected to known/secure network

Stimmenhotel opened this issue · 11 comments

Hey, thanks for this great app!

I am trying to enable VPN (priv. wireguard) every time I connect to an unknown/unsecure Wi-Fi.
It is more like ==> I am trying to only enable VPN every time I am not connected to a known/secure Wi-Fi.

Right now I am only using the VPN feature to connect to a VPN automatically if my profile (for example "work"), which will automatically connect to the work Wi-Fi.

Now, I tried to create a dedicated profile to connect to the VPN once an event only checking for Wi-Fi is triggered.
Using the Wi-Fi Sensor, I hoped to find an option like "Don't start if connected to ...", so I can add trusted Wi-Fi to the list instead of "connect to VPN if in one of these Wi-Fi".

Am I missing a function which allows this? Or is it not possible right now?

OK, maybe I understand what you want. Is possible to check network capabilities:

private boolean isProtectedNetwork(String capability){

       return (capability.contains("WPA") || 
               capability.contains("WEP") || 
               capability.contains("WPS")
              );
}

These 3 types are secure. You want this?

Source: https://stackoverflow.com/questions/25662761/how-to-differentiate-open-and-secure-wifi-networks-without-connecting-to-it-in-a

Sorry for not answering for a while, I was testing your solution for a few weeks now.

Sadly, it is not what I searched for/PPP is not the App for this.

Basically, I want an app that will connect me to a wireguard vpn if I am not in my home-wifi (save network).
So if I enter any cafeteria/work/train network (unsecure), I want to get connected.
Edit: The list of secure networks is managed manually.

Your solution was working, but also if the network is only in reach but not connected.

"So if I enter any cafeteria/work/train network (unsecure), I want to get connected."

The problem is: when to enable VPN.

Because:

  • at work: you want to enable VPN automatically when device is at work? If yes, add event with Wi-Fi sensor, SSID name at work, Connection type=Nearby and activate profile which enable VPN.
  • in cafeteria, train: maybe only when you want to use Wi-Fi? Then maually activate profile, which enable VPN.

EDIT:

  • in cafeteria, train: you want to enable VPN automatically? If yes, add event with Wi-Fi sensor, SSID name at Home, Connection type="Not nearby" and activate profile which enable VPN.
    But with this is problem. This enable VPN in all detected SSIDs, except Home SSID. Maybe this is not good for you.

EDIT2:

  • at Home you must disable VPN. For this add event with Wi-Fi sensor, SSID name at Home, Connection type=Nearby and activate profile which DISABLE VPN.

The idea was to be connected to VPN automatically once in a not "listed"/save/known network.

Between Wifis I am on mobile data, that is ok and "safe".

The Nearby/Not Connected event triggers even if I am driving past an open-wifi I was connected to (for example, every bus stop has an open hotspot for my provider). The wifi won't even connect in that time, but VPN will be enabled for LTE already.

I only want to enable VPN only if not conneted to a "safe" network.
In other words: Connect to VPN if not connected to "list-of-wifi"
In event words: Connect to VPN if "not-connected" to "list-of-wifi"

Enabling/disabling VPN is no problem manually. Wireguard has a QS-tile for enabling this.

I think this is also more a use-case for tasker or similar apps. Not for profiles as in "ringing-profiles".

The problem is: when to enable VPN.

If connected to a VPN not on the list.

Connected in that case is not "nearby" or "not connected", as it already enables VPN if not needed.

"I only want to enable VPN only if not conneted to a "safe" network."

at home is safe Wifi, or not? If is safe, use this:

  • at home you must disable VPN. For this add event with Wi-Fi sensor, SSID name at Home, Connection type=Nearby and activate profile which DISABLE VPN.

For other situations use this:

  • in cafeteria, train: you want to enable VPN automatically? If yes, add event with Wi-Fi sensor, SSID name at Home, Connection type="Not nearby" and activate profile which enable VPN.

"safe" Wi-Fi detection is not implemented in PPP. But is possible to add it. :-)

Which Wi-Fi is safe by you? Which not requires password?
Is possible to detect capability WPA, WEP, WPS. These Wi-Fi SSIDs requires password.

You have list of non-safe SSIDs? By me not, because in train is changed train by train, also for cafeteria, ...

No, it is "save to connect without VPN"-List.

I will read/try you other ideas tomorrow.

Then it is your subjective list. Some WPA, WEP, WPS SSIDs my be subective non-safe by you.
Android is "computer", is not possible to mark any SSID as non-safe, because in Wi-Fi capabilities is not flag for this.

Yes, it is a completely subjective list. I used the term "safe" in the meaning that I know who is providing the network, how the "logging" is and if it is an open/shared network with many strangers without knowing about the isolation between them.

So my list would most likely contain my private network and a few friends. But since I am using public hotspots, these are the ones I want to have automatic VPN connection IF I am connected/connecting.

Again, I don't know if PPP is intended for this use case. Since the VPN Profile would be running more or less separated from the profiles for setting ringer, etc. for specific locations.

  • For cafeteria you can use "Location sensor" and you must add each cafeteria location in it.
  • For train you must using "Wi-Fi sensor" and have list of SSID names in all used trains. Because location in train will change, when is in motion.

Another solution not exists.