This commit is contained in:
robin
2026-03-05 02:44:43 +08:00
parent 49021c7415
commit 49776c3d0a
41 changed files with 432 additions and 297 deletions

View File

@@ -58,9 +58,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
+ (void)initialize {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
asyncTaskConcurrentQueue = dispatch_queue_create("com.Trust.sdk.httpdns.asyncTask", DISPATCH_QUEUE_CONCURRENT);
asyncTaskConcurrentQueue = dispatch_queue_create("com.New.sdk.httpdns.asyncTask", DISPATCH_QUEUE_CONCURRENT);
httpdnsServiceInstances = [NSMutableDictionary dictionary];
httpdnsServiceInstancesQueue = dispatch_queue_create("com.Trust.sdk.httpdns.serviceRegistry", DISPATCH_QUEUE_SERIAL);
httpdnsServiceInstancesQueue = dispatch_queue_create("com.New.sdk.httpdns.serviceRegistry", DISPATCH_QUEUE_SERIAL);
});
}
@@ -168,7 +168,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
self.requestManager = [[HttpdnsRequestManager alloc] initWithAccountId:accountID ownerService:self];
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kTrustHttpdnsRegionKey, (long)accountID];
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kNewHttpdnsRegionKey, (long)accountID];
NSString *cachedRegion = [userDefault objectForKey:regionKey];
HttpdnsScheduleCenter *scheduleCenter = [[HttpdnsScheduleCenter alloc] initWithAccountId:accountID];
@@ -235,7 +235,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
- (void)setRegion:(NSString *)region {
if ([HttpdnsUtil isEmptyString:region]) {
region = Trust_HTTPDNS_DEFAULT_REGION_KEY;
region = NEW_HTTPDNS_DEFAULT_REGION_KEY;
}
if (![[HttpdnsRegionConfigLoader getAvailableRegionList] containsObject:region]) {
@@ -244,7 +244,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
}
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kTrustHttpdnsRegionKey, (long)self.accountID];
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kNewHttpdnsRegionKey, (long)self.accountID];
NSString *oldRegion = [userDefault objectForKey:regionKey];
if (![region isEqualToString:oldRegion]) {
[userDefault setObject:region forKey:regionKey];
@@ -262,16 +262,16 @@ static HttpDnsService *httpdnsSharedStubInstance;
}
- (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(TrustHttpDNS_IPType)ipType {
- (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(NewHttpDNS_IPType)ipType {
HttpdnsQueryIPType ipQueryType;
switch (ipType) {
case TrustHttpDNS_IPTypeV4:
case NewHttpDNS_IPTypeV4:
ipQueryType = HttpdnsQueryIPTypeIpv4;
break;
case TrustHttpDNS_IPTypeV6:
case NewHttpDNS_IPTypeV6:
ipQueryType = HttpdnsQueryIPTypeIpv6;
break;
case TrustHttpDNS_IPTypeV64:
case NewHttpDNS_IPTypeV64:
ipQueryType = HttpdnsQueryIPTypeIpv4 | HttpdnsQueryIPTypeIpv6;
break;
default:
@@ -888,9 +888,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
if ([HttpdnsUtil isAnIP:host]) {
HttpdnsLogDebug("The host is just an IP: %@", host);
if ([HttpdnsUtil isIPv4Address:host]) {
return @{TrustHDNS_IPV4: @[host?:@""]};
return @{NewHDNS_IPV4: @[host?:@""]};
} else if ([HttpdnsUtil isIPv6Address:host]) {
return @{TrustHDNS_IPV6: @[host?:@""]};
return @{NewHDNS_IPV6: @[host?:@""]};
}
return nil;
}
@@ -909,10 +909,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
NSArray *ip6s = [hostObject getV6IpStrings];
NSMutableDictionary *resultMDic = [NSMutableDictionary dictionary];
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
[resultMDic setObject:ip4s forKey:NewHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[resultMDic setObject:ip6s forKey:TrustHDNS_IPV6];
[resultMDic setObject:ip6s forKey:NewHDNS_IPV6];
}
NSLog(@"getIPv4_v6ByHostAsync result is %@", resultMDic);
return resultMDic;
@@ -935,9 +935,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
if ([HttpdnsUtil isAnIP:host]) {
HttpdnsLogDebug("The host is just an IP: %@", host);
if ([HttpdnsUtil isIPv4Address:host]) {
return @{TrustHDNS_IPV4: @[host?:@""]};
return @{NewHDNS_IPV4: @[host?:@""]};
} else if ([HttpdnsUtil isIPv6Address:host]) {
return @{TrustHDNS_IPV6: @[host?:@""]};
return @{NewHDNS_IPV6: @[host?:@""]};
}
return nil;
}
@@ -957,10 +957,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
NSMutableDictionary *httpdnsResult = [NSMutableDictionary dictionary];
NSLog(@"getHttpDnsResultHostAsync result is %@", httpdnsResult);
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
[httpdnsResult setObject:ip4s forKey:TrustHDNS_IPV4];
[httpdnsResult setObject:ip4s forKey:NewHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[httpdnsResult setObject:ip6s forKey:TrustHDNS_IPV6];
[httpdnsResult setObject:ip6s forKey:NewHDNS_IPV6];
}
return httpdnsResult;
}
@@ -981,9 +981,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
if ([HttpdnsUtil isAnIP:host]) {
HttpdnsLogDebug("The host is just an IP: %@", host);
if ([HttpdnsUtil isIPv4Address:host]) {
return @{TrustHDNS_IPV4: @[host?:@""]};
return @{NewHDNS_IPV4: @[host?:@""]};
} else if ([HttpdnsUtil isIPv6Address:host]) {
return @{TrustHDNS_IPV6: @[host?:@""]};
return @{NewHDNS_IPV6: @[host?:@""]};
}
return nil;
}
@@ -1005,10 +1005,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
NSMutableDictionary *resultMDic = [NSMutableDictionary dictionary];
NSLog(@"getIPv4_v6ByHostAsync result is %@", resultMDic);
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
[resultMDic setObject:ip4s forKey:NewHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[resultMDic setObject:ip6s forKey:TrustHDNS_IPV6];
[resultMDic setObject:ip6s forKey:NewHDNS_IPV6];
}
return resultMDic;
}
@@ -1026,10 +1026,10 @@ static HttpDnsService *httpdnsSharedStubInstance;
NSArray *ip6s = [hostObject getV6IpStrings];
resultMDic = [NSMutableDictionary dictionary];
if ([HttpdnsUtil isNotEmptyArray:ip4s]) {
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
[resultMDic setObject:ip4s forKey:NewHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[resultMDic setObject:ip6s forKey:TrustHDNS_IPV6];
[resultMDic setObject:ip6s forKey:NewHDNS_IPV6];
}
NSLog(@"###### getHttpDnsResultHostSync result is %@", resultMDic);
}
@@ -1045,12 +1045,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
} else if (stackType == kHttpdnsIpv4Only) {
NSArray* ipv4Ips = [self getIpsByHostAsync:host];
if (ipv4Ips != nil) {
[ipv4_ipv6 setObject:ipv4Ips forKey:TrustHDNS_IPV4];
[ipv4_ipv6 setObject:ipv4Ips forKey:NewHDNS_IPV4];
}
} else if (stackType == kHttpdnsIpv6Only) {
NSArray* ipv6Ips = [self getIPv6sByHostAsync:host];
if (ipv6Ips != nil) {
[ipv4_ipv6 setObject:ipv6Ips forKey:TrustHDNS_IPV6];
[ipv4_ipv6 setObject:ipv6Ips forKey:NewHDNS_IPV6];
}
}
@@ -1065,12 +1065,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
} else if (stackType == kHttpdnsIpv4Only) {
NSArray* ipv4IpList = [self getIPv4ListForHostAsync:host];
if (ipv4IpList) {
[httpdnsResult setObject:ipv4IpList forKey:TrustHDNS_IPV4];
[httpdnsResult setObject:ipv4IpList forKey:NewHDNS_IPV4];
}
} else if (stackType == kHttpdnsIpv6Only) {
NSArray* ipv6List = [self getIPv6ListForHostAsync:host];
if (ipv6List) {
[httpdnsResult setObject:ipv6List forKey:TrustHDNS_IPV6];
[httpdnsResult setObject:ipv6List forKey:NewHDNS_IPV6];
}
}
@@ -1083,14 +1083,14 @@ static HttpDnsService *httpdnsSharedStubInstance;
if (stackType == kHttpdnsIpv4Only) {
NSArray* ipv4IpList = [self getIPv4ListForHostSync:host];
if (ipv4IpList) {
[httpdnsResult setObject:ipv4IpList forKey:TrustHDNS_IPV4];
[httpdnsResult setObject:ipv4IpList forKey:NewHDNS_IPV4];
}
} else if (stackType == kHttpdnsIpDual) {
httpdnsResult = [[self getHttpDnsResultHostSync:host] mutableCopy];
} else if (stackType == kHttpdnsIpv6Only) {
NSArray* ipv6List = [self getIPv6ListForHostSync:host];
if (ipv6List) {
[httpdnsResult setObject:ipv6List forKey:TrustHDNS_IPV6];
[httpdnsResult setObject:ipv6List forKey:NewHDNS_IPV6];
}
}
return httpdnsResult;