From 3708b36d803001c2a76b8ef04ff391fe649e95ac Mon Sep 17 00:00:00 2001 From: erichuyuehu Date: Thu, 14 Jul 2022 16:52:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=B0=83=E6=95=B4=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MSDKDns/CacheManager/MSDKDnsNetworkManager.m | 4 ++-- MSDKDns/CacheManager/MSDKDnsParamsManager.h | 4 ++-- MSDKDns/CacheManager/MSDKDnsParamsManager.m | 12 ++++++------ MSDKDns/MSDKDns.h | 2 +- MSDKDns/MSDKDns.m | 4 ++-- MSDKDns/MSDKDnsService.m | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/MSDKDns/CacheManager/MSDKDnsNetworkManager.m b/MSDKDns/CacheManager/MSDKDnsNetworkManager.m index 78a5eb7..24d2693 100644 --- a/MSDKDns/CacheManager/MSDKDnsNetworkManager.m +++ b/MSDKDns/CacheManager/MSDKDnsNetworkManager.m @@ -284,8 +284,8 @@ - (void)getHostsByKeepAliveDomains{ //对保活域名发送解析请求 dispatch_async([MSDKDnsInfoTool msdkdns_queue], ^{ NSArray *keepAliveDomains = [[MSDKDnsParamsManager shareInstance] msdkDnsGetKeepAliveDomains]; - BOOL openCacheRefresh = [[MSDKDnsParamsManager shareInstance] msdkDnsGetOpenCacheRefresh]; - if (openCacheRefresh && keepAliveDomains && keepAliveDomains.count > 0) { + BOOL enableKeepDomainsAlive = [[MSDKDnsParamsManager shareInstance] msdkDnsGetEnableKeepDomainsAlive]; + if (enableKeepDomainsAlive && keepAliveDomains && keepAliveDomains.count > 0) { [[MSDKDnsManager shareInstance] refreshCacheDelay:keepAliveDomains clearDispatchTag:NO]; } }); diff --git a/MSDKDns/CacheManager/MSDKDnsParamsManager.h b/MSDKDns/CacheManager/MSDKDnsParamsManager.h index 1bb4700..9797163 100644 --- a/MSDKDns/CacheManager/MSDKDnsParamsManager.h +++ b/MSDKDns/CacheManager/MSDKDnsParamsManager.h @@ -28,7 +28,7 @@ - (void)msdkDnsSetPreResolvedDomains: (NSArray *)domains; - (void)msdkDnsSetAddressType: (HttpDnsAddressType)addressType; - (void)msdkDnsSetKeepAliveDomains: (NSArray *)domains; -- (void)msdkDnsSetOpenCacheRefresh: (BOOL)openCacheRefresh; +- (void)msdkDnsSetEnableKeepDomainsAlive: (BOOL)enableKeepDomainsAlive; - (NSString *) msdkDnsGetMDnsIp; - (NSString *) msdkDnsGetMOpenId; @@ -47,5 +47,5 @@ - (NSArray *)msdkDnsGetPreResolvedDomains; - (HttpDnsAddressType)msdkDnsGetAddressType; - (NSArray *)msdkDnsGetKeepAliveDomains; -- (BOOL)msdkDnsGetOpenCacheRefresh; +- (BOOL)msdkDnsGetEnableKeepDomainsAlive; @end diff --git a/MSDKDns/CacheManager/MSDKDnsParamsManager.m b/MSDKDns/CacheManager/MSDKDnsParamsManager.m index 44761a7..8fa6c75 100644 --- a/MSDKDns/CacheManager/MSDKDnsParamsManager.m +++ b/MSDKDns/CacheManager/MSDKDnsParamsManager.m @@ -33,7 +33,7 @@ @interface MSDKDnsParamsManager() @property (strong, nonatomic, readwrite) NSArray* preResolvedDomains; @property (assign, nonatomic, readwrite) HttpDnsAddressType msdkAddressType; @property (strong, nonatomic, readwrite) NSArray* keepAliveDomains; -@property (assign, nonatomic, readwrite) BOOL openCacheRefresh; +@property (assign, nonatomic, readwrite) BOOL enableKeepDomainsAlive; @end @@ -57,7 +57,7 @@ - (id) init { _minutesBeforeSwitchToMain = 10; _enableReport = NO; _msdkAddressType = HttpDnsAddressTypeAuto; - _openCacheRefresh = YES; + _enableKeepDomainsAlive = YES; } return self; } @@ -166,9 +166,9 @@ - (void)msdkDnsSetKeepAliveDomains: (NSArray *)domains { }); } -- (void)msdkDnsSetOpenCacheRefresh: (BOOL)openCacheRefresh { +- (void)msdkDnsSetEnableKeepDomainsAlive: (BOOL)enableKeepDomainsAlive { dispatch_async([MSDKDnsInfoTool msdkdns_queue], ^{ - self.openCacheRefresh = openCacheRefresh; + self.enableKeepDomainsAlive = enableKeepDomainsAlive; }); } @@ -250,8 +250,8 @@ - (NSArray *)msdkDnsGetKeepAliveDomains { return _keepAliveDomains; } -- (BOOL)msdkDnsGetOpenCacheRefresh { - return _openCacheRefresh; +- (BOOL)msdkDnsGetEnableKeepDomainsAlive { + return _enableKeepDomainsAlive; } diff --git a/MSDKDns/MSDKDns.h b/MSDKDns/MSDKDns.h index 993db00..cca84fb 100644 --- a/MSDKDns/MSDKDns.h +++ b/MSDKDns/MSDKDns.h @@ -87,7 +87,7 @@ typedef struct DnsConfigStruct { /** * 设置开启和关闭缓存启停功能,默认开启 */ -- (void) WGSetSetOpenCacheRefresh: (BOOL)openCacheRefresh; +- (void) WGSetEnableKeepDomainsAlive: (BOOL)enableKeepDomainsAlive; #pragma mark - 域名解析接口,按需调用 /** diff --git a/MSDKDns/MSDKDns.m b/MSDKDns/MSDKDns.m index f410e63..6609863 100644 --- a/MSDKDns/MSDKDns.m +++ b/MSDKDns/MSDKDns.m @@ -106,8 +106,8 @@ - (void) WGSetKeepAliveDomains:(NSArray *)domains { } } -- (void) WGSetSetOpenCacheRefresh: (BOOL)openCacheRefresh { - [[MSDKDnsParamsManager shareInstance] msdkDnsSetOpenCacheRefresh:openCacheRefresh]; +- (void) WGSetEnableKeepDomainsAlive: (BOOL)enableKeepDomainsAlive { + [[MSDKDnsParamsManager shareInstance] msdkDnsSetEnableKeepDomainsAlive:enableKeepDomainsAlive]; } - (void) WGSetHijackDomainArray:(NSArray *)hijackDomainArray { diff --git a/MSDKDns/MSDKDnsService.m b/MSDKDns/MSDKDnsService.m index 6bde49a..d946820 100644 --- a/MSDKDns/MSDKDnsService.m +++ b/MSDKDns/MSDKDnsService.m @@ -158,7 +158,7 @@ - (void)resolver:(MSDKDnsResolver *)resolver didGetDomainInfo:(NSDictionary *)do [self callBack:resolver Info:info]; if (resolver == self.httpDnsResolver_A || resolver == self.httpDnsResolver_4A || resolver == self.httpDnsResolver_BOTH) { NSArray *keepAliveDomains = [[MSDKDnsParamsManager shareInstance] msdkDnsGetKeepAliveDomains]; - BOOL openCacheRefresh = [[MSDKDnsParamsManager shareInstance] msdkDnsGetOpenCacheRefresh]; + BOOL enableKeepDomainsAlive = [[MSDKDnsParamsManager shareInstance] msdkDnsGetEnableKeepDomainsAlive]; // 获取延迟记录字典 NSMutableDictionary *domainISOpenDelayDispatch = [[MSDKDnsManager shareInstance] msdkDnsGetDomainISOpenDelayDispatch]; [domainInfo enumerateKeysAndObjectsUsingBlock:^(id _Nonnull domain, id _Nonnull obj, BOOL * _Nonnull stop) { @@ -166,7 +166,7 @@ - (void)resolver:(MSDKDnsResolver *)resolver didGetDomainInfo:(NSDictionary *)do // NSLog(@"domainInfo = %@", domainInfo); // 判断此次请求的域名中有多少属于保活域名,是则开启延时解析请求,自动刷新缓存 - if (openCacheRefresh && keepAliveDomains && domain && [keepAliveDomains containsObject:domain]) { + if (enableKeepDomainsAlive && keepAliveDomains && domain && [keepAliveDomains containsObject:domain]) { NSMutableString * afterTime = [[NSMutableString alloc] init]; @@ -199,8 +199,8 @@ - (void)resolver:(MSDKDnsResolver *)resolver didGetDomainInfo:(NSDictionary *)do MSDKDNSLOG(@"Start the delayed execution task, it is expected to start requesting the domain name %@ after %f seconds", domain, afterTime.floatValue); dispatch_after(dispatch_time(DISPATCH_TIME_NOW,afterTime.floatValue* NSEC_PER_SEC), [MSDKDnsInfoTool msdkdns_queue], ^{ // NSLog(@"延时更新请求开始!请求域名为%@",domain); - BOOL openCacheRefresh = [[MSDKDnsParamsManager shareInstance] msdkDnsGetOpenCacheRefresh]; - if (openCacheRefresh) { + BOOL enableKeepDomainsAlive = [[MSDKDnsParamsManager shareInstance] msdkDnsGetEnableKeepDomainsAlive]; + if (enableKeepDomainsAlive) { MSDKDNSLOG(@"The cache update request start! request domain:%@",domain); [[MSDKDnsManager shareInstance] refreshCacheDelay:@[domain] clearDispatchTag:YES]; }