Skip to content

Instantly share code, notes, and snippets.

View PramodJoshi's full-sized avatar

Pramod Joshi PramodJoshi

  • University of Illinois
  • Champaign, IL
View GitHub Profile
@PramodJoshi
PramodJoshi / Utils.swift
Last active July 17, 2024 03:16
Check VPN connection on iOS devices - Swift 3/4
func isVPNConnected() -> Bool {
let cfDict = CFNetworkCopySystemProxySettings()
let nsDict = cfDict!.takeRetainedValue() as NSDictionary
let keys = nsDict["__SCOPED__"] as! NSDictionary
for key: String in keys.allKeys as! [String] {
if (key == "tap" || key == "tun" || key == "ppp" || key == "ipsec" || key == "ipsec0") {
return true
}
}