Skip to content

Commit

Permalink
feat:调整变量名称
Browse files Browse the repository at this point in the history
  • Loading branch information
erichuyuehu committed Jul 14, 2022
1 parent 11d1fc1 commit 3708b36
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions MSDKDns/CacheManager/MSDKDnsNetworkManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
});
Expand Down
4 changes: 2 additions & 2 deletions MSDKDns/CacheManager/MSDKDnsParamsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,5 +47,5 @@
- (NSArray *)msdkDnsGetPreResolvedDomains;
- (HttpDnsAddressType)msdkDnsGetAddressType;
- (NSArray *)msdkDnsGetKeepAliveDomains;
- (BOOL)msdkDnsGetOpenCacheRefresh;
- (BOOL)msdkDnsGetEnableKeepDomainsAlive;
@end
12 changes: 6 additions & 6 deletions MSDKDns/CacheManager/MSDKDnsParamsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -57,7 +57,7 @@ - (id) init {
_minutesBeforeSwitchToMain = 10;
_enableReport = NO;
_msdkAddressType = HttpDnsAddressTypeAuto;
_openCacheRefresh = YES;
_enableKeepDomainsAlive = YES;
}
return self;
}
Expand Down Expand Up @@ -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;
});
}

Expand Down Expand Up @@ -250,8 +250,8 @@ - (NSArray *)msdkDnsGetKeepAliveDomains {
return _keepAliveDomains;
}

- (BOOL)msdkDnsGetOpenCacheRefresh {
return _openCacheRefresh;
- (BOOL)msdkDnsGetEnableKeepDomainsAlive {
return _enableKeepDomainsAlive;
}


Expand Down
2 changes: 1 addition & 1 deletion MSDKDns/MSDKDns.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ typedef struct DnsConfigStruct {
/**
* 设置开启和关闭缓存启停功能,默认开启
*/
- (void) WGSetSetOpenCacheRefresh: (BOOL)openCacheRefresh;
- (void) WGSetEnableKeepDomainsAlive: (BOOL)enableKeepDomainsAlive;

#pragma mark - 域名解析接口,按需调用
/**
Expand Down
4 changes: 2 additions & 2 deletions MSDKDns/MSDKDns.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions MSDKDns/MSDKDnsService.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ - (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) {
// NSLog(@"domain = %@", domain);
// NSLog(@"domainInfo = %@", domainInfo);

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

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

Expand Down Expand Up @@ -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];
}
Expand Down

0 comments on commit 3708b36

Please sign in to comment.