Skip to content

Commit

Permalink
feat:增加ipv4和ipv6的判断逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
erichuyuehu committed Jul 7, 2022
1 parent fd5d35b commit bd548e0
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions MSDKDns/MSDKDnsService.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,33 @@ - (void)resolver:(MSDKDnsResolver *)resolver didGetDomainInfo:(NSDictionary *)do

// 判断此次请求的域名中有多少属于保活域名,是则开启延时解析请求,自动刷新缓存
if (keepAliveDomains && domain && [keepAliveDomains containsObject:domain]) {
NSString *afterTime = domainInfo[domain][kTTL];

NSMutableString * afterTime = [[NSMutableString alloc] init];

if(resolver == self.httpDnsResolver_BOTH){
NSDictionary *domainResult = domainInfo[domain];
if (domainResult) {
NSDictionary *ipv4Value = [domainResult objectForKey:@"ipv4"];
NSDictionary *ipv6Value = [domainResult objectForKey:@"ipv6"];
if (ipv6Value) {
NSString *ttl = [ipv6Value objectForKey:kTTL];
afterTime = [[NSMutableString alloc]initWithString:ttl];
}
if (ipv4Value) {
NSString *ttl = [ipv4Value objectForKey:kTTL];
afterTime = [[NSMutableString alloc]initWithString:ttl];
}
}
}else{
NSDictionary *domainResult = domainInfo[domain];
if (domainResult) {
NSString *ttl = [domainResult objectForKey:kTTL];
afterTime = [[NSMutableString alloc]initWithString:ttl];
}
}

// NSLog(@"4444444延时更新请求等待,预计在%f秒后开始!请求域名为%@",afterTime.floatValue,domain);
if (!domainISOpenDelayDispatch[domain]) {
if (!domainISOpenDelayDispatch[domain] && afterTime) {
// 使用静态字典来记录该域名是否开启了一个延迟解析请求,如果已经开启则忽略,没有则立马开启一个
[[MSDKDnsManager shareInstance] msdkDnsAddDomainOpenDelayDispatch:domain];
MSDKDNSLOG(@"Start the delayed execution task, it is expected to start requesting the domain name %@ after %f seconds", domain, afterTime.floatValue);
Expand Down

0 comments on commit bd548e0

Please sign in to comment.