//需要导入ifadds头文件
//是否连接VPN
- (BOOL)isVPNConnected{
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
int success = 0;
//检索当前接口,0 成功
success = getifaddrs(&interfaces);
if (success == 0) {
//循环链表接口
temp_addr = interfaces;
while (temp_addr != NULL) {
NSString *string = [NSString stringWithFormat:@"%s" , temp_addr->ifa_name];
if ([string rangeOfString:@"tap"].location != NSNotFound ||
[string rangeOfString:@"tun"].location != NSNotFound ||
[string rangeOfString:@"ppp"].location != NSNotFound){
return YES;
}
temp_addr = temp_addr->ifa_next;
}
}
// Free memory
freeifaddrs(interfaces);
[inspirationDetailVC.view myMBProgressShowView:MBLocalizedString(KNetworkFailed)];
return NO;
struct ifaddrs *interfaces = NULL;
struct ifaddrs *temp_addr = NULL;
int success = 0;
//检索当前接口,0 成功
success = getifaddrs(&interfaces);
if (success == 0) {
//循环链表接口
temp_addr = interfaces;
while (temp_addr != NULL) {
NSString *string = [NSString stringWithFormat:@"%s" , temp_addr->ifa_name];
if ([string rangeOfString:@"tap"].location != NSNotFound ||
[string rangeOfString:@"tun"].location != NSNotFound ||
[string rangeOfString:@"ppp"].location != NSNotFound){
return YES;
}
temp_addr = temp_addr->ifa_next;
}
}
// Free memory
freeifaddrs(interfaces);
[inspirationDetailVC.view myMBProgressShowView:MBLocalizedString(KNetworkFailed)];
return NO;
}