File tree Expand file tree Collapse file tree 1 file changed +34
-12
lines changed
Expand file tree Collapse file tree 1 file changed +34
-12
lines changed Original file line number Diff line number Diff line change 99import Foundation
1010
1111internal class ProxyChecker {
12- static func amIProxied( ) -> Bool {
13- guard let unmanagedSettings = CFNetworkCopySystemProxySettings ( ) else {
14- return false
12+ static func amIProxied( considerVPNConnectionAsProxy: Bool = false ) -> Bool {
13+ guard let unmanagedSettings = CFNetworkCopySystemProxySettings ( ) else {
14+ return false
15+ }
16+
17+ let settingsOptional = unmanagedSettings. takeRetainedValue ( ) as? [ String : Any ]
18+
19+ guard let settings = settingsOptional else {
20+ return false
21+ }
22+
23+ if ( considerVPNConnectionAsProxy) {
24+ if let scoped = settings [ " __SCOPED__ " ] as? [ String : Any ] {
25+ for interface in scoped. keys {
26+
27+ let names = [
28+ " tap " ,
29+ " tun " ,
30+ " ppp " ,
31+ " ipsec " ,
32+ " utun "
33+ ]
34+
35+ for name in names {
36+ if ( interface. contains ( name) ) {
37+ print ( " detected: \( interface) " )
38+ return true
39+ }
40+ }
41+ }
42+ }
43+ }
44+
45+ return ( settings. keys. contains ( " HTTPProxy " ) || settings. keys. contains ( " HTTPSProxy " ) )
1546 }
16-
17- let settingsOptional = unmanagedSettings. takeRetainedValue ( ) as? [ String : Any ]
18-
19- guard let settings = settingsOptional else {
20- return false
21- }
22-
23- return ( settings. keys. contains ( " HTTPProxy " ) || settings. keys. contains ( " HTTPSProxy " ) )
24- }
2547}
You can’t perform that action at this time.
0 commit comments