前言
我们常常需要知道本地VPN或者其他类型的VPN连接状态,通过是监听对应的通知进行处理
正文
- SBVPNConnectionChangedNotification
如果是VPN服务器超时、断网、鉴权失败或者自定义VPN(对接系统的VPN接口)等情况, 通常是不会触发这个SBVPNConnectionChangedNotification。
<!-- 因此需要监听其他进程的动态---CFUserNotificationCreate -->
因为连接失败系统总要和用户交互,这个就想起了hook CFUserNotification,因为Function CFUserNotificationCreate的功能是:
Creates a CFUserNotification object and displays its notification dialog on screen.
Creates a CFUserNotification object and displays its notification dialog on screen.
<!-- vpn 相关的进程: -->
<!-- 大部分的情况是处理 nesessionmanager、sb 就足够了-->
<string>nesessionmanager</string>
<string>racoon</string>
<string>configd</string>
<string>mDNSResponder</string>
<string>networkd</string>
<string>pppd</string>
NSBundle* references = [NSBundle bundleWithPath:@"/System/Library/PreferenceBundles/VPNPreferences.bundle"];
https://github.com/ichitaso/iOS-iphoneheaders/tree/master/iOS7.1.1/System/Library/PreferenceBundles
StoreServices.framework
- SSClientAccountStore.h
https://github.com/ichitaso/iOS-iphoneheaders/blob/be1e4073114a6572b34b171245a62186a732e561/iOS7.0.3/System/Library/PrivateFrameworks/StoreServices.framework/SSClientAccountStore.h
SSAccountStore
SpringBoard
- SBApplicationPlaceholderController
iOS-iphoneheaders/iOS8.3/System/Library/CoreServices/SpringBoard.app/SBApplicationPlaceholderController.h
iOS-iphoneheaders/iOS8.3/System/Library/CoreServices/SpringBoard.app/SBApplicationLibraryObserver.h
see also
/Users/devzkn/code/other/AFlexLoader-master/deploy
<!-- Depends: mobilesubstrate, preferenceloader (>= 2.2), applist (>= 1.5.11)
-->
preferenceloader、applist
void handleSystemPasscodeChange(CFNotificationCenterRef center,void *observer,CFStringRef name,const void *object,CFDictionaryRef userInfo) {
global_slfe = nil;
global_OnceUnlockSuccessfully = NO;
}
"AUTO_LOCK_NEVER"="自动锁定: 永不";
"AUTO_LOCK_MIN"="自动锁定: %d分钟";
"AUTO_LOCK_MINS"="自动锁定: %d分钟";
转载请注明:张坤楠的博客 > setupVPNActive
在操作过程或者文章有问题的话欢迎在 原文 里提问或指正。