Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if iphone/ipad connected to VPN via public wifi programmatically

We have an app wherein certain functionality needs to work only when the user is connected to a router associated with his account (we have some information about user accounts and home routers). However, it is possible for the user to set up a VPN connection to his home router via any public wifi/3g network. We want to block certain functionality if that is the case.

Any ideas as to how it can be detected using any of the existing iphone/ipad apis?

Thanks, Hetal

like image 653
Hetal Vora Avatar asked Apr 04 '11 15:04

Hetal Vora


2 Answers

There is a flag in the reachability API called kSCNetworkReachabilityFlagsTransientConnection. It is true when you are connected via a VPN and false if you are not connected via a VPN. We used this flag value to check for our conditions.

like image 199
Hetal Vora Avatar answered Oct 14 '22 11:10

Hetal Vora


There's no iOS API (public at least) that is going to give you information on whether you're running on a home router or public WiFi connection. You can only determine that you're on a WiFi connection vs. 3G. (for example, see the Reachability sample)

You might be able to do some sort of lookup based on the device's current IP address. You'd have to have each user register their router's IP address and have your application validate it before running, etc. But still, there'd be no guarantee that user's home router is secured. In other words, it could be just as wide open as a public WiFi.

like image 40
Ken Pespisa Avatar answered Oct 14 '22 12:10

Ken Pespisa