From bd548e0bf4be27f34542ea689bd5f14576e29ae6 Mon Sep 17 00:00:00 2001 From: erichuyuehu Date: Thu, 7 Jul 2022 17:15:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0ipv4=E5=92=8Cipv6?= =?UTF-8?q?=E7=9A=84=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MSDKDns/MSDKDnsService.m | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/MSDKDns/MSDKDnsService.m b/MSDKDns/MSDKDnsService.m index 4a0fbbc..84c34a3 100644 --- a/MSDKDns/MSDKDnsService.m +++ b/MSDKDns/MSDKDnsService.m @@ -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);