From 6e5d349835cb38a7abe65e0cef01d98f2d1c0a62 Mon Sep 17 00:00:00 2001 From: vastly Date: Mon, 14 Mar 2022 14:08:38 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=BC=98=E5=8C=96=E5=A4=9A?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MSDKDns/CacheManager/MSDKDnsManager.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MSDKDns/CacheManager/MSDKDnsManager.m b/MSDKDns/CacheManager/MSDKDnsManager.m index dd0f045..c5da2c8 100644 --- a/MSDKDns/CacheManager/MSDKDnsManager.m +++ b/MSDKDns/CacheManager/MSDKDnsManager.m @@ -668,8 +668,9 @@ - (BOOL) domianCache:(NSDictionary *)cache hit:(NSString *)domain { # pragma mark - servers - (NSString *)currentDnsServer { - if (self.serverIndex < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count]) { - return [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] objectAtIndex:self.serverIndex]; + int index = self.serverIndex; + if (index < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count]) { + return [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] objectAtIndex:index]; } return [[MSDKDnsParamsManager shareInstance] msdkDnsGetMDnsIp]; } @@ -680,7 +681,7 @@ - (void)switchDnsServer { } self.waitToSwitch = YES; dispatch_async([MSDKDnsInfoTool msdkdns_queue], ^{ - if (self.serverIndex < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count]) { + if (self.serverIndex < [[[MSDKDnsParamsManager shareInstance] msdkDnsGetServerIps] count] - 1) { self.serverIndex += 1; if (!self.firstFailTime) { self.firstFailTime = [NSDate date];