ashleymills / Reachability.swift

Replacement for Apple's Reachability re-written in Swift with closures
MIT License
7.92k stars 943 forks source link

Is reachability works for checking private VPN connection? #255

Open pycoder-pjh opened 6 years ago

pycoder-pjh commented 6 years ago

i need to connect to VPN, in order to access my ios application. Is there a way reachability works . Also need to alert user on this.. Please help me team..

Thanks in advance..

nderkach commented 6 years ago

You can check isTransientConnectionFlagSet

MelkonYoussif commented 5 years ago

You can use the following code:

   private var isConnectedToVpn: Bool {
        if let settings = CFNetworkCopySystemProxySettings()?.takeRetainedValue() as? Dictionary<String, Any>,
            let scopes = settings["__SCOPED__"] as? [String:Any] {
            for (key, _) in scopes {
                    if key.contains("tap") || key.contains("tun") || key.contains("ppp") || key.contains("ipsec") || key.contains("ipsec0") {
                    return true
                }
            }
        }
        return false
    }
thahgr commented 5 years ago

You can use the following code:

Thanks for a working answer. Is there a licensing issue in using this code snippet ?

Thanks