BBAAPIReqUtils.h
3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// BBAAPIReqUtils.h
// BBAPods-APIRequest
//
// Created by liumuye on 2017/7/14.
// Copyright © 2017年 Baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
/// 当前接入网协议栈类型
typedef NS_OPTIONS(NSUInteger, BBAIpStack) {
BBAIpStackNone = 0, // 无
BBAIpStackV4 = 1 << 0, // IPv4 only
BBAIpStackV6 = 1 << 1, // IPv6 only
BBAIpStackDual = BBAIpStackV4 | BBAIpStackV6 // Dual(IPv4/IPv6)
};
@interface BBAPingResultInfo : NSObject
@property (nonatomic, assign) BOOL isSuccess;
@property (nonatomic, copy) NSString *detail;
@property (nonatomic, assign) NSInteger errCode;
@property (nonatomic, assign) CGFloat lossRate;
@property (nonatomic, copy) NSString *destination; // 所探测的域名或IP
@property (nonatomic, copy) NSString *interfaceName; // 网卡名称(指定网卡探测时不为空)
@end
@interface BBADnsResultInfo : NSObject
@property (nonatomic, assign) BOOL isSuccess;
@property (nonatomic, copy) NSString *detail;
@property (nonatomic, assign) NSInteger errCode;
@property (nonatomic, assign) NSInteger subErrCode;
@property (nonatomic, copy) NSArray <NSString *>* ipList;
@property (nonatomic, copy) NSString *domain; // 域名
@property (nonatomic, copy) NSString *localDns; // 所使用的局域网DNS服务器IP
@property (nonatomic, copy) NSString *interfaceName;// 网卡名称(指定网卡探测时不为空)
@end
@interface BBATcpResultInfo : NSObject
@property (nonatomic, assign) BOOL isSuccess;
@property (nonatomic, assign) NSInteger errCode;
@end
@interface BBATracertResultInfo : NSObject
@property (nonatomic, copy) NSString *detail;
@end
@interface BBAWiFiInfo : NSObject
@property (nonatomic, copy) NSString *ssid;
@property (nonatomic, copy) NSString *bssid;
@end
@interface BBAMobileInfo : NSObject
@property (nonatomic, copy) NSString *ispName;
@property (nonatomic, copy) NSString *ispCode;
@end
@interface BBAAPIReqUtils : NSObject
// 获取localIP
+(NSString*)getLocalIP;
+ (NSString *)getLocalIPv6;
// 通过域名获取IP
+(NSString *)getIPFromHost:(NSString *)host;
// 获取时间戳
+(NSString*)getTimeStamp;
// 获取文件MimeType
+ (NSString*)mimeTypeForPath:(NSURL*)pathURL;
// Ping检查
+ (BBAPingResultInfo *)pingCheck:(NSString *)hostOrIp;
+ (BBAPingResultInfo *)pingCheck:(NSString *)hostOrIp useInterface:(NSString *)interfaceName;
// tcp检查
+ (BBATcpResultInfo *)tcpCheck:(NSString *)ip port:(NSUInteger)port;
// ipStack
+ (BBAIpStack)ipStack;
// IPV6
+ (BOOL)isIPV6;
// DNS检查
+ (NSArray<NSString*>*)dnsServerIPV4;
+ (NSArray<NSString*>*)dnsServerIPV6;
+ (BBADnsResultInfo *)dnsCheck:(NSString *)host toDNSServer:(NSString *)dnsServer;
+ (BBADnsResultInfo *)dnsCheck:(NSString *)host toDNSServer:(NSString *)dnsServer useInterface:(NSString *)interfaceName;
// Tracert检查
+ (BBATracertResultInfo *)tracertCheck:(NSString*)hostOrIp;
// NetInfo
+ (NSString*)netInfo;
// NetType
+ (NSString *)netType;
// 当前是否是WiFi连接
+ (BOOL)isWifi;
// 获取WiFi网络详细信息
+ (BBAWiFiInfo *)wifiInfo;
// 当前是否是移动网络
+ (BOOL)isMobile;
// 获取移动网络详细信息
+ (BBAMobileInfo *)mobileInfo;
// 是否使用了VPN
+ (BOOL)isConnectedToVpn;
@end