带阿里标识的版本
This commit is contained in:
@@ -44,12 +44,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
@property (nonatomic, copy) NSString *aesSecretKey;
|
||||
@property (nonatomic, assign) BOOL hasConfiguredAccount;
|
||||
|
||||
// 每次访问的签名有效期,SDK内部定死,当前不暴露设置接口,有效期定为10分钟。
|
||||
// 每次访问的签名有效期,SDK内部定死,当前不暴露设置接口,有效期定为10分钟<EFBFBD><EFBFBD>?
|
||||
@property (nonatomic, assign) NSUInteger authTimeoutInterval;
|
||||
|
||||
@property (nonatomic, copy) NSDictionary<NSString *, NSString *> *presetSdnsParamsDict;
|
||||
|
||||
// scheduleCenter 已在 HttpdnsService_Internal.h 暴露,避免重复声明
|
||||
// scheduleCenter 已在 HttpdnsService_Internal.h 暴露,避免重复声<EFBFBD><EFBFBD>?
|
||||
|
||||
@end
|
||||
|
||||
@@ -58,9 +58,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
+ (void)initialize {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
asyncTaskConcurrentQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.asyncTask", DISPATCH_QUEUE_CONCURRENT);
|
||||
asyncTaskConcurrentQueue = dispatch_queue_create("com.Trust.sdk.httpdns.asyncTask", DISPATCH_QUEUE_CONCURRENT);
|
||||
httpdnsServiceInstances = [NSMutableDictionary dictionary];
|
||||
httpdnsServiceInstancesQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.serviceRegistry", DISPATCH_QUEUE_SERIAL);
|
||||
httpdnsServiceInstancesQueue = dispatch_queue_create("com.Trust.sdk.httpdns.serviceRegistry", DISPATCH_QUEUE_SERIAL);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
self.requestManager = [[HttpdnsRequestManager alloc] initWithAccountId:accountID ownerService:self];
|
||||
|
||||
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
|
||||
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kAlicloudHttpdnsRegionKey, (long)accountID];
|
||||
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kTrustHttpdnsRegionKey, (long)accountID];
|
||||
NSString *cachedRegion = [userDefault objectForKey:regionKey];
|
||||
|
||||
HttpdnsScheduleCenter *scheduleCenter = [[HttpdnsScheduleCenter alloc] initWithAccountId:accountID];
|
||||
@@ -235,7 +235,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
|
||||
- (void)setRegion:(NSString *)region {
|
||||
if ([HttpdnsUtil isEmptyString:region]) {
|
||||
region = ALICLOUD_HTTPDNS_DEFAULT_REGION_KEY;
|
||||
region = Trust_HTTPDNS_DEFAULT_REGION_KEY;
|
||||
}
|
||||
|
||||
if (![[HttpdnsRegionConfigLoader getAvailableRegionList] containsObject:region]) {
|
||||
@@ -244,7 +244,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
}
|
||||
|
||||
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
|
||||
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kAlicloudHttpdnsRegionKey, (long)self.accountID];
|
||||
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kTrustHttpdnsRegionKey, (long)self.accountID];
|
||||
NSString *oldRegion = [userDefault objectForKey:regionKey];
|
||||
if (![region isEqualToString:oldRegion]) {
|
||||
[userDefault setObject:region forKey:regionKey];
|
||||
@@ -262,16 +262,16 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
}
|
||||
|
||||
|
||||
- (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(AlicloudHttpDNS_IPType)ipType {
|
||||
- (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(TrustHttpDNS_IPType)ipType {
|
||||
HttpdnsQueryIPType ipQueryType;
|
||||
switch (ipType) {
|
||||
case AlicloudHttpDNS_IPTypeV4:
|
||||
case TrustHttpDNS_IPTypeV4:
|
||||
ipQueryType = HttpdnsQueryIPTypeIpv4;
|
||||
break;
|
||||
case AlicloudHttpDNS_IPTypeV6:
|
||||
case TrustHttpDNS_IPTypeV6:
|
||||
ipQueryType = HttpdnsQueryIPTypeIpv6;
|
||||
break;
|
||||
case AlicloudHttpDNS_IPTypeV64:
|
||||
case TrustHttpDNS_IPTypeV64:
|
||||
ipQueryType = HttpdnsQueryIPTypeIpv4 | HttpdnsQueryIPTypeIpv6;
|
||||
break;
|
||||
default:
|
||||
@@ -284,7 +284,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
|
||||
- (void)setPreResolveHosts:(NSArray *)hosts byIPType:(HttpdnsQueryIPType)ipType {
|
||||
// 初始化过程包含了region配置更新流程,region切换会导致缓存清空,立即做预解析可能是没有意义的
|
||||
// 这是sdk接口设计的历史问题,目前没有太好办法,这里0.5秒之后再发预解析请求
|
||||
// 这是sdk接口设计的历史问题,目前没有太好办法,这<EFBFBD><EFBFBD>?.5秒之后再发预解析请求
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), asyncTaskConcurrentQueue, ^{
|
||||
[self->_requestManager preResolveHosts:hosts queryType:ipType];
|
||||
});
|
||||
@@ -320,20 +320,20 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
}
|
||||
|
||||
- (void)setIPv6Enabled:(BOOL)enable {
|
||||
// 默认都支持
|
||||
// 默认都支<EFBFBD><EFBFBD>?
|
||||
}
|
||||
|
||||
- (void)enableNetworkInfo:(BOOL)enable {
|
||||
// 弃用此接口
|
||||
// 弃用此接<EFBFBD><EFBFBD>?
|
||||
}
|
||||
|
||||
- (void)setReadNetworkInfoEnabled:(BOOL)enable {
|
||||
// 弃用此接口
|
||||
// 弃用此接<EFBFBD><EFBFBD>?
|
||||
}
|
||||
|
||||
- (void)enableCustomIPRank:(BOOL)enable {
|
||||
// 不再生效,保留接口
|
||||
// 是否开启自定义IP排序,由是否设置IPRankingDatasource和IPRankingDatasource中是否能根据host找到对应的IP来决定
|
||||
// 不再生效,保留接<EFBFBD><EFBFBD>?
|
||||
// 是否开启自定义IP排序,由是否设置IPRankingDatasource和IPRankingDatasource中是否能根据host找到对应的IP来决<EFBFBD><EFBFBD>?
|
||||
}
|
||||
|
||||
- (NSString *)getSessionId {
|
||||
@@ -357,7 +357,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
|
||||
- (nullable HttpdnsResult *)resolveHostSync:(HttpdnsRequest *)request {
|
||||
if ([NSThread isMainThread]) {
|
||||
// 主线程做一个防御
|
||||
// 主线程做一个防<EFBFBD><EFBFBD>?
|
||||
return [self resolveHostSyncNonBlocking:request];
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
if (specifiedQueryIpType == HttpdnsQueryIPTypeAuto) {
|
||||
HttpdnsIPStackType stackType = [[HttpdnsIpStackDetector sharedInstance] currentIpStack];
|
||||
switch (stackType) {
|
||||
// 双栈和ipv6only,两个类型都要请求
|
||||
// 双栈和ipv6only,两个类型都要请<EFBFBD><EFBFBD>?
|
||||
// 虽然判断是ipv6only,但现实中只有实验室才会有这种情况,考虑判断网络协议栈是有误判可能的,权衡之下,还是应该请求ipv4
|
||||
// 如果用户是在明确的实验室环境中做测试,他应该直接指定请求type为ipv6
|
||||
case kHttpdnsIpDual:
|
||||
@@ -470,7 +470,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
}
|
||||
}
|
||||
|
||||
// 否则就按指定类型来解析
|
||||
// 否则就按指定类型来解<EFBFBD><EFBFBD>?
|
||||
return specifiedQueryIpType;
|
||||
}
|
||||
|
||||
@@ -681,7 +681,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
}
|
||||
//需要检查是不是在主线程,如果是主线程,保持异步逻辑
|
||||
if ([NSThread isMainThread]) {
|
||||
//如果是主线程,仍然使用异步的方式,即先查询缓存,如果没有,则发送异步请求
|
||||
//如果是主线程,仍然使用异步的方式,即先查询缓存,如果没有,则发送异步请<EFBFBD><EFBFBD>?
|
||||
HttpdnsRequest *request = [[HttpdnsRequest alloc] initWithHost:host queryIpType:HttpdnsQueryIPTypeIpv4];
|
||||
[self attachAccountInfoToRequest:request];
|
||||
[request becomeNonBlockingRequest];
|
||||
@@ -839,7 +839,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
}
|
||||
|
||||
if ([NSThread isMainThread]) {
|
||||
// 如果是主线程,仍然使用异步的方式,即先查询缓存,如果没有,则发送异步请求
|
||||
// 如果是主线程,仍然使用异步的方式,即先查询缓存,如果没有,则发送异步请<EFBFBD><EFBFBD>?
|
||||
HttpdnsRequest *request = [[HttpdnsRequest alloc] initWithHost:host queryIpType:HttpdnsQueryIPTypeIpv6];
|
||||
[self attachAccountInfoToRequest:request];
|
||||
[request becomeNonBlockingRequest];
|
||||
@@ -888,9 +888,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
if ([HttpdnsUtil isAnIP:host]) {
|
||||
HttpdnsLogDebug("The host is just an IP: %@", host);
|
||||
if ([HttpdnsUtil isIPv4Address:host]) {
|
||||
return @{ALICLOUDHDNS_IPV4: @[host?:@""]};
|
||||
return @{TrustHDNS_IPV4: @[host?:@""]};
|
||||
} else if ([HttpdnsUtil isIPv6Address:host]) {
|
||||
return @{ALICLOUDHDNS_IPV6: @[host?:@""]};
|
||||
return @{TrustHDNS_IPV6: @[host?:@""]};
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -909,10 +909,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
NSArray *ip6s = [hostObject getV6IpStrings];
|
||||
NSMutableDictionary *resultMDic = [NSMutableDictionary dictionary];
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
|
||||
[resultMDic setObject:ip4s forKey:ALICLOUDHDNS_IPV4];
|
||||
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
|
||||
}
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
|
||||
[resultMDic setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
|
||||
[resultMDic setObject:ip6s forKey:TrustHDNS_IPV6];
|
||||
}
|
||||
NSLog(@"getIPv4_v6ByHostAsync result is %@", resultMDic);
|
||||
return resultMDic;
|
||||
@@ -935,9 +935,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
if ([HttpdnsUtil isAnIP:host]) {
|
||||
HttpdnsLogDebug("The host is just an IP: %@", host);
|
||||
if ([HttpdnsUtil isIPv4Address:host]) {
|
||||
return @{ALICLOUDHDNS_IPV4: @[host?:@""]};
|
||||
return @{TrustHDNS_IPV4: @[host?:@""]};
|
||||
} else if ([HttpdnsUtil isIPv6Address:host]) {
|
||||
return @{ALICLOUDHDNS_IPV6: @[host?:@""]};
|
||||
return @{TrustHDNS_IPV6: @[host?:@""]};
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -957,10 +957,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
NSMutableDictionary *httpdnsResult = [NSMutableDictionary dictionary];
|
||||
NSLog(@"getHttpDnsResultHostAsync result is %@", httpdnsResult);
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
|
||||
[httpdnsResult setObject:ip4s forKey:ALICLOUDHDNS_IPV4];
|
||||
[httpdnsResult setObject:ip4s forKey:TrustHDNS_IPV4];
|
||||
}
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
|
||||
[httpdnsResult setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
|
||||
[httpdnsResult setObject:ip6s forKey:TrustHDNS_IPV6];
|
||||
}
|
||||
return httpdnsResult;
|
||||
}
|
||||
@@ -981,9 +981,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
if ([HttpdnsUtil isAnIP:host]) {
|
||||
HttpdnsLogDebug("The host is just an IP: %@", host);
|
||||
if ([HttpdnsUtil isIPv4Address:host]) {
|
||||
return @{ALICLOUDHDNS_IPV4: @[host?:@""]};
|
||||
return @{TrustHDNS_IPV4: @[host?:@""]};
|
||||
} else if ([HttpdnsUtil isIPv6Address:host]) {
|
||||
return @{ALICLOUDHDNS_IPV6: @[host?:@""]};
|
||||
return @{TrustHDNS_IPV6: @[host?:@""]};
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@@ -1005,10 +1005,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
NSMutableDictionary *resultMDic = [NSMutableDictionary dictionary];
|
||||
NSLog(@"getIPv4_v6ByHostAsync result is %@", resultMDic);
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
|
||||
[resultMDic setObject:ip4s forKey:ALICLOUDHDNS_IPV4];
|
||||
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
|
||||
}
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
|
||||
[resultMDic setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
|
||||
[resultMDic setObject:ip6s forKey:TrustHDNS_IPV6];
|
||||
}
|
||||
return resultMDic;
|
||||
}
|
||||
@@ -1026,10 +1026,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
NSArray *ip6s = [hostObject getV6IpStrings];
|
||||
resultMDic = [NSMutableDictionary dictionary];
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
|
||||
[resultMDic setObject:ip4s forKey:ALICLOUDHDNS_IPV4];
|
||||
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
|
||||
}
|
||||
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
|
||||
[resultMDic setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
|
||||
[resultMDic setObject:ip6s forKey:TrustHDNS_IPV6];
|
||||
}
|
||||
NSLog(@"###### getHttpDnsResultHostSync result is %@", resultMDic);
|
||||
}
|
||||
@@ -1045,12 +1045,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
} else if (stackType == kHttpdnsIpv4Only) {
|
||||
NSArray* ipv4Ips = [self getIpsByHostAsync:host];
|
||||
if (ipv4Ips != nil) {
|
||||
[ipv4_ipv6 setObject:ipv4Ips forKey:ALICLOUDHDNS_IPV4];
|
||||
[ipv4_ipv6 setObject:ipv4Ips forKey:TrustHDNS_IPV4];
|
||||
}
|
||||
} else if (stackType == kHttpdnsIpv6Only) {
|
||||
NSArray* ipv6Ips = [self getIPv6sByHostAsync:host];
|
||||
if (ipv6Ips != nil) {
|
||||
[ipv4_ipv6 setObject:ipv6Ips forKey:ALICLOUDHDNS_IPV6];
|
||||
[ipv4_ipv6 setObject:ipv6Ips forKey:TrustHDNS_IPV6];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1065,12 +1065,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
} else if (stackType == kHttpdnsIpv4Only) {
|
||||
NSArray* ipv4IpList = [self getIPv4ListForHostAsync:host];
|
||||
if (ipv4IpList) {
|
||||
[httpdnsResult setObject:ipv4IpList forKey:ALICLOUDHDNS_IPV4];
|
||||
[httpdnsResult setObject:ipv4IpList forKey:TrustHDNS_IPV4];
|
||||
}
|
||||
} else if (stackType == kHttpdnsIpv6Only) {
|
||||
NSArray* ipv6List = [self getIPv6ListForHostAsync:host];
|
||||
if (ipv6List) {
|
||||
[httpdnsResult setObject:ipv6List forKey:ALICLOUDHDNS_IPV6];
|
||||
[httpdnsResult setObject:ipv6List forKey:TrustHDNS_IPV6];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1083,14 +1083,14 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
if (stackType == kHttpdnsIpv4Only) {
|
||||
NSArray* ipv4IpList = [self getIPv4ListForHostSync:host];
|
||||
if (ipv4IpList) {
|
||||
[httpdnsResult setObject:ipv4IpList forKey:ALICLOUDHDNS_IPV4];
|
||||
[httpdnsResult setObject:ipv4IpList forKey:TrustHDNS_IPV4];
|
||||
}
|
||||
} else if (stackType == kHttpdnsIpDual) {
|
||||
httpdnsResult = [[self getHttpDnsResultHostSync:host] mutableCopy];
|
||||
} else if (stackType == kHttpdnsIpv6Only) {
|
||||
NSArray* ipv6List = [self getIPv6ListForHostSync:host];
|
||||
if (ipv6List) {
|
||||
[httpdnsResult setObject:ipv6List forKey:ALICLOUDHDNS_IPV6];
|
||||
[httpdnsResult setObject:ipv6List forKey:TrustHDNS_IPV6];
|
||||
}
|
||||
}
|
||||
return httpdnsResult;
|
||||
|
||||
Reference in New Issue
Block a user