带阿里标识的版本

This commit is contained in:
robin
2026-02-28 18:55:33 +08:00
parent 150799f41d
commit 5d0b7c7e91
477 changed files with 10813 additions and 4044 deletions

View File

@@ -19,12 +19,12 @@
#import <Foundation/Foundation.h>
#import <AlicloudHTTPDNS/HttpdnsLog.h>
#import <AlicloudHTTPDNS/HttpdnsPublicConstant.h>
#import <AlicloudHTTPDNS/HttpdnsService.h>
#import <AlicloudHTTPDNS/HttpdnsRequest.h>
#import <AlicloudHTTPDNS/HttpDnsResult.h>
#import <AlicloudHTTPDNS/HttpdnsEdgeService.h>
#import <AlicloudHTTPDNS/HttpdnsLoggerProtocol.h>
#import <AlicloudHTTPDNS/HttpdnsDegradationDelegate.h>
#import <AlicloudHTTPDNS/HttpdnsIpStackDetector.h>
#import <TrustHTTPDNS/HttpdnsLog.h>
#import <TrustHTTPDNS/HttpdnsPublicConstant.h>
#import <TrustHTTPDNS/HttpdnsService.h>
#import <TrustHTTPDNS/HttpdnsRequest.h>
#import <TrustHTTPDNS/HttpDnsResult.h>
#import <TrustHTTPDNS/HttpdnsEdgeService.h>
#import <TrustHTTPDNS/HttpdnsLoggerProtocol.h>
#import <TrustHTTPDNS/HttpdnsDegradationDelegate.h>
#import <TrustHTTPDNS/HttpdnsIpStackDetector.h>

View File

@@ -1,9 +1,9 @@
//
// HttpdnsInternalConstant.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2025/03/10.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#ifndef HTTPDNS_INTERNAL_CONSTANT_H
@@ -19,42 +19,42 @@ static const int HTTPDNS_DEFAULT_REQUEST_TIMEOUT_INTERVAL = 3;
static const NSUInteger HTTPDNS_DEFAULT_AUTH_TIMEOUT_INTERVAL = 10 * 60;
static NSString *const ALICLOUD_HTTPDNS_VALID_SERVER_CERTIFICATE_IP = @"203.107.1.1";
static NSString *const Trust_HTTPDNS_VALID_SERVER_CERTIFICATE_IP = @"203.107.1.1";
// 在iOS14和iOS16网络信息的获取权限受到越来越紧的限
// 在iOS14和iOS16网络信息的获取权限受到越来越紧的限<EFBFBD><EFBFBD>?
// 除非用户主动声明需要相关entitlement不然只能拿到空信息
// 考虑大多数用户并不会申请这些权限,我们放弃针对细节的网络信息做缓存粒度隔
// 出于兼容性考虑网络运营商只有default一种类
// 考虑大多数用户并不会申请这些权限,我们放弃针对细节的网络信息做缓存粒度隔<EFBFBD><EFBFBD>?
// 出于兼容性考虑网络运营商只有default一种类<EFBFBD><EFBFBD>?
#define HTTPDNS_DEFAULT_NETWORK_CARRIER_NAME @"default"
// 调度地址示例http://106.11.90.200/sc/httpdns_config?account_id=153519&platform=ios&sdk_version=1.6.1
static NSString *const ALICLOUD_HTTPDNS_SCHEDULE_CENTER_REQUEST_HOST = @"httpdns-sc.aliyuncs.com";
static NSString *const Trust_HTTPDNS_SCHEDULE_CENTER_REQUEST_HOST = @"httpdns-sc.TrustAPPcs.com";
static NSString *const ALICLOUD_HTTPDNS_ERROR_MESSAGE_KEY = @"ErrorMessage";
static NSString *const Trust_HTTPDNS_ERROR_MESSAGE_KEY = @"ErrorMessage";
static NSString *const kAlicloudHttpdnsRegionConfigV4HostKey = @"service_ip";
static NSString *const kAlicloudHttpdnsRegionConfigV6HostKey = @"service_ipv6";
static NSString *const kTrustHttpdnsRegionConfigV4HostKey = @"service_ip";
static NSString *const kTrustHttpdnsRegionConfigV6HostKey = @"service_ipv6";
static NSString *const kAlicloudHttpdnsRegionKey = @"HttpdnsRegion";
static NSString *const kTrustHttpdnsRegionKey = @"HttpdnsRegion";
#define SECONDS_OF_ONE_YEAR 365 * 24 * 60 * 60
static NSString *const ALICLOUD_HTTPDNS_ERROR_DOMAIN = @"HttpdnsErrorDomain";
static NSString *const Trust_HTTPDNS_ERROR_DOMAIN = @"HttpdnsErrorDomain";
static NSInteger const ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE = 10003;
static NSInteger const ALICLOUD_HTTPDNS_HTTP_COMMON_ERROR_CODE = 10004;
static NSInteger const Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE = 10003;
static NSInteger const Trust_HTTPDNS_HTTP_COMMON_ERROR_CODE = 10004;
static NSInteger const ALICLOUD_HTTPDNS_HTTPS_TIMEOUT_ERROR_CODE = 10005;
static NSInteger const ALICLOUD_HTTPDNS_HTTP_TIMEOUT_ERROR_CODE = 10006;
static NSInteger const ALICLOUD_HTTPDNS_HTTP_OPEN_STREAM_ERROR_CODE = 10007;
static NSInteger const ALICLOUD_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE = 10008;
static NSInteger const Trust_HTTPDNS_HTTPS_TIMEOUT_ERROR_CODE = 10005;
static NSInteger const Trust_HTTPDNS_HTTP_TIMEOUT_ERROR_CODE = 10006;
static NSInteger const Trust_HTTPDNS_HTTP_OPEN_STREAM_ERROR_CODE = 10007;
static NSInteger const Trust_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE = 10008;
static NSInteger const ALICLOUD_HTTP_UNSUPPORTED_STATUS_CODE = 10013;
static NSInteger const ALICLOUD_HTTP_PARSE_JSON_FAILED = 10014;
static NSInteger const Trust_HTTP_UNSUPPORTED_STATUS_CODE = 10013;
static NSInteger const Trust_HTTP_PARSE_JSON_FAILED = 10014;
// 加密错误
static NSInteger const ALICLOUD_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE = 10021;
static NSInteger const ALICLOUD_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE = 10022;
static NSInteger const ALICLOUD_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE = 10023;
// 加密错误<EFBFBD><EFBFBD>?
static NSInteger const Trust_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE = 10021;
static NSInteger const Trust_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE = 10022;
static NSInteger const Trust_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE = 10023;
#endif

View File

@@ -1,9 +1,9 @@
//
// HttpdnsPublicConstant.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/6/16.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#ifndef PublicConstant_h
@@ -11,11 +11,11 @@
static NSString *const HTTPDNS_IOS_SDK_VERSION = @"1.0.0";
#define ALICLOUD_HTTPDNS_DEFAULT_REGION_KEY @"cn"
#define ALICLOUD_HTTPDNS_HONGKONG_REGION_KEY @"hk"
#define ALICLOUD_HTTPDNS_SINGAPORE_REGION_KEY @"sg"
#define ALICLOUD_HTTPDNS_GERMANY_REGION_KEY @"de"
#define ALICLOUD_HTTPDNS_AMERICA_REGION_KEY @"us"
#define Trust_HTTPDNS_DEFAULT_REGION_KEY @"cn"
#define Trust_HTTPDNS_HONGKONG_REGION_KEY @"hk"
#define Trust_HTTPDNS_SINGAPORE_REGION_KEY @"sg"
#define Trust_HTTPDNS_GERMANY_REGION_KEY @"de"
#define Trust_HTTPDNS_AMERICA_REGION_KEY @"us"
#endif /* PublicConstant_h */

View File

@@ -1,9 +1,9 @@
//
// HttpdnsRegionConfigLoader.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/6/16.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@@ -1,20 +1,20 @@
//
// HttpdnsRegionConfigLoader.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/6/16.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import "HttpdnsRegionConfigLoader.h"
#import "HttpdnsPublicConstant.h"
static NSString *const kServiceV4Key = @"ALICLOUD_HTTPDNS_SERVICE_HOST_V4_KEY";
static NSString *const kUpdateV4FallbackHostKey = @"ALICLOUD_HTTPDNS_UPDATE_HOST_V4_KEY";
static NSString *const kServiceV6Key = @"ALICLOUD_HTTPDNS_SERVICE_HOST_V6_KEY";
static NSString *const kUpdateV6FallbackHostKey = @"ALICLOUD_HTTPDNS_UPDATE_HOST_V6_KEY";
static NSString *const kServiceV4Key = @"Trust_HTTPDNS_SERVICE_HOST_V4_KEY";
static NSString *const kUpdateV4FallbackHostKey = @"Trust_HTTPDNS_UPDATE_HOST_V4_KEY";
static NSString *const kServiceV6Key = @"Trust_HTTPDNS_SERVICE_HOST_V6_KEY";
static NSString *const kUpdateV6FallbackHostKey = @"Trust_HTTPDNS_UPDATE_HOST_V6_KEY";
static NSArray<NSString *> *ALICLOUD_HTTPDNS_AVAILABLE_REGION_LIST = nil;
static NSArray<NSString *> *Trust_HTTPDNS_AVAILABLE_REGION_LIST = nil;
@interface HttpdnsRegionConfigLoader ()
@@ -25,12 +25,12 @@ static NSArray<NSString *> *ALICLOUD_HTTPDNS_AVAILABLE_REGION_LIST = nil;
@implementation HttpdnsRegionConfigLoader
+ (void)initialize {
ALICLOUD_HTTPDNS_AVAILABLE_REGION_LIST = @[
ALICLOUD_HTTPDNS_DEFAULT_REGION_KEY,
ALICLOUD_HTTPDNS_HONGKONG_REGION_KEY,
ALICLOUD_HTTPDNS_SINGAPORE_REGION_KEY,
ALICLOUD_HTTPDNS_GERMANY_REGION_KEY,
ALICLOUD_HTTPDNS_AMERICA_REGION_KEY
Trust_HTTPDNS_AVAILABLE_REGION_LIST = @[
Trust_HTTPDNS_DEFAULT_REGION_KEY,
Trust_HTTPDNS_HONGKONG_REGION_KEY,
Trust_HTTPDNS_SINGAPORE_REGION_KEY,
Trust_HTTPDNS_GERMANY_REGION_KEY,
Trust_HTTPDNS_AMERICA_REGION_KEY
];
}
@@ -51,40 +51,40 @@ static NSArray<NSString *> *ALICLOUD_HTTPDNS_AVAILABLE_REGION_LIST = nil;
}
+ (NSArray<NSString *> *)getAvailableRegionList {
return ALICLOUD_HTTPDNS_AVAILABLE_REGION_LIST;
return Trust_HTTPDNS_AVAILABLE_REGION_LIST;
}
- (void)loadRegionConfig {
self.regionConfig = @{
ALICLOUD_HTTPDNS_DEFAULT_REGION_KEY: @{
Trust_HTTPDNS_DEFAULT_REGION_KEY: @{
kServiceV4Key: @[@"203.107.1.1", @"203.107.1.97", @"203.107.1.100", @"203.119.238.240", @"106.11.25.239", @"59.82.99.47"],
kUpdateV4FallbackHostKey: @[@"resolvers-cn.httpdns.aliyuncs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-cn.httpdns.TrustAPPcs.com"],
kServiceV6Key: @[@"2401:b180:7001::31d", @"2401:b180:2000:30::1c", @"2401:b180:2000:20::10", @"2401:b180:2000:30::1c"],
kUpdateV6FallbackHostKey: @[@"resolvers-cn.httpdns.aliyuncs.com"]
kUpdateV6FallbackHostKey: @[@"resolvers-cn.httpdns.TrustAPPcs.com"]
},
ALICLOUD_HTTPDNS_HONGKONG_REGION_KEY: @{
Trust_HTTPDNS_HONGKONG_REGION_KEY: @{
kServiceV4Key: @[@"47.56.234.194", @"47.56.119.115"],
kUpdateV4FallbackHostKey: @[@"resolvers-hk.httpdns.aliyuncs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-hk.httpdns.TrustAPPcs.com"],
kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"],
kUpdateV6FallbackHostKey: @[@"resolvers-hk.httpdns.aliyuncs.com"]
kUpdateV6FallbackHostKey: @[@"resolvers-hk.httpdns.TrustAPPcs.com"]
},
ALICLOUD_HTTPDNS_SINGAPORE_REGION_KEY: @{
Trust_HTTPDNS_SINGAPORE_REGION_KEY: @{
kServiceV4Key: @[@"161.117.200.122", @"47.74.222.190"],
kUpdateV4FallbackHostKey: @[@"resolvers-sg.httpdns.aliyuncs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-sg.httpdns.TrustAPPcs.com"],
kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"],
kUpdateV6FallbackHostKey: @[@"resolvers-sg.httpdns.aliyuncs.com"]
kUpdateV6FallbackHostKey: @[@"resolvers-sg.httpdns.TrustAPPcs.com"]
},
ALICLOUD_HTTPDNS_GERMANY_REGION_KEY: @{
Trust_HTTPDNS_GERMANY_REGION_KEY: @{
kServiceV4Key: @[@"47.89.80.182", @"47.246.146.77"],
kUpdateV4FallbackHostKey: @[@"resolvers-de.httpdns.aliyuncs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-de.httpdns.TrustAPPcs.com"],
kServiceV6Key: @[@"2404:2280:3000::176", @"2404:2280:3000::188"],
kUpdateV6FallbackHostKey: @[@"resolvers-de.httpdns.aliyuncs.com"]
kUpdateV6FallbackHostKey: @[@"resolvers-de.httpdns.TrustAPPcs.com"]
},
ALICLOUD_HTTPDNS_AMERICA_REGION_KEY: @{
Trust_HTTPDNS_AMERICA_REGION_KEY: @{
kServiceV4Key: @[@"47.246.131.175", @"47.246.131.141"],
kUpdateV4FallbackHostKey: @[@"resolvers-us.httpdns.aliyuncs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"],
kServiceV6Key: @[@"2404:2280:4000::2bb", @"2404:2280:4000::23e"],
kUpdateV6FallbackHostKey: @[@"resolvers-us.httpdns.aliyuncs.com"]
kUpdateV6FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"]
}
};
}

View File

@@ -1,4 +1,4 @@
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN

View File

@@ -1,4 +1,4 @@
#import "HttpdnsEdgeService.h"
#import "HttpdnsEdgeService.h"
#import <CommonCrypto/CommonCrypto.h>

View File

@@ -1,9 +1,9 @@
//
// HttpdnsLocalResolver.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2025/3/16.
// Copyright © 2025 alibaba-inc.com. All rights reserved.
// Copyright © 2025 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@@ -1,9 +1,9 @@
//
// HttpdnsLocalResolver.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2025/3/16.
// Copyright © 2025 alibaba-inc.com. All rights reserved.
// Copyright © 2025 trustapp.com. All rights reserved.
//
#import "HttpdnsLocalResolver.h"
@@ -34,7 +34,7 @@
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC; // IPv4IPv6
hints.ai_socktype = SOCK_STREAM; // TCP (DNS)
hints.ai_socktype = SOCK_STREAM; // TCP (DNS<EFBFBD><EFBFBD>?
// 3. getaddrinfo
struct addrinfo *res = NULL;
@@ -105,7 +105,7 @@
for (NSString *ipStr in ipv4Array) {
HttpdnsIpObject *ipObj = [[HttpdnsIpObject alloc] init];
[ipObj setIp:ipStr]; // ipObj.ip = ipStr
// connectedRT0
// connectedRT<EFBFBD><EFBFBD>?
[v4IpObjects addObject:ipObj];
}
}
@@ -123,17 +123,17 @@
[hostObject setV4Ips:v4IpObjects];
[hostObject setV6Ips:v6IpObjects];
// IPv4IPv6TTL60
// IPv4IPv6TTL<EFBFBD><EFBFBD>?0<EFBFBD><EFBFBD>?
[hostObject setV4TTL:60];
[hostObject setV6TTL:60];
// ttl
[HttpdnsUtil processCustomTTL:hostObject forHost:host service:service];
// (1970)
// (<EFBFBD><EFBFBD>?970)
int64_t now = (int64_t)[[NSDate date] timeIntervalSince1970];
//
// <EFBFBD><EFBFBD>?
[hostObject setLastIPv4LookupTime:now];
[hostObject setLastIPv6LookupTime:now];
@@ -141,8 +141,8 @@
[hostObject setHasNoIpv4Record:(v4IpObjects.count == 0)];
[hostObject setHasNoIpv6Record:(v6IpObjects.count == 0)];
// clientIp
// /
// clientIp<EFBFBD><EFBFBD>?
// <EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?
return hostObject;
}

View File

@@ -59,7 +59,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
+ (void)initialize {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_streamOperateSyncQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.runloopOperateQueue.HttpdnsRequest", DISPATCH_QUEUE_SERIAL);
_streamOperateSyncQueue = dispatch_queue_create("com.Trust.sdk.httpdns.runloopOperateQueue.HttpdnsRequest", DISPATCH_QUEUE_SERIAL);
});
}
@@ -83,7 +83,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return nil;
}
//
// <EFBFBD><EFBFBD>?
if (![self validateResponseCode:json]) {
return nil;
}
@@ -94,7 +94,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return nil;
}
//
// <EFBFBD><EFBFBD>?
NSArray *answers = [self getAnswersFromData:data];
if (!answers) {
return nil;
@@ -112,7 +112,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return hostObjects;
}
//
// <EFBFBD><EFBFBD>?
- (BOOL)validateResponseCode:(NSDictionary *)json {
NSString *code = [json objectForKey:@"code"];
if (![code isEqualToString:@"success"]) {
@@ -122,17 +122,17 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return YES;
}
//
// <EFBFBD><EFBFBD>?
- (id)extractDataContent:(NSDictionary *)json {
// mode
// mode<EFBFBD><EFBFBD>?
NSInteger mode = [[json objectForKey:@"mode"] integerValue];
id data = [json objectForKey:@"data"];
if (mode == 1) { // AES-CBC
//
// <EFBFBD><EFBFBD>?
data = [self decryptData:data withMode:mode];
} else if (mode != 0) {
// AES-GCM
// AES-GCM<EFBFBD><EFBFBD>?
HttpdnsLogDebug("Unsupported encryption mode: %ld", (long)mode);
return nil;
}
@@ -174,7 +174,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return nil;
}
// 使
// 使<EFBFBD><EFBFBD>?
NSError *decryptError = nil;
NSData *decryptedData = [HttpdnsUtil decryptDataAESCBC:encryptedData withKey:keyData error:&decryptError];
@@ -183,7 +183,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return nil;
}
// JSON
// JSON<EFBFBD><EFBFBD>?
NSError *jsonError;
id decodedData = [NSJSONSerialization JSONObjectWithData:decryptedData options:0 error:&jsonError];
@@ -205,7 +205,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return answers;
}
//
// <EFBFBD><EFBFBD>?
- (HttpdnsHostObject *)createHostObjectFromAnswer:(NSDictionary *)answer {
//
NSString *host = [answer objectForKey:@"dn"];
@@ -251,7 +251,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
// IPv4TTL
[self setTTLForHostObject:hostObject fromData:v4Data forIPv6:NO];
// v4extra使
// v4extra使<EFBFBD><EFBFBD>?
[self processExtraInfo:v4Data forHostObject:hostObject];
// no_ip_codeIPv4
@@ -259,7 +259,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
hostObject.hasNoIpv4Record = YES;
}
} else {
// IPv4v4
// IPv4v4<EFBFBD><EFBFBD>?
hostObject.hasNoIpv4Record = YES;
}
}
@@ -289,12 +289,12 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
hostObject.hasNoIpv6Record = YES;
}
} else {
// IPv6v6
// IPv6v6<EFBFBD><EFBFBD>?
hostObject.hasNoIpv6Record = YES;
}
}
// IP
// IP<EFBFBD><EFBFBD>?
- (void)setIpArrayToHostObject:(HttpdnsHostObject *)hostObject fromIpsArray:(NSArray *)ips forIPv6:(BOOL)isIPv6 {
NSMutableArray *ipArray = [NSMutableArray array];
for (NSString *ip in ips) {
@@ -352,7 +352,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return nil;
}
//
// <EFBFBD><EFBFBD>?
NSDictionary *paramsToSign = [self prepareSigningParams:request forEncryption:[self shouldUseEncryption]];
//
@@ -380,7 +380,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return isV4 ? [scheduleCenter currentActiveServiceServerV4Host] : [scheduleCenter currentActiveServiceServerV6Host];
}
// 使
// 使<EFBFBD><EFBFBD>?
- (BOOL)shouldUseEncryption {
HttpDnsService *service = self.service ?: [HttpDnsService sharedInstance];
return [HttpdnsUtil isNotEmptyString:service.aesSecretKey];
@@ -391,13 +391,13 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
HttpDnsService *service = self.service ?: [HttpDnsService sharedInstance];
NSInteger accountId = service.accountID;
//
// <EFBFBD><EFBFBD>?
NSMutableDictionary *paramsToSign = [NSMutableDictionary dictionary];
//
NSMutableDictionary *paramsToEncrypt = [NSMutableDictionary dictionary];
// ID
// ID<EFBFBD><EFBFBD>?
[paramsToSign setObject:[NSString stringWithFormat:@"%ld", accountId] forKey:@"id"];
//
@@ -416,7 +416,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
// SDNS
[self addSdnsParams:request.sdnsParams toParams:paramsToEncrypt];
//
// <EFBFBD><EFBFBD>?
long expiredTimestamp = [self calculateExpiredTimestamp];
NSString *expiredTimestampString = [NSString stringWithFormat:@"%ld", expiredTimestamp];
[paramsToSign setObject:expiredTimestampString forKey:@"exp"];
@@ -435,7 +435,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return paramsToSign;
}
//
// <EFBFBD><EFBFBD>?
- (NSString *)getQueryTypeString:(HttpdnsQueryIPType)queryIpType {
if ((queryIpType & HttpdnsQueryIPTypeIpv4) && (queryIpType & HttpdnsQueryIPTypeIpv6)) {
return @"4,6";
@@ -455,7 +455,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
}
}
//
// <EFBFBD><EFBFBD>?
- (long)calculateExpiredTimestamp {
HttpDnsService *service = self.service ?: [HttpDnsService sharedInstance];
long localTimestampOffset = (long)service.authTimeOffset;
@@ -510,7 +510,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
[signParts addObject:[NSString stringWithFormat:@"%@=%@", key, [params objectForKey:key]]];
}
//
// <EFBFBD><EFBFBD>?
NSString *signContent = [signParts componentsJoinedByString:@"&"];
// HMAC-SHA256
@@ -538,7 +538,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
// enc
[finalUrl appendFormat:@"&enc=%@", [params objectForKey:@"enc"]];
} else {
//
// <EFBFBD><EFBFBD>?
NSMutableDictionary *paramsForPlainText = [NSMutableDictionary dictionaryWithDictionary:params];
[paramsForPlainText removeObjectForKey:@"id"];
[paramsForPlainText removeObjectForKey:@"m"];
@@ -557,7 +557,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
}
}
//
// <EFBFBD><EFBFBD>?
if ([HttpdnsUtil isNotEmptyString:signature]) {
[finalUrl appendFormat:@"&s=%@", signature];
}
@@ -568,7 +568,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
return finalUrl;
}
//
// <EFBFBD><EFBFBD>?
- (void)appendAdditionalParams:(NSMutableString *)url {
// sessionId
NSString *sessionId = [HttpdnsUtil generateSessionID];
@@ -594,7 +594,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
if (!service) {
HttpdnsLogDebug("Missing service for accountId: %ld; ensure request.accountId is set and service initialized", (long)request.accountId);
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE userInfo:@{NSLocalizedDescriptionKey: @"HttpDnsService not found for accountId"}];
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE userInfo:@{NSLocalizedDescriptionKey: @"HttpDnsService not found for accountId"}];
}
return nil;
}
@@ -612,7 +612,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
@try {
HttpdnsIPStackType stackType = [[HttpdnsIpStackDetector sharedInstance] currentIpStack];
// 由于上面默认只用ipv4请求这里判断如果是ipv6-only环境那就用v6的ip再试一
// 由于上面默认只用ipv4请求这里判断如果是ipv6-only环境那就用v6的ip再试一<EFBFBD><EFBFBD>?
if (stackType == kHttpdnsIpv6Only) {
url = [self constructHttpdnsResolvingUrl:request forV4Net:NO];
HttpdnsLogDebug("lookupHostFromServer by ipv4 server failed, construct ipv6 backup url: %@", url);
@@ -631,8 +631,8 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
- (NSArray<HttpdnsHostObject *> *)sendRequest:(NSString *)urlStr queryIpType:(HttpdnsQueryIPType)queryIpType error:(NSError **)error {
if (![HttpdnsUtil isNotEmptyString:urlStr]) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Empty resolve URL due to missing scheduler"}];
}
return nil;
@@ -654,8 +654,8 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
if (httpResponse.statusCode != 200) {
if (error) {
NSString *errorMessage = [NSString stringWithFormat:@"Unsupported http status code: %ld", (long)httpResponse.statusCode];
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_UNSUPPORTED_STATUS_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_UNSUPPORTED_STATUS_CODE
userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
}
return nil;
@@ -673,8 +673,8 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
NSDictionary *json = [HttpdnsUtil getValidDictionaryFromJson:jsonValue];
if (!json) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Failed to parse JSON response"}];
}
return nil;
@@ -691,10 +691,10 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
}
if ([extra isKindOfClass:[NSString class]]) {
//
// <EFBFBD><EFBFBD>?
return extra;
} else {
// JSON
// JSON<EFBFBD><EFBFBD>?
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:extra options:0 error:&error];
if (!error && jsonData) {

View File

@@ -71,8 +71,8 @@ typedef struct {
+ (void)initialize {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_persistentCacheConcurrentQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.persistentCacheOperationQueue", DISPATCH_QUEUE_CONCURRENT);
_asyncResolveHostQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.asyncResolveHostQueue", DISPATCH_QUEUE_CONCURRENT);
_persistentCacheConcurrentQueue = dispatch_queue_create("com.Trust.sdk.httpdns.persistentCacheOperationQueue", DISPATCH_QUEUE_CONCURRENT);
_asyncResolveHostQueue = dispatch_queue_create("com.Trust.sdk.httpdns.asyncResolveHostQueue", DISPATCH_QUEUE_CONCURRENT);
});
}
@@ -113,7 +113,7 @@ typedef struct {
//
[self->_httpdnsDB cleanRecordAlreadExpiredAt:[[NSDate date] timeIntervalSince1970] - duration];
//
// <EFBFBD><EFBFBD>?
[self loadCacheFromDbToMemory];
});
}
@@ -139,7 +139,7 @@ typedef struct {
return;
}
// 5
// <EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?
NSUInteger totalCount = hosts.count;
for (NSUInteger i = 0; i < totalCount; i += HTTPDNS_PRE_RESOLVE_BATCH_SIZE) {
NSUInteger length = MIN(HTTPDNS_PRE_RESOLVE_BATCH_SIZE, totalCount - i);
@@ -190,21 +190,21 @@ typedef struct {
if (isCachedResultUsable) {
if (isResolvingRequired) {
//
//
// <EFBFBD><EFBFBD>?
[self determineResolvingHostNonBlocking:request];
}
// cacheKeyhost
result.hostName = host;
HttpdnsLogDebug("Reuse available cache for cacheKey: %@, result: %@", cacheKey, result);
//
// <EFBFBD><EFBFBD>?
return result;
}
if (request.isBlockingRequest) {
//
// <EFBFBD><EFBFBD>?
return [self determineResolveHostBlocking:request];
} else {
//
// <EFBFBD><EFBFBD>?
[self determineResolvingHostNonBlocking:request];
return nil;
}
@@ -264,14 +264,14 @@ typedef struct {
if ([hostObject isExpiredUnderQueryIpType:queryType]) {
if (self.atomicExpiredIPEnabled || [hostObject isLoadFromDB]) {
//
// <EFBFBD><EFBFBD>?
HttpdnsLogDebug("The ips is expired, but we accept it, host: %@, queryType: %ld, expiredIpEnabled: %d, isLoadFromDB: %d",
hostObject.hostName, queryType, self.atomicExpiredIPEnabled, [hostObject isLoadFromDB]);
//
// <EFBFBD><EFBFBD>?
return (HostObjectExamingResult){YES, YES};
}
//
// <EFBFBD><EFBFBD>?
return (HostObjectExamingResult){NO, YES};
}
@@ -310,7 +310,7 @@ typedef struct {
return nil;
}
// host
// host<EFBFBD><EFBFBD>?
result = resultArray.firstObject;
} else {
if (!self.degradeToLocalDNSEnabled) {
@@ -332,7 +332,7 @@ typedef struct {
// merge
HttpdnsHostObject *lookupResult = [self mergeLookupResultToManager:result host:host cacheKey:cacheKey underQueryIpType:queryIPType];
//
// <EFBFBD><EFBFBD>?
return [lookupResult copy];
}
@@ -483,7 +483,7 @@ typedef struct {
HttpdnsNetworkStatus currentStatus = [[HttpdnsReachability sharedInstance] currentReachabilityStatus];
NSString *currentStatusString = [[HttpdnsReachability sharedInstance] currentReachabilityString];
//
// <EFBFBD><EFBFBD>?
// 1
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
[[HttpdnsIpStackDetector sharedInstance] redetectIpStack];
@@ -493,23 +493,23 @@ typedef struct {
BOOL statusChanged = (_lastNetworkStatus != currentStatus);
// :
// -
// -
// - <EFBFBD><EFBFBD>?
// - <EFBFBD><EFBFBD>?
NSTimeInterval elapsedTime = currentTimestamp - _lastUpdateTimestamp;
if (elapsedTime >= 5 || (statusChanged && elapsedTime >= 1)) {
HttpdnsLogDebug("Processing network change: oldStatus: %ld, newStatus: %ld(%@), elapsedTime=%.2f seconds",
_lastNetworkStatus, currentStatus, currentStatusString, elapsedTime);
//
// 2
// 2<EFBFBD><EFBFBD>?
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
HttpdnsScheduleCenter *scheduleCenter = self.ownerService.scheduleCenter;
[scheduleCenter asyncUpdateRegionScheduleConfig];
});
//
// cacheKey hostName
// SDNS 使 cacheKey
// cacheKey hostName<EFBFBD><EFBFBD>?
// SDNS 使 cacheKey <EFBFBD><EFBFBD>?
NSArray *allKeys = [_hostObjectInMemoryCache allCacheKeys];
NSMutableArray<NSString *> *hostArray = [NSMutableArray array];
for (NSString *key in allKeys) {
@@ -524,10 +524,10 @@ typedef struct {
}
}
//
// 3
// <EFBFBD><EFBFBD>?
// 3<EFBFBD><EFBFBD>?
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
// hostName SDNS cacheKey
// hostName <EFBFBD><EFBFBD>?SDNS cacheKey <EFBFBD><EFBFBD>?
for (NSString *host in hostArray) {
[self->_hostObjectInMemoryCache removeHostObjectByCacheKey:host];
}
@@ -538,7 +538,7 @@ typedef struct {
}
});
//
// <EFBFBD><EFBFBD>?
_lastNetworkStatus = currentStatus;
_lastUpdateTimestamp = currentTimestamp;
} else {
@@ -552,7 +552,7 @@ typedef struct {
- (dispatch_queue_t)cacheQueue {
if (!_cacheQueue) {
_cacheQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.cacheDisableStatusQueue", DISPATCH_QUEUE_SERIAL);
_cacheQueue = dispatch_queue_create("com.Trust.sdk.httpdns.cacheDisableStatusQueue", DISPATCH_QUEUE_SERIAL);
}
return _cacheQueue;
}
@@ -573,7 +573,7 @@ typedef struct {
HttpdnsHostObject *hostObject = [HttpdnsHostObject fromDBRecord:hostRecord];
// App使
// App使<EFBFBD><EFBFBD>?
[hostObject setIsLoadFromDB:YES];
[self->_hostObjectInMemoryCache setHostObject:hostObject forCacheKey:cacheKey];
@@ -596,7 +596,7 @@ typedef struct {
}
}
//
// <EFBFBD><EFBFBD>?
dispatch_async(_persistentCacheConcurrentQueue, ^{
[self->_httpdnsDB deleteByHostNameArr:hostArray];
});
@@ -605,7 +605,7 @@ typedef struct {
- (void)cleanMemoryAndPersistentCacheOfAllHosts {
[_hostObjectInMemoryCache removeAllHostObjects];
//
// <EFBFBD><EFBFBD>?
dispatch_async(_persistentCacheConcurrentQueue, ^{
[self->_httpdnsDB deleteAll];
});
@@ -622,7 +622,7 @@ typedef struct {
}
#pragma mark -
#pragma mark -
#pragma mark - <EFBFBD><EFBFBD>?
- (NSString *)showMemoryCache {
NSString *cacheDes;

View File

@@ -24,19 +24,19 @@
// #import "HttpdnsDegradationDelegate.h"
// #import "HttpdnsLoggerProtocol.h"
#import <AlicloudHTTPDNS/HttpdnsRequest.h>
#import <AlicloudHTTPDNS/HttpDnsResult.h>
#import <AlicloudHTTPDNS/HttpdnsLoggerProtocol.h>
#import <AlicloudHTTPDNS/HttpdnsDegradationDelegate.h>
#import <TrustHTTPDNS/HttpdnsRequest.h>
#import <TrustHTTPDNS/HttpDnsResult.h>
#import <TrustHTTPDNS/HttpdnsLoggerProtocol.h>
#import <TrustHTTPDNS/HttpdnsDegradationDelegate.h>
#define ALICLOUD_HTTPDNS_DEPRECATED(explain) __attribute__((deprecated(explain)))
#define Trust_HTTPDNS_DEPRECATED(explain) __attribute__((deprecated(explain)))
#ifndef ALICLOUDHDNS_STACK_KEY
#define ALICLOUDHDNS_STACK_KEY
#ifndef TrustHDNS_STACK_KEY
#define TrustHDNS_STACK_KEY
#define ALICLOUDHDNS_IPV4 @"ALICLOUDHDNS_IPV4"
#define ALICLOUDHDNS_IPV6 @"ALICLOUDHDNS_IPV6"
#define TrustHDNS_IPV4 @"TrustHDNS_IPV4"
#define TrustHDNS_IPV6 @"TrustHDNS_IPV6"
#endif
@@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 域名
/// @param ipType 当前查询的IP类型
/// @param ttl 当次域名解析返回的TTL
- (int64_t)httpdnsHost:(NSString * _Nonnull)host ipType:(AlicloudHttpDNS_IPType)ipType ttl:(int64_t)ttl;
- (int64_t)httpdnsHost:(NSString * _Nonnull)host ipType:(TrustHttpDNS_IPType)ipType ttl:(int64_t)ttl;
@end
@@ -62,154 +62,154 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy, readonly, nullable) NSString *aesSecretKey;
@property (nonatomic, weak, setter=setDelegateForDegradationFilter:) id<HttpDNSDegradationDelegate> delegate ALICLOUD_HTTPDNS_DEPRECATED("不再建议通过设置此回调实现降级逻辑而是自行在调用HTTPDNS解析域名前做判断");
@property (nonatomic, weak, setter=setDelegateForDegradationFilter:) id<HttpDNSDegradationDelegate> delegate Trust_HTTPDNS_DEPRECATED("不再建议通过设置此回调实现降级逻辑而是自行在调用HTTPDNS解析域名前做判断");
@property (nonatomic, weak) id<HttpdnsTTLDelegate> ttlDelegate;
+ (nonnull instancetype)sharedInstance;
/// 获取指定账号对应HttpDnsService 实例
/// 获取指定账号对应<EFBFBD><EFBFBD>?HttpDnsService 实例
/// @param accountID 账号 ID
/// @return 已初始化的实例,若账号尚未注册则返回 nil
+ (nullable instancetype)getInstanceByAccountId:(NSInteger)accountID;
/*!
* @brief 无需鉴权功能的初始化接口
* @details 初始化,设置 HTTPDNS 服务 Account ID。使用本接口初始化请求将无任何签名保护请谨慎使用
* 您可以从控制台获取您Account ID
* 此方法会初始化为单例
* 注意:本接口从3.2.1起废弃,后续将进行移除
* @details 初始化,设置 HTTPDNS 服务 Account ID。使用本接口初始化请求将无任何签名保护请谨慎使用<EFBFBD><EFBFBD>?
* 您可以从控制台获取您<EFBFBD><EFBFBD>?Account ID <EFBFBD><EFBFBD>?
* 此方法会初始化为单例<EFBFBD><EFBFBD>?
* 注意:本接口<EFBFBD><EFBFBD>?.2.1起废弃,后续将进行移除<EFBFBD><EFBFBD>?
* @param accountID 您的 HTTPDNS Account ID
*/
- (nonnull instancetype)initWithAccountID:(NSInteger)accountID ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. This method will be removed in the future. Use -[HttpDnsService initWithAccountID:secretKey:] instead.");
- (nonnull instancetype)initWithAccountID:(NSInteger)accountID Trust_HTTPDNS_DEPRECATED("Deprecated. This method will be removed in the future. Use -[HttpDnsService initWithAccountID:secretKey:] instead.");
/*!
* @brief 启用鉴权功能的初始化接口
* @details 初始化、开启鉴权功能,并设HTTPDNS 服务 Account ID鉴权功能对应的 secretKey
* 您可以从控制台获取您Account ID 、secretKey信息
* 此方法会初始化为单例
* @details 初始化、开启鉴权功能,并设<EFBFBD><EFBFBD>?HTTPDNS 服务 Account ID鉴权功能对应的 secretKey<EFBFBD><EFBFBD>?
* 您可以从控制台获取您<EFBFBD><EFBFBD>?Account ID 、secretKey信息<EFBFBD><EFBFBD>?
* 此方法会初始化为单例<EFBFBD><EFBFBD>?
* @param accountID 您的 HTTPDNS Account ID
* @param secretKey 鉴权对应secretKey
* @param secretKey 鉴权对应<EFBFBD><EFBFBD>?secretKey
*/
- (nonnull instancetype)initWithAccountID:(NSInteger)accountID secretKey:(NSString * _Nonnull)secretKey;
/*!
* @brief 启用鉴权功能、加密功能的初始化接
* @details 初始化、开启鉴权功能、开启AES加密并设置 HTTPDNS 服务 Account ID鉴权功能对应的 secretKey加密功能对应的 aesSecretKey
* 您可以从控制台获取您Account ID 、secretKey、aesSecretKey 信息
* 此方法会初始化为单例
* @brief 启用鉴权功能、加密功能的初始化接<EFBFBD><EFBFBD>?
* @details 初始化、开启鉴权功能、开启AES加密并设置 HTTPDNS 服务 Account ID鉴权功能对应的 secretKey加密功能对应的 aesSecretKey<EFBFBD><EFBFBD>?
* 您可以从控制台获取您<EFBFBD><EFBFBD>?Account ID 、secretKey、aesSecretKey 信息<EFBFBD><EFBFBD>?
* 此方法会初始化为单例<EFBFBD><EFBFBD>?
* @param accountID 您的 HTTPDNS Account ID
* @param secretKey 鉴权对应secretKey
* @param aesSecretKey 加密功能对应aesSecretKey
* @param secretKey 鉴权对应<EFBFBD><EFBFBD>?secretKey
* @param aesSecretKey 加密功能对应<EFBFBD><EFBFBD>?aesSecretKey
*/
- (nonnull instancetype)initWithAccountID:(NSInteger)accountID secretKey:(NSString * _Nonnull)secretKey aesSecretKey:(NSString * _Nullable)aesSecretKey;
/// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间
/// 注意,校正操作在 APP 的一个生命周期内生效APP 重启后需要重新设置才能重新生
/// @param authCurrentTime 用于校正的时间戳,单位为
- (void)setAuthCurrentTime:(NSUInteger)authCurrentTime ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setInternalAuthTimeBaseBySpecifyingCurrentTime:] instead.");
/// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间<EFBFBD><EFBFBD>?
/// 注意,校正操作在 APP 的一个生命周期内生效APP 重启后需要重新设置才能重新生<EFBFBD><EFBFBD>?
/// @param authCurrentTime 用于校正的时间戳,单位为<EFBFBD><EFBFBD>?
- (void)setAuthCurrentTime:(NSUInteger)authCurrentTime Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setInternalAuthTimeBaseBySpecifyingCurrentTime:] instead.");
/// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间
/// 注意,校正操作在 APP 的一个生命周期内生效APP 重启后需要重新设置才能重新生
/// @param currentTime 用于校正的时间戳,单位为
/// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间<EFBFBD><EFBFBD>?
/// 注意,校正操作在 APP 的一个生命周期内生效APP 重启后需要重新设置才能重新生<EFBFBD><EFBFBD>?
/// @param currentTime 用于校正的时间戳,单位为<EFBFBD><EFBFBD>?
- (void)setInternalAuthTimeBaseBySpecifyingCurrentTime:(NSTimeInterval)currentTime;
/// 设置持久化缓存功
/// @param enable YES: 开NO: 关闭
- (void)setCachedIPEnabled:(BOOL)enable ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setPersistentCacheIPEnabled:] instead.");
/// 设置持久化缓存功<EFBFBD><EFBFBD>?
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
- (void)setCachedIPEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setPersistentCacheIPEnabled:] instead.");
/// 设置持久化缓存功
/// 设置持久化缓存功<EFBFBD><EFBFBD>?
/// 开启后,每次解析会将结果持久化缓存到本地,当下次应用启动时,可以从本地加载缓存解析结果,提高应用启动时获取解析结果的速度
/// 加载时,会丢弃已经过期的解析结果
/// @param enable YES: 开NO: 关闭
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
- (void)setPersistentCacheIPEnabled:(BOOL)enable;
/// 设置持久化缓存功
/// 设置持久化缓存功<EFBFBD><EFBFBD>?
/// 开启后,每次解析会将结果持久化缓存到本地,当下次应用启动时,可以从本地加载缓存解析结果,提高应用启动时获取解析结果的速度
/// 加载时,会丢弃过期时间已经超过指定值的解析结果
/// @param enable YES: 开NO: 关闭
/// @param duration 决定丢弃IP的过期时间阈值单位为秒过期超过这个时间范围的IP会被丢弃取值范围为0-1年。这个值仅在开启持久化缓存功能时才有意
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
/// @param duration 决定丢弃IP的过期时间阈值单位为秒过期超过这个时间范围的IP会被丢弃取值范围为0-1年。这个值仅在开启持久化缓存功能时才有意<EFBFBD><EFBFBD>?
- (void)setPersistentCacheIPEnabled:(BOOL)enable discardRecordsHasExpiredFor:(NSTimeInterval)duration;
/// 是否允许 HTTPDNS 返回 TTL 过期域名ip ,建议允许(默认不允许)
/// @param enable YES: 开NO: 关闭
- (void)setExpiredIPEnabled:(BOOL)enable ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setReuseExpiredIPEnabled:] instead.");
/// 是否允许 HTTPDNS 返回 TTL 过期域名<EFBFBD><EFBFBD>?ip ,建议允许(默认不允许)
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
- (void)setExpiredIPEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setReuseExpiredIPEnabled:] instead.");
/// 是否允许 HTTPDNS 返回 TTL 过期域名ip ,建议允许(默认不允许)
/// @param enable YES: 开NO: 关闭
/// 是否允许 HTTPDNS 返回 TTL 过期域名<EFBFBD><EFBFBD>?ip ,建议允许(默认不允许)
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
- (void)setReuseExpiredIPEnabled:(BOOL)enable;
/// 设置 HTTPDNS 域名解析请求类型 ( HTTP / HTTPS )
/// 若不调用该接口,默认HTTP 请求
/// HTTP 请求基于底层 CFNetwork 实现,不ATS 限制
/// 若不调用该接口,默认<EFBFBD><EFBFBD>?HTTP 请求<EFBFBD><EFBFBD>?
/// HTTP 请求基于底层 CFNetwork 实现,不<EFBFBD><EFBFBD>?ATS 限制<EFBFBD><EFBFBD>?
/// @param enable YES: HTTPS请求 NO: HTTP请求
- (void)setHTTPSRequestEnabled:(BOOL)enable;
/// 声明App是否配置了ATS为AllowsArbitraryLoads默认认为没有配
/// 声明App是否配置了ATS为AllowsArbitraryLoads默认认为没有配<EFBFBD><EFBFBD>?
/// 若做了声明则当指定走HTTP方式解析域名时解析链路会走系统NSURLSession逻辑
/// 否则会走定制的CFHTTP链路避免被ATS拦截请求
- (void)setHasAllowedArbitraryLoadsInATS:(BOOL)hasAllowedArbitraryLoadsInATS;
/// 设置底层HTTPDNS网络请求超时时间单位为
/// 需要注意,这个值只决定底层解析请求的网络超时时间,而非同步解析接口、异步解析接口的最长阻塞或者等待时
/// 设置底层HTTPDNS网络请求超时时间单位为<EFBFBD><EFBFBD>?
/// 需要注意,这个值只决定底层解析请求的网络超时时间,而非同步解析接口、异步解析接口的最长阻塞或者等待时<EFBFBD><EFBFBD>?
/// 同步解析接口、异步解析接口的最长阻塞或者等待时间需要调用接口时设置request参数中的`resolveTimeoutInSecond`决定
/// @param timeoutInterval 超时时间,单位为
/// @param timeoutInterval 超时时间,单位为<EFBFBD><EFBFBD>?
- (void)setNetworkingTimeoutInterval:(NSTimeInterval)timeoutInterval;
/// 指定region指定后会读取该region对应配置作为初始化配
/// 一般情况下无需设置SDK内部会默认路由全球范围内最近的接入
/// 指定region指定后会读取该region对应配置作为初始化配<EFBFBD><EFBFBD>?
/// 一般情况下无需设置SDK内部会默认路由全球范围内最近的接入<EFBFBD><EFBFBD>?
/// @param region 需要指定的region缺省为中国大陆
- (void)setRegion:(NSString *)region;
/// 域名预解(默认解析双栈记录)
/// 通常用于启动后立即向SDK设置您后续可能会使用到的热点域名以便SDK提前解析减少后续解析域名时请求的时
/// 如果是在运行过程中调用SDK也会立即解析设置的域名数组中的域名刷新这些域名的解析结
/// 域名预解<EFBFBD><EFBFBD>?(默认解析双栈记录)
/// 通常用于启动后立即向SDK设置您后续可能会使用到的热点域名以便SDK提前解析减少后续解析域名时请求的时<EFBFBD><EFBFBD>?
/// 如果是在运行过程中调用SDK也会立即解析设置的域名数组中的域名刷新这些域名的解析结<EFBFBD><EFBFBD>?
///
/// @param hosts 预解析列表数
/// @param hosts 预解析列表数<EFBFBD><EFBFBD>?
- (void)setPreResolveHosts:(NSArray *)hosts;
/// 域名预解析可以指定预解析auto、ipv4、ipv6、both
/// 通常用于启动后立即向SDK设置您后续可能会使用到的热点域名以便SDK提前解析减少后续解析域名时请求的时
/// 如果是在运行过程中调用SDK也会立即解析设置的域名数组中的域名刷新这些域名的解析结
/// 通常用于启动后立即向SDK设置您后续可能会使用到的热点域名以便SDK提前解析减少后续解析域名时请求的时<EFBFBD><EFBFBD>?
/// 如果是在运行过程中调用SDK也会立即解析设置的域名数组中的域名刷新这些域名的解析结<EFBFBD><EFBFBD>?
///
/// @param hosts 预解析列表数
/// @param ipType 指定预解析记录类
/// @param hosts 预解析列表数<EFBFBD><EFBFBD>?
/// @param ipType 指定预解析记录类<EFBFBD><EFBFBD>?
- (void)setPreResolveHosts:(NSArray *)hosts byIPType:(HttpdnsQueryIPType)ipType;
/// 域名预解
/// 域名预解<EFBFBD><EFBFBD>?
/// @param hosts 域名
/// @param ipType 4: ipv4; 6: ipv6; 64: ipv4+ipv6
- (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(AlicloudHttpDNS_IPType)ipType ALICLOUD_HTTPDNS_DEPRECATED("Deprecated, this method will be removed in the future. Use -[HttpDnsService setPreResolveHosts:byIPType:] instead.");
- (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(TrustHttpDNS_IPType)ipType Trust_HTTPDNS_DEPRECATED("Deprecated, this method will be removed in the future. Use -[HttpDnsService setPreResolveHosts:byIPType:] instead.");
/// 本地日志 log 开
/// 本地日志 log 开<EFBFBD><EFBFBD>?
/// @param enable YES: 打开 NO: 关闭
- (void)setLogEnabled:(BOOL)enable;
/// 设置网络切换时是否自动更新所有域名解析结
/// 如果打开此开关,在网络切换时,会自动刷新所有域名的解析结果,但会产生一定流量消
/// @param enable YES: 开NO: 关闭
/// 设置网络切换时是否自动更新所有域名解析结<EFBFBD><EFBFBD>?
/// 如果打开此开关,在网络切换时,会自动刷新所有域名的解析结果,但会产生一定流量消<EFBFBD><EFBFBD>?
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
- (void)setPreResolveAfterNetworkChanged:(BOOL)enable;
/// 设置当httpdns解析失败时是否降级到localDNS尝试解析
/// 降级生效时SDNS参数不生效降级逻辑只解析域名返回的结果默认使用60秒(若未指定该域名自定义TTL)作为TTL
/// 降级生效时SDNS参数不生效降级逻辑只解析域名返回的结果默认使<EFBFBD><EFBFBD>?0<><30>?若未指定该域名自定义TTL)作为TTL<EFBFBD><EFBFBD>?
/// 降级请求也不会再对ip进行优先排序
/// 默认关闭,不会自动降
/// @param enable YES自动降NO不自动降级
/// 默认关闭,不会自动降<EFBFBD><EFBFBD>?
/// @param enable YES自动降<EFBFBD><EFBFBD>?NO不自动降级
- (void)setDegradeToLocalDNSEnabled:(BOOL)enable;
@@ -219,59 +219,59 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setIPRankingDatasource:(NSDictionary<NSString *, NSNumber *> *)IPRankingDatasource;
/// 设置是否 开IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结
/// @param enable YES: 开NO: 关闭
- (void)enableIPv6:(BOOL)enable ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setIPv6Enabled:] instead.");
/// 设置是否 开<EFBFBD><EFBFBD>?IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结<EFBFBD><EFBFBD>?
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
- (void)enableIPv6:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setIPv6Enabled:] instead.");
/// 设置是否 开IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结
/// 设置是否 开<EFBFBD><EFBFBD>?IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结<EFBFBD><EFBFBD>?
/// 已弃用。默认支持IPv6。如果不需要IPv6类型的结果只需在请求时指定`queryIpType`为`HttpdnsQueryIPTypeIpv4`
/// @param enable YES: 开NO: 关闭
- (void)setIPv6Enabled:(BOOL)enable ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. If ipv6 is unnecessary, you can set the `queryIpType` as HttpdnsQueryIPTypeIpv4 when resolving domain.");
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭
- (void)setIPv6Enabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. If ipv6 is unnecessary, you can set the `queryIpType` as HttpdnsQueryIPTypeIpv4 when resolving domain.");
/// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid
/// @param enable YES: 开NO: 关闭 ,默认关
- (void)enableNetworkInfo:(BOOL)enable ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore");
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭 ,默认关<EFBFBD><EFBFBD>?
- (void)enableNetworkInfo:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore");
/// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid
/// @param enable YES: 开NO: 关闭 ,默认关
- (void)setReadNetworkInfoEnabled:(BOOL)enable ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore.");
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭 ,默认关<EFBFBD><EFBFBD>?
- (void)setReadNetworkInfoEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore.");
/// 是否开启IP探测功能
/// @param enable YES: 开NO: 关闭 默认打开
- (void)enableCustomIPRank:(BOOL)enable ALICLOUD_HTTPDNS_DEPRECATED("Deprecated, will be removed in the future.");
/// @param enable YES: 开<EFBFBD><EFBFBD>?NO: 关闭 默认打开
- (void)enableCustomIPRank:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated, will be removed in the future.");
/// 设置软件自定义解析全局默认参数,设置后,调用软件自定义解析时,每个请求默认都会带上这里配置的参
/// 设置软件自定义解析全局默认参数,设置后,调用软件自定义解析时,每个请求默认都会带上这里配置的参<EFBFBD><EFBFBD>?
/// @param params 全局默认参数
- (void)setSdnsGlobalParams:(NSDictionary<NSString *, NSString *> *)params;
/// 设置日志输出回调,以实现自定义日志输出方
/// 设置日志输出回调,以实现自定义日志输出方<EFBFBD><EFBFBD>?
/// @param logHandler 日志输出回调实现实例
- (void)setLogHandler:(id<HttpdnsLoggerProtocol>)logHandler;
/// 获取用于用户追踪sessionId
/// sessionId为随机生成长度12 位App 生命周期内保持不
/// 为了排查可能的解析问题,需要您sessionId 和解析出IP 一起记录在日志
/// 请参考: 解析异常排查“会话追踪方案https://help.aliyun.com/document_detail/100530.html
/// 获取用于用户追踪<EFBFBD><EFBFBD>?sessionId
/// sessionId为随机生成长度<EFBFBD><EFBFBD>?12 位App 生命周期内保持不<EFBFBD><EFBFBD>?
/// 为了排查可能的解析问题,需要您<EFBFBD><EFBFBD>?sessionId 和解析出<EFBFBD><EFBFBD>?IP 一起记录在日志<EFBFBD><EFBFBD>?
/// 请参<EFBFBD><EFBFBD>? 解析异常排查<EFBFBD><EFBFBD>?“会话追踪方案<EFBFBD><EFBFBD>?https://help.TrustAPP.com/document_detail/100530.html
- (NSString *)getSessionId;
/// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结
/// 为了防止在主线程中误用本接口导致APP卡顿本接口会做检测若发现调用线程是主线程则自动降级到resolveHostSyncNonBlocking接口的实现逻辑
/// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结<EFBFBD><EFBFBD>?
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结<EFBFBD><EFBFBD>?
/// 为了防止在主线程中误用本接口导致APP卡顿本接口会做检测若发现调用线程是主线程则自动降级到resolveHostSyncNonBlocking接口的实现逻辑<EFBFBD><EFBFBD>?
/// @param host 需要解析的域名
/// @param queryIpType 可设置为自动选择ipv4ipv6. 设置为自动选择时会自动根据当前所处网络环境选择解析ipv4或ipv6
/// @return 解析结果
- (nullable HttpdnsResult *)resolveHostSync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType;
/// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结
/// 为了防止在主线程中误用本接口导致APP卡顿本接口会做检测若发现调用线程是主线程则自动降级到resolveHostSyncNonBlocking接口的实现逻辑
/// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结<EFBFBD><EFBFBD>?
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结<EFBFBD><EFBFBD>?
/// 为了防止在主线程中误用本接口导致APP卡顿本接口会做检测若发现调用线程是主线程则自动降级到resolveHostSyncNonBlocking接口的实现逻辑<EFBFBD><EFBFBD>?
/// @param host 需要解析的域名
/// @param queryIpType 可设置为自动选择ipv4ipv6. 设置为自动选择时会自动根据当前所处网络环境选择解析ipv4或ipv6
/// @param sdnsParams 如果域名配置了sdns自定义解析通过此参数携带自定义参数
@@ -279,22 +279,22 @@ NS_ASSUME_NONNULL_BEGIN
/// @return 解析结果
- (nullable HttpdnsResult *)resolveHostSync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType withSdnsParams:(NSDictionary<NSString *, NSString *> *)sdnsParams sdnsCacheKey:(NSString *)cacheKey;
/// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结
/// 为了防止在主线程中误用本接口导致APP卡顿本接口会做检测若发现调用线程是主线程则自动降级到resolveHostSyncNonBlocking接口的实现逻辑
/// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结<EFBFBD><EFBFBD>?
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结<EFBFBD><EFBFBD>?
/// 为了防止在主线程中误用本接口导致APP卡顿本接口会做检测若发现调用线程是主线程则自动降级到resolveHostSyncNonBlocking接口的实现逻辑<EFBFBD><EFBFBD>?
/// @param request 请求参数对象
/// @return 解析结果
- (nullable HttpdnsResult *)resolveHostSync:(HttpdnsRequest *)request;
/// 异步解析域名,不会阻塞当前线程,会在从缓存中获取到有效结果,或从服务器拿到最新解析结果后,通过回调返回结果
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结<EFBFBD><EFBFBD>?
/// @param host 需要解析的域名
/// @param queryIpType 可设置为自动选择ipv4ipv6. 设置为自动选择时会自动根据当前所处网络环境选择解析ipv4或ipv6
/// @handler 解析结果回调
- (void)resolveHostAsync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType completionHandler:(void (^)(HttpdnsResult * nullable))handler;
/// 异步解析域名,不会阻塞当前线程,会在从缓存中获取到有效结果,或从服务器拿到最新解析结果后,通过回调返回结果
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结<EFBFBD><EFBFBD>?
/// @param host 需要解析的域名
/// @param queryIpType 可设置为自动选择ipv4ipv6. 设置为自动选择时会自动根据当前所处网络环境选择解析ipv4或ipv6
/// @param sdnsParams 如果域名配置了sdns自定义解析通过此参数携带自定义参数
@@ -303,20 +303,20 @@ NS_ASSUME_NONNULL_BEGIN
- (void)resolveHostAsync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType withSdnsParams:(nullable NSDictionary<NSString *, NSString *> *)sdnsParams sdnsCacheKey:(nullable NSString *)cacheKey completionHandler:(void (^)(HttpdnsResult * nullable))handler;
/// 异步解析域名,不会阻塞当前线程,会在从缓存中获取到有效结果,或从服务器拿到最新解析结果后,通过回调返回结果
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结<EFBFBD><EFBFBD>?
/// @param request 请求参数对象
/// @handler 解析结果回调
- (void)resolveHostAsync:(HttpdnsRequest *)request completionHandler:(void (^)(HttpdnsResult * nullable))handler;
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为
/// 先查询缓存,缓存中存在有效结果(未过期,或者过期但配置了可以复用过期解析结果),则直接返回结果,如果缓存未命中,则发起异步解析请求
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在有效结<EFBFBD><EFBFBD>?未过期,或者过期但配置了可以复用过期解析结<EFBFBD><EFBFBD>?,则直接返回结果,如果缓存未命中,则发起异步解析请求
/// @param host 需要解析的域名
/// @param queryIpType 可设置为自动选择ipv4ipv6. 设置为自动选择时会自动根据当前所处网络环境选择解析ipv4或ipv6
/// @return 解析结果
- (nullable HttpdnsResult *)resolveHostSyncNonBlocking:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType;
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为
/// 先查询缓存,缓存中存在有效结果(未过期,或者过期但配置了可以复用过期解析结果),则直接返回结果,如果缓存未命中,则发起异步解析请求
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在有效结<EFBFBD><EFBFBD>?未过期,或者过期但配置了可以复用过期解析结<EFBFBD><EFBFBD>?,则直接返回结果,如果缓存未命中,则发起异步解析请求
/// @param host 需要解析的域名
/// @param queryIpType 可设置为自动选择ipv4ipv6. 设置为自动选择时会自动根据当前所处网络环境选择解析ipv4或ipv6
/// @param sdnsParams 如果域名配置了sdns自定义解析通过此参数携带自定义参数
@@ -324,8 +324,8 @@ NS_ASSUME_NONNULL_BEGIN
/// @return 解析结果
- (nullable HttpdnsResult *)resolveHostSyncNonBlocking:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType withSdnsParams:(nullable NSDictionary<NSString *, NSString *> *)sdnsParams sdnsCacheKey:(nullable NSString *)cacheKey;
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为
/// 先查询缓存,缓存中存在有效结果(未过期,或者过期但配置了可以复用过期解析结果),则直接返回结果,如果缓存未命中,则发起异步解析请求
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在有效结<EFBFBD><EFBFBD>?未过期,或者过期但配置了可以复用过期解析结<EFBFBD><EFBFBD>?,则直接返回结果,如果缓存未命中,则发起异步解析请求
/// @param request 请求参数对象
/// @return 解析结果
- (nullable HttpdnsResult *)resolveHostSyncNonBlocking:(HttpdnsRequest *)request;
@@ -333,34 +333,34 @@ NS_ASSUME_NONNULL_BEGIN
/// 获取域名对应的IP单IP
/// @param host 域名
- (NSString *)getIpByHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSString *)getIpByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的IP数组多IP
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSArray *)getIpsByHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSArray *)getIpsByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开enableIPv6
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSString *)getIPv6ByHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSString *)getIPv6ByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开enableIPv6
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSArray *)getIPv6sByHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSArray *)getIPv6sByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 同时获取ipv4 ipv6的IP 需要开启ipv6 开enableIPv6
/// 同时获取ipv4 ipv6的IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// @param host 域名
/// @result 返回字典类型结构
/// {
/// ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// }
- (NSDictionary <NSString *, NSArray *>*)getIPv4_v6ByHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSDictionary <NSString *, NSArray *>*)getIPv4_v6ByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址
/// 使用此API 需要确enableIPv6 开关已打开
/// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址<EFBFBD><EFBFBD>?
/// 使用此API 需要确<EFBFBD><EFBFBD>?enableIPv6 开关已打开
/// 设备网络 返回域名IP
/// IPv4 Only IPv4
/// IPv6 Only IPv6 如果没有Pv6返回空
@@ -368,75 +368,75 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 要解析的域名
/// @result 返回字典类型结构
/// {
/// ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// }
-(NSDictionary <NSString *, NSArray *>*)autoGetIpsByHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
-(NSDictionary <NSString *, NSArray *>*)autoGetIpsByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的IPv4地址单IPv4
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSString *)getIPv4ForHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSString *)getIPv4ForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的IP数组多IP
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSArray *)getIPv4ListForHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSArray *)getIPv4ListForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 获取IPv4地址列表同步接口必须在子线程中执行否则会转变为异步接口
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限为5s
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大于5s同步接口也最多阻塞当前线程5s
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起同步解析请
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<EFBFBD><EFBFBD>?s<><73>?
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<EFBFBD><EFBFBD>?s同步接口也最多阻塞当前线<EFBFBD><EFBFBD>?s
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起同步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSArray *)getIPv4ListForHostSync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
- (NSArray *)getIPv4ListForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开enableIPv6
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSString *)getIPv6ForHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSString *)getIPv6ForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开enableIPv6
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSArray *)getIPv6ListForHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSArray *)getIPv6ListForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 获取IPv6地址列表同步接口必须在子线程中执行否则会转变为异步接口
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限为5s
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大于5s同步接口也最多阻塞当前线程5s
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<EFBFBD><EFBFBD>?s<><73>?
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<EFBFBD><EFBFBD>?s同步接口也最多阻塞当前线<EFBFBD><EFBFBD>?s
/// @param host 域名
- (NSArray *)getIPv6ListForHostSync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
- (NSArray *)getIPv6ListForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应格式化后的IP (针对ipv6)
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
- (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空同时获取ipv4 ipv6的IP 需要开启ipv6 开enableIPv6
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 异步接口首次结果可能为空同时获取ipv4 ipv6的IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
/// @result 返回字典类型结构
/// {
/// ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// }
- (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
- (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// NOTE: 同步接口,必须在子线程中执行,否则会转变为异步接
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限为5s
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大于5s同步接口也最多阻塞当前线程5s
/// 同时获取ipv4 + ipv6的IP 需要开启ipv6 开enableIPv6
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// NOTE: 同步接口,必须在子线程中执行,否则会转变为异步接<EFBFBD><EFBFBD>?
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<EFBFBD><EFBFBD>?s<><73>?
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<EFBFBD><EFBFBD>?s同步接口也最多阻塞当前线<EFBFBD><EFBFBD>?s
/// 同时获取ipv4 + ipv6的IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
/// @result 返回字典类型结构
/// {
/// ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// }
- (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostSync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
- (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 异步接口,首次结果可能为空,根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址
/// 使用此API 需要确enableIPv6 开关已打开
/// 异步接口,首次结果可能为空,根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址<EFBFBD><EFBFBD>?
/// 使用此API 需要确<EFBFBD><EFBFBD>?enableIPv6 开关已打开
/// 设备网络 返回域名IP
/// IPv4 Only IPv4
/// IPv6 Only IPv6 如果没有Pv6返回空
@@ -444,33 +444,33 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 要解析的域名
/// @result 返回字典类型结构
/// {
/// ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// }
-(NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostAsync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
-(NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址组同步接口必须在子线程中执行否则会转变为异步接
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限为5s
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大于5s同步接口也最多阻塞当前线程5s
/// 根据当前网络栈自动获取ipv4 ipv6的IP 需要开启ipv6 开enableIPv6
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请
/// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址组同步接口必须在子线程中执行否则会转变为异步接<EFBFBD><EFBFBD>?
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<EFBFBD><EFBFBD>?s<><73>?
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<EFBFBD><EFBFBD>?s同步接口也最多阻塞当前线<EFBFBD><EFBFBD>?s
/// 根据当前网络栈自动获取ipv4 ipv6的IP 需要开启ipv6 开<EFBFBD><EFBFBD>?enableIPv6<EFBFBD><EFBFBD>?
/// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请<EFBFBD><EFBFBD>?
/// @param host 域名
/// @result 返回字典类型结构
/// {
/// ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],
/// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// }
- (NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostSync:(NSString *)host ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
- (NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 软件自定义解析接
- (NSDictionary *)getIpsByHostAsync:(NSString *)host withParams:(NSDictionary<NSString *, NSString *> *)params withCacheKey:(NSString *)cacheKey ALICLOUD_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:withSdnsParams:sdnsCacheKey:] instead.");
/// 软件自定义解析接<EFBFBD><EFBFBD>?
- (NSDictionary *)getIpsByHostAsync:(NSString *)host withParams:(NSDictionary<NSString *, NSString *> *)params withCacheKey:(NSString *)cacheKey Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:withSdnsParams:sdnsCacheKey:] instead.");
/// 清除指定host缓存存+沙盒数据库)
/// 清除指定host缓存<EFBFBD><EFBFBD>?沙盒数据库)
/// @param hostArray 需要清除的host域名数组。如果需要清空全部数据传nil或者空数组即可
- (void)cleanHostCache:(nullable NSArray<NSString *> *)hostArray;
/// 清除当前所有host缓存 (内存+沙盒数据库)
/// 清除当前所有host缓存 (内存+沙盒数据<EFBFBD><EFBFBD>?
- (void)cleanAllHostCache;
/// 清理已经配置的软件自定义解析全局参数

View File

@@ -44,12 +44,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
@property (nonatomic, copy) NSString *aesSecretKey;
@property (nonatomic, assign) BOOL hasConfiguredAccount;
// 访SDK10
// 访SDK10<EFBFBD><EFBFBD>?
@property (nonatomic, assign) NSUInteger authTimeoutInterval;
@property (nonatomic, copy) NSDictionary<NSString *, NSString *> *presetSdnsParamsDict;
// scheduleCenter HttpdnsService_Internal.h
// scheduleCenter HttpdnsService_Internal.h <EFBFBD><EFBFBD>?
@end
@@ -58,9 +58,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
+ (void)initialize {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
asyncTaskConcurrentQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.asyncTask", DISPATCH_QUEUE_CONCURRENT);
asyncTaskConcurrentQueue = dispatch_queue_create("com.Trust.sdk.httpdns.asyncTask", DISPATCH_QUEUE_CONCURRENT);
httpdnsServiceInstances = [NSMutableDictionary dictionary];
httpdnsServiceInstancesQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.serviceRegistry", DISPATCH_QUEUE_SERIAL);
httpdnsServiceInstancesQueue = dispatch_queue_create("com.Trust.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", kAlicloudHttpdnsRegionKey, (long)accountID];
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kTrustHttpdnsRegionKey, (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 = ALICLOUD_HTTPDNS_DEFAULT_REGION_KEY;
region = Trust_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", kAlicloudHttpdnsRegionKey, (long)self.accountID];
NSString *regionKey = [NSString stringWithFormat:@"%@.%ld", kTrustHttpdnsRegionKey, (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:(AlicloudHttpDNS_IPType)ipType {
- (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(TrustHttpDNS_IPType)ipType {
HttpdnsQueryIPType ipQueryType;
switch (ipType) {
case AlicloudHttpDNS_IPTypeV4:
case TrustHttpDNS_IPTypeV4:
ipQueryType = HttpdnsQueryIPTypeIpv4;
break;
case AlicloudHttpDNS_IPTypeV6:
case TrustHttpDNS_IPTypeV6:
ipQueryType = HttpdnsQueryIPTypeIpv6;
break;
case AlicloudHttpDNS_IPTypeV64:
case TrustHttpDNS_IPTypeV64:
ipQueryType = HttpdnsQueryIPTypeIpv4 | HttpdnsQueryIPTypeIpv6;
break;
default:
@@ -284,7 +284,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
- (void)setPreResolveHosts:(NSArray *)hosts byIPType:(HttpdnsQueryIPType)ipType {
// regionregion
// sdk0.5
// sdk<EFBFBD><EFBFBD>?.5
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), asyncTaskConcurrentQueue, ^{
[self->_requestManager preResolveHosts:hosts queryType:ipType];
});
@@ -320,20 +320,20 @@ static HttpDnsService *httpdnsSharedStubInstance;
}
- (void)setIPv6Enabled:(BOOL)enable {
//
// <EFBFBD><EFBFBD>?
}
- (void)enableNetworkInfo:(BOOL)enable {
//
// <EFBFBD><EFBFBD>?
}
- (void)setReadNetworkInfoEnabled:(BOOL)enable {
//
// <EFBFBD><EFBFBD>?
}
- (void)enableCustomIPRank:(BOOL)enable {
//
// IPIPRankingDatasourceIPRankingDatasourcehostIP
// <EFBFBD><EFBFBD>?
// IPIPRankingDatasourceIPRankingDatasourcehostIP<EFBFBD><EFBFBD>?
}
- (NSString *)getSessionId {
@@ -357,7 +357,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
- (nullable HttpdnsResult *)resolveHostSync:(HttpdnsRequest *)request {
if ([NSThread isMainThread]) {
// 线
// 线<EFBFBD><EFBFBD>?
return [self resolveHostSyncNonBlocking:request];
}
@@ -456,7 +456,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
if (specifiedQueryIpType == HttpdnsQueryIPTypeAuto) {
HttpdnsIPStackType stackType = [[HttpdnsIpStackDetector sharedInstance] currentIpStack];
switch (stackType) {
// ipv6only
// ipv6only<EFBFBD><EFBFBD>?
// ipv6onlyipv4
// typeipv6
case kHttpdnsIpDual:
@@ -470,7 +470,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
}
}
//
// <EFBFBD><EFBFBD>?
return specifiedQueryIpType;
}
@@ -681,7 +681,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
}
//线线
if ([NSThread isMainThread]) {
//线使
//线使<EFBFBD><EFBFBD>?
HttpdnsRequest *request = [[HttpdnsRequest alloc] initWithHost:host queryIpType:HttpdnsQueryIPTypeIpv4];
[self attachAccountInfoToRequest:request];
[request becomeNonBlockingRequest];
@@ -839,7 +839,7 @@ static HttpDnsService *httpdnsSharedStubInstance;
}
if ([NSThread isMainThread]) {
// 线使
// 线使<EFBFBD><EFBFBD>?
HttpdnsRequest *request = [[HttpdnsRequest alloc] initWithHost:host queryIpType:HttpdnsQueryIPTypeIpv6];
[self attachAccountInfoToRequest:request];
[request becomeNonBlockingRequest];
@@ -888,9 +888,9 @@ static HttpDnsService *httpdnsSharedStubInstance;
if ([HttpdnsUtil isAnIP:host]) {
HttpdnsLogDebug("The host is just an IP: %@", host);
if ([HttpdnsUtil isIPv4Address:host]) {
return @{ALICLOUDHDNS_IPV4: @[host?:@""]};
return @{TrustHDNS_IPV4: @[host?:@""]};
} else if ([HttpdnsUtil isIPv6Address:host]) {
return @{ALICLOUDHDNS_IPV6: @[host?:@""]};
return @{TrustHDNS_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:ALICLOUDHDNS_IPV4];
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[resultMDic setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
[resultMDic setObject:ip6s forKey:TrustHDNS_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 @{ALICLOUDHDNS_IPV4: @[host?:@""]};
return @{TrustHDNS_IPV4: @[host?:@""]};
} else if ([HttpdnsUtil isIPv6Address:host]) {
return @{ALICLOUDHDNS_IPV6: @[host?:@""]};
return @{TrustHDNS_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:ALICLOUDHDNS_IPV4];
[httpdnsResult setObject:ip4s forKey:TrustHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[httpdnsResult setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
[httpdnsResult setObject:ip6s forKey:TrustHDNS_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 @{ALICLOUDHDNS_IPV4: @[host?:@""]};
return @{TrustHDNS_IPV4: @[host?:@""]};
} else if ([HttpdnsUtil isIPv6Address:host]) {
return @{ALICLOUDHDNS_IPV6: @[host?:@""]};
return @{TrustHDNS_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:ALICLOUDHDNS_IPV4];
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[resultMDic setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
[resultMDic setObject:ip6s forKey:TrustHDNS_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:ALICLOUDHDNS_IPV4];
[resultMDic setObject:ip4s forKey:TrustHDNS_IPV4];
}
if ([HttpdnsUtil isNotEmptyArray:ip6s]) {
[resultMDic setObject:ip6s forKey:ALICLOUDHDNS_IPV6];
[resultMDic setObject:ip6s forKey:TrustHDNS_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:ALICLOUDHDNS_IPV4];
[ipv4_ipv6 setObject:ipv4Ips forKey:TrustHDNS_IPV4];
}
} else if (stackType == kHttpdnsIpv6Only) {
NSArray* ipv6Ips = [self getIPv6sByHostAsync:host];
if (ipv6Ips != nil) {
[ipv4_ipv6 setObject:ipv6Ips forKey:ALICLOUDHDNS_IPV6];
[ipv4_ipv6 setObject:ipv6Ips forKey:TrustHDNS_IPV6];
}
}
@@ -1065,12 +1065,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
} else if (stackType == kHttpdnsIpv4Only) {
NSArray* ipv4IpList = [self getIPv4ListForHostAsync:host];
if (ipv4IpList) {
[httpdnsResult setObject:ipv4IpList forKey:ALICLOUDHDNS_IPV4];
[httpdnsResult setObject:ipv4IpList forKey:TrustHDNS_IPV4];
}
} else if (stackType == kHttpdnsIpv6Only) {
NSArray* ipv6List = [self getIPv6ListForHostAsync:host];
if (ipv6List) {
[httpdnsResult setObject:ipv6List forKey:ALICLOUDHDNS_IPV6];
[httpdnsResult setObject:ipv6List forKey:TrustHDNS_IPV6];
}
}
@@ -1083,14 +1083,14 @@ static HttpDnsService *httpdnsSharedStubInstance;
if (stackType == kHttpdnsIpv4Only) {
NSArray* ipv4IpList = [self getIPv4ListForHostSync:host];
if (ipv4IpList) {
[httpdnsResult setObject:ipv4IpList forKey:ALICLOUDHDNS_IPV4];
[httpdnsResult setObject:ipv4IpList forKey:TrustHDNS_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:ALICLOUDHDNS_IPV6];
[httpdnsResult setObject:ipv6List forKey:TrustHDNS_IPV6];
}
}
return httpdnsResult;

View File

@@ -1,9 +1,9 @@
//
// HttpdnsIpStackDetector.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2025/3/16.
// Copyright © 2025 alibaba-inc.com. All rights reserved.
// Copyright © 2025 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@@ -11,10 +11,10 @@
NS_ASSUME_NONNULL_BEGIN
/**
* IP 协议栈类
* IP 协议栈类<EFBFBD><EFBFBD>?
*/
typedef enum {
kHttpdnsIpUnknown = 0, // 未知协议
kHttpdnsIpUnknown = 0, // 未知协议<EFBFBD><EFBFBD>?
kHttpdnsIpv4Only = 1, // IPv4-only
kHttpdnsIpv6Only = 2, // IPv6-only
kHttpdnsIpDual = 3 // 双栈
@@ -23,13 +23,13 @@ typedef enum {
@interface HttpdnsIpStackDetector : NSObject
/**
* 返回HttpdnsIpStackDetector的共享实
* 返回HttpdnsIpStackDetector的共享实<EFBFBD><EFBFBD>?
* @return HttpdnsIpStackDetector实例
*/
+ (instancetype)sharedInstance;
/**
* 返回当前缓存的IP协议栈类型不执行检
* 返回当前缓存的IP协议栈类型不执行检<EFBFBD><EFBFBD>?
* @return HttpdnsIPStackType
*/
- (HttpdnsIPStackType)currentIpStack;
@@ -41,7 +41,7 @@ typedef enum {
- (BOOL)isIpv6OnlyNetwork;
/**
* 强制重新检测IP协议栈类
* 强制重新检测IP协议栈类<EFBFBD><EFBFBD>?
*/
- (void)redetectIpStack;

View File

@@ -1,16 +1,16 @@
//
// HttpdnsLog_Internal.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by junmo on 2018/12/19.
// Copyright © 2018年 alibaba-inc.com. All rights reserved.
// Copyright © 2018<EFBFBD><EFBFBD>?trustapp.com. All rights reserved.
//
#import "HttpdnsLog.h"
#import "HttpdnsLoggerProtocol.h"
#import <pthread/pthread.h>
// logHandler输出日志不受日志开关影
// logHandler输出日志不受日志开关影<EFBFBD><EFBFBD>?
#define HttpdnsLogDebug(frmt, ...) \
if ([HttpdnsLog validLogHandler]) { \
@try { \

View File

@@ -1,9 +1,9 @@
//
// HttpdnsLoggerProtocol.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by junmo on 2018/12/19.
// Copyright © 2018年 alibaba-inc.com. All rights reserved.
// Copyright © 2018<EFBFBD><EFBFBD>?trustapp.com. All rights reserved.
//
#ifndef HttpdnsLoggerProtocol_h

View File

@@ -52,7 +52,7 @@
@property (nonatomic, setter=setV6TTL:, getter=getV6TTL) int64_t v6ttl;
@property (nonatomic, assign) int64_t lastIPv6LookupTime;
// 用来标记该域名为配置v4记录或v6记录的情况避免如双栈网络下因为某个协议查不到record需要重复请
// 用来标记该域名为配置v4记录或v6记录的情况避免如双栈网络下因为某个协议查不到record需要重复请<EFBFBD><EFBFBD>?
// 这个信息不用持久化一次APP启动周期内使用是合适的
@property (nonatomic, assign) BOOL hasNoIpv4Record;
@property (nonatomic, assign) BOOL hasNoIpv6Record;
@@ -71,8 +71,8 @@
+ (instancetype)fromDBRecord:(HttpdnsHostRecord *)IPRecord;
/**
* 将当前对象转换为数据库记录对
* @return 数据库记录对
* 将当前对象转换为数据库记录对<EFBFBD><EFBFBD>?
* @return 数据库记录对<EFBFBD><EFBFBD>?
*/
- (HttpdnsHostRecord *)toDBRecord;
@@ -83,7 +83,7 @@
/**
* 更新指定IP的connectedRT值并重新排序IP列表
* @param ip 需要更新的IP地址
* @param connectedRT 检测到的RT值-1表示不可
* @param connectedRT 检测到的RT值-1表示不可<EFBFBD><EFBFBD>?
*/
- (void)updateConnectedRT:(NSInteger)connectedRT forIP:(NSString *)ip;

View File

@@ -29,7 +29,7 @@
- (instancetype)init {
if (self = [super init]) {
// connectedRT
// connectedRT<EFBFBD><EFBFBD>?
self.connectedRT = NSIntegerMax;
}
return self;
@@ -129,13 +129,13 @@
- (BOOL)isIpEmptyUnderQueryIpType:(HttpdnsQueryIPType)queryType {
if (queryType & HttpdnsQueryIPTypeIpv4) {
// _hasNoIpv4Recordtrueipv4ip
// _hasNoIpv4Recordtrueipv4ip<EFBFBD><EFBFBD>?
if ([HttpdnsUtil isEmptyArray:[self getV4Ips]] && !_hasNoIpv4Record) {
return YES;
}
} else if (queryType & HttpdnsQueryIPTypeIpv6 && !_hasNoIpv6Record) {
// _hasNoIpv6Recordtrueipv6ip
// _hasNoIpv6Recordtrueipv6ip<EFBFBD><EFBFBD>?
if ([HttpdnsUtil isEmptyArray:[self getV6Ips]] && !_hasNoIpv6Record) {
return YES;
}
@@ -202,14 +202,14 @@
}
- (HttpdnsHostRecord *)toDBRecord {
// IPIP
// IPIP<EFBFBD><EFBFBD>?
NSArray<NSString *> *v4IpStrings = [self getV4IpStrings];
NSArray<NSString *> *v6IpStrings = [self getV6IpStrings];
// modifyAt
NSDate *currentDate = [NSDate date];
// 使hostNamecacheKeyfromDBRecord
// 使hostNamecacheKeyfromDBRecord<EFBFBD><EFBFBD>?
return [[HttpdnsHostRecord alloc] initWithId:0 // ID
cacheKey:self.cacheKey
hostName:self.hostName
@@ -271,17 +271,17 @@
return;
}
// connectedRTIP-1
// connectedRTIP<EFBFBD><EFBFBD>?1<EFBFBD><EFBFBD>?
[mutableIpObjects sortUsingComparator:^NSComparisonResult(HttpdnsIpObject *obj1, HttpdnsIpObject *obj2) {
// obj1connectedRT-1
// obj1connectedRT<EFBFBD><EFBFBD>?1<EFBFBD><EFBFBD>?
if (obj1.connectedRT == -1) {
return NSOrderedDescending;
}
// obj2connectedRT-1
// obj2connectedRT<EFBFBD><EFBFBD>?1<EFBFBD><EFBFBD>?
if (obj2.connectedRT == -1) {
return NSOrderedAscending;
}
// connectedRT
// connectedRT<EFBFBD><EFBFBD>?
return obj1.connectedRT > obj2.connectedRT ? NSOrderedDescending : (obj1.connectedRT < obj2.connectedRT ? NSOrderedAscending : NSOrderedSame);
}];

View File

@@ -1,9 +1,9 @@
//
// HttpdnsHostRecord.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by ElonChan地风 on 2017/5/3.
// Copyright © 2017年 alibaba-inc.com. All rights reserved.
// Copyright © 2017<EFBFBD><EFBFBD>?trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@@ -1,9 +1,9 @@
//
// HttpdnsHostRecord.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by ElonChan on 2017/5/3.
// Copyright © 2017 alibaba-inc.com. All rights reserved.
// Copyright © 2017<EFBFBD><EFBFBD>?trustapp.com. All rights reserved.
//
#import "HttpdnsHostRecord.h"

View File

@@ -1,23 +1,23 @@
//
// HttpdnsRequest.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/5/19.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#ifndef ALICLOUDHTTPDNSQUERYIPTYPE
#define ALICLOUDHTTPDNSQUERYIPTYPE
#ifndef TrustHTTPDNSQUERYIPTYPE
#define TrustHTTPDNSQUERYIPTYPE
typedef enum {
AlicloudHttpDNS_IPTypeV4 = 0, //ipv4
AlicloudHttpDNS_IPTypeV6 = 1, //ipv6
AlicloudHttpDNS_IPTypeV64 = 2, //ipv4 + ipv6
} AlicloudHttpDNS_IPType;
TrustHttpDNS_IPTypeV4 = 0, //ipv4
TrustHttpDNS_IPTypeV6 = 1, //ipv6
TrustHttpDNS_IPTypeV64 = 2, //ipv4 + ipv6
} TrustHttpDNS_IPType;
typedef NS_OPTIONS(NSUInteger, HttpdnsQueryIPType) {
HttpdnsQueryIPTypeAuto NS_SWIFT_NAME(auto) = 0,
@@ -33,15 +33,15 @@ typedef NS_OPTIONS(NSUInteger, HttpdnsQueryIPType) {
/// 需要解析的域名
@property (nonatomic, copy) NSString *host;
/// 解析超时时间,对于同步接口,即为最大等待时间,对于异步接口,即为最大等待回调时
/// 默认值2取值必须在0.5- 5秒之
/// 解析超时时间,对于同步接口,即为最大等待时间,对于异步接口,即为最大等待回调时<EFBFBD><EFBFBD>?
/// 默认<EFBFBD><EFBFBD>?取值必须在0.5<EFBFBD><EFBFBD>?- 5秒之<EFBFBD><EFBFBD>?
@property (nonatomic, assign) double resolveTimeoutInSecond;
/// 查询IP类型
/// 默认为HttpdnsQueryIPTypeAuto此类型下SDK至少会请求解析ipv4地址若判断到当前网络环境支持ipv6则还会请求解析ipv6地址
/// HttpdnsQueryIPTypeIpv4只请求解析ipv4
/// HttpdnsQueryIPTypeIpv6只请求解析ipv6
/// HttpdnsQueryIPTypeBoth不管当前网络环境是什么会尝试同时请求解析ipv4地址和ipv6地址这种用法通常需要拿到结果之后自行判断网络环境决定使用哪个结
/// HttpdnsQueryIPTypeBoth不管当前网络环境是什么会尝试同时请求解析ipv4地址和ipv6地址这种用法通常需要拿到结果之后自行判断网络环境决定使用哪个结<EFBFBD><EFBFBD>?
@property (nonatomic, assign) HttpdnsQueryIPType queryIpType;
/// SDNS参数针对软件自定义解析场景使用

View File

@@ -1,9 +1,9 @@
//
// HttpdnsRequest.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/5/19.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import "HttpdnsRequest.h"
@@ -65,7 +65,7 @@ static double const RESOLVE_HOST_MAX_TIMEOUT_IN_SEC = 5;
} else if (_resolveTimeoutInSecond > RESOLVE_HOST_MAX_TIMEOUT_IN_SEC) {
_resolveTimeoutInSecond = RESOLVE_HOST_MAX_TIMEOUT_IN_SEC;
} else {
//
// <EFBFBD><EFBFBD>?
}
}

View File

@@ -1,9 +1,9 @@
//
// HttpdnsRequest_Internal.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/6/19.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#ifndef HttpdnsRequest_Internal_h

View File

@@ -1,9 +1,9 @@
//
// HttpdnsResult.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/5/15.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@@ -1,9 +1,9 @@
//
// HttpdnsResult.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/5/15.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import "HttpdnsResult.h"

View File

@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface HttpdnsNWHTTPClient : NSObject
/// 全局共享实例,复用底层连接池;线程安
/// 全局共享实例,复用底层连接池;线程安<EFBFBD><EFBFBD>?
+ (instancetype)sharedInstance;
- (nullable HttpdnsNWHTTPClientResponse *)performRequestWithURLString:(NSString *)urlString

View File

@@ -30,7 +30,7 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
@property (nonatomic, strong) dispatch_queue_t poolQueue;
#if DEBUG
//
// <EFBFBD><EFBFBD>?
@property (atomic, assign) NSUInteger connectionCreationCount;
@property (atomic, assign) NSUInteger connectionReuseCount;
#endif
@@ -81,7 +81,7 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
- (instancetype)init {
self = [super init];
if (self) {
_poolQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.network.pool", DISPATCH_QUEUE_SERIAL);
_poolQueue = dispatch_queue_create("com.Trust.sdk.httpdns.network.pool", DISPATCH_QUEUE_SERIAL);
_connectionPool = [NSMutableDictionary dictionary];
}
return self;
@@ -95,8 +95,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSURL *url = [NSURL URLWithString:urlString];
if (!url) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Invalid resolve URL"}];
}
return nil;
@@ -107,8 +107,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSString *host = url.host;
if (![HttpdnsUtil isNotEmptyString:host]) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Missing host in resolve URL"}];
}
return nil;
@@ -121,8 +121,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSData *requestData = [requestString dataUsingEncoding:NSUTF8StringEncoding];
if (!requestData) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Failed to encode HTTP request"}];
}
return nil;
@@ -136,8 +136,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
error:&connectionError];
if (!connection) {
if (error) {
*error = connectionError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = connectionError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Unable to obtain network connection"}];
}
return nil;
@@ -154,8 +154,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
if (!rawResponse) {
[self returnConnection:connection forKey:poolKey shouldClose:YES];
if (error) {
*error = exchangeError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = exchangeError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Network request failed"}];
}
return nil;
@@ -168,8 +168,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
if (![self parseHTTPResponseData:rawResponse statusCode:&statusCode headers:&headers body:&bodyData error:&parseError]) {
[self returnConnection:connection forKey:poolKey shouldClose:YES];
if (error) {
*error = parseError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = parseError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Failed to parse HTTP response"}];
}
return nil;
@@ -239,8 +239,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
useTLS:useTLS];
if (!newConnection) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Failed to create network connection"}];
}
return nil;
@@ -409,8 +409,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSString *headerString = [[NSString alloc] initWithData:headerData encoding:NSUTF8StringEncoding];
if (![HttpdnsUtil isNotEmptyString:headerString]) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Failed to decode HTTP headers"}];
}
return HttpdnsHTTPHeaderParseResultError;
@@ -419,8 +419,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSArray<NSString *> *lines = [headerString componentsSeparatedByString:@"\r\n"];
if (lines.count == 0) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Missing HTTP status line"}];
}
return HttpdnsHTTPHeaderParseResultError;
@@ -437,8 +437,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
if (filteredParts.count < 2) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid HTTP status line"}];
}
return HttpdnsHTTPHeaderParseResultError;
@@ -447,8 +447,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSInteger localStatus = [filteredParts[1] integerValue];
if (localStatus <= 0) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid HTTP status code"}];
}
return HttpdnsHTTPHeaderParseResultError;
@@ -510,8 +510,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSString *sizeString = [[NSString alloc] initWithData:sizeData encoding:NSUTF8StringEncoding];
if (![HttpdnsUtil isNotEmptyString:sizeString]) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid chunk size"}];
}
return HttpdnsHTTPChunkParseResultError;
@@ -524,8 +524,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
unsigned long long chunkSize = strtoull(cStr, &endPtr, 16);
if (endPtr == NULL || endPtr == cStr) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid chunk size"}];
}
return HttpdnsHTTPChunkParseResultError;
@@ -533,8 +533,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
if (chunkSize > NSUIntegerMax - cursor) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Chunk size overflow"}];
}
return HttpdnsHTTPChunkParseResultError;
@@ -570,8 +570,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
}
if (bytes[cursor] != '\r' || bytes[cursor + 1] != '\n') {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid chunk terminator"}];
}
return HttpdnsHTTPChunkParseResultError;
@@ -589,8 +589,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
error:(NSError **)error {
if (!data || data.length == 0) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Empty HTTP response"}];
}
return NO;
@@ -608,8 +608,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
if (headerResult != HttpdnsHTTPHeaderParseResultSuccess) {
if (error) {
if (headerResult == HttpdnsHTTPHeaderParseResultIncomplete) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Missing HTTP header terminator"}];
} else {
*error = headerError;
@@ -670,8 +670,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
}
if (lineEnd + 1 >= length) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid chunked encoding"}];
}
return nil;
@@ -681,8 +681,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
NSString *sizeString = [[NSString alloc] initWithData:sizeData encoding:NSUTF8StringEncoding];
if (![HttpdnsUtil isNotEmptyString:sizeString]) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid chunk size"}];
}
return nil;
@@ -695,8 +695,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
//
if (endPtr == cStr) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid chunk size format"}];
}
return nil;
@@ -710,8 +710,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
}
if (cursor + chunkSize > length) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Chunk size exceeds buffer"}];
}
return nil;
@@ -720,8 +720,8 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
cursor += chunkSize;
if (cursor + 1 >= length || bytes[cursor] != '\r' || bytes[cursor + 1] != '\n') {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Invalid chunk terminator"}];
}
return nil;
@@ -734,7 +734,7 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust forDomain:(NSString *)domain {
// TLS
// HTTPDNS_SKIP_TLS_VERIFY mock server
// HTTPDNS_SKIP_TLS_VERIFY mock server <EFBFBD><EFBFBD>?
if (getenv("HTTPDNS_SKIP_TLS_VERIFY") != NULL) {
return YES;
}
@@ -777,15 +777,15 @@ static const NSTimeInterval kHttpdnsNWHTTPClientDefaultTimeout = 10.0;
if (!userInfo[NSLocalizedDescriptionKey]) {
userInfo[NSLocalizedDescriptionKey] = @"Network operation failed";
}
return [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
return [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:userInfo];
}
@end
#if DEBUG
// API
// <EFBFBD><EFBFBD>?API
@implementation HttpdnsNWHTTPClient (TestInspection)
- (NSUInteger)connectionPoolCountForKey:(NSString *)key {

View File

@@ -30,7 +30,7 @@ typedef NS_ENUM(NSInteger, HttpdnsHTTPChunkParseResult) {
headers:(NSDictionary<NSString *, NSString *> *__autoreleasing _Nullable * _Nullable)headers
error:(NSError * _Nullable * _Nullable)error;
// Chunked 编码检
// Chunked 编码检<EFBFBD><EFBFBD>?
- (HttpdnsHTTPChunkParseResult)checkChunkedBodyCompletionInData:(NSData *)data
headerEndIndex:(NSUInteger)headerEndIndex
error:(NSError * _Nullable * _Nullable)error;
@@ -48,7 +48,7 @@ typedef NS_ENUM(NSInteger, HttpdnsHTTPChunkParseResult) {
// HTTP 请求构建
- (NSString *)buildHTTPRequestStringWithURL:(NSURL *)url userAgent:(NSString *)userAgent;
// 连接key 生成
// 连接<EFBFBD><EFBFBD>?key 生成
- (NSString *)connectionPoolKeyForHost:(NSString *)host port:(NSString *)port useTLS:(BOOL)useTLS;
// 错误转换
@@ -57,10 +57,10 @@ typedef NS_ENUM(NSInteger, HttpdnsHTTPChunkParseResult) {
@end
#if DEBUG
// 测试专用:连接池检API
// 测试专用:连接池检<EFBFBD><EFBFBD>?API
@interface HttpdnsNWHTTPClient (TestInspection)
// 获取指定 pool key 的连接数
// 获取指定 pool key 的连接数<EFBFBD><EFBFBD>?
- (NSUInteger)connectionPoolCountForKey:(NSString *)key;
// 获取所有连接池 keys
@@ -75,7 +75,7 @@ typedef NS_ENUM(NSInteger, HttpdnsHTTPChunkParseResult) {
// 连接复用计数(用于验证连接复用)
@property (atomic, assign) NSUInteger connectionReuseCount;
// 重置统计计数器(每个测试开始前调用
// 重置统计计数器(每个测试开始前调用<EFBFBD><EFBFBD>?
- (void)resetPoolStatistics;
@end

View File

@@ -32,8 +32,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface HttpdnsNWReusableConnection (DebugInspection)
// 状态检查(这些属性已在主接口暴露,这里仅为文档明确)
// @property lastUsedDate - 可读
// @property inUse - 可读
// @property lastUsedDate - 可读<EFBFBD><EFBFBD>?
// @property inUse - 可读<EFBFBD><EFBFBD>?
// @property invalidated - 只读
// 测试辅助方法

View File

@@ -13,7 +13,7 @@
@class HttpdnsNWHTTPClient;
// /
// <EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?
@interface HttpdnsNWHTTPExchange : NSObject
@property (nonatomic, strong, readonly) NSMutableData *buffer;
@@ -99,7 +99,7 @@
_host = [host copy];
_port = [port copy];
_useTLS = useTLS;
_queue = dispatch_queue_create("com.alibaba.sdk.httpdns.network.connection.reuse", DISPATCH_QUEUE_SERIAL);
_queue = dispatch_queue_create("com.Trust.sdk.httpdns.network.connection.reuse", DISPATCH_QUEUE_SERIAL);
_stateSemaphore = dispatch_semaphore_create(0);
_state = nw_connection_state_invalid;
_lastUsedDate = [NSDate date];
@@ -135,14 +135,14 @@
if (secTrust && strongSelf) {
SecTrustRef trustRef = sec_trust_copy_ref(secTrust);
if (trustRef) {
NSString *validIP = ALICLOUD_HTTPDNS_VALID_SERVER_CERTIFICATE_IP;
NSString *validIP = Trust_HTTPDNS_VALID_SERVER_CERTIFICATE_IP;
isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:validIP];
if (!isValid && [HttpdnsUtil isNotEmptyString:strongSelf.host]) {
isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:strongSelf.host];
}
if (!isValid && !strongSelf.stateError) {
strongSelf.stateError = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
strongSelf.stateError = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"TLS trust validation failed"}];
}
CFRelease(trustRef);
@@ -220,8 +220,8 @@
- (BOOL)openWithTimeout:(NSTimeInterval)timeout error:(NSError **)error {
if (self.invalidated) {
if (error) {
*error = _stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection invalid"}];
}
return NO;
@@ -237,8 +237,8 @@
if (waitResult != 0) {
self.invalidated = YES;
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection setup timed out"}];
}
nw_connection_cancel(_connectionHandle);
@@ -250,8 +250,8 @@
}
if (error) {
*error = _stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection failed to become ready"}];
}
return NO;
@@ -277,8 +277,8 @@
error:(NSError **)error {
if (!requestData || requestData.length == 0) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Empty HTTP request"}];
}
return nil;
@@ -286,8 +286,8 @@
if (![self isViable] || self.currentExchange) {
if (error) {
*error = _stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection not ready"}];
}
return nil;
@@ -299,16 +299,16 @@
dispatch_sync(_queue, ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection released unexpectedly"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
return;
}
if (strongSelf.invalidated || strongSelf.currentExchange) {
exchange.error = strongSelf.stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = strongSelf.stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection is busy"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
@@ -320,8 +320,8 @@
if (exchange.finished) {
return;
}
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Request timed out"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
@@ -366,8 +366,8 @@
if (waitResult != 0) {
if (!exchange.error) {
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Request wait timed out"}];
}
[self invalidate];
@@ -428,8 +428,8 @@
if (is_complete) {
exchange.remoteClosed = YES;
if (!exchange.finished) {
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection closed before response completed"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
@@ -452,7 +452,7 @@
}
if (isComplete) {
//
// <EFBFBD><EFBFBD>?
exchange.remoteClosed = YES;
}
@@ -527,7 +527,7 @@
@end
#if DEBUG
//
// <EFBFBD><EFBFBD>?
@implementation HttpdnsNWReusableConnection (DebugInspection)
- (void)debugSetLastUsedDate:(nullable NSDate *)date {

View File

@@ -1,9 +1,9 @@
//
// HttpdnsDB.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2025/3/15.
// Copyright © 2025 alibaba-inc.com. All rights reserved.
// Copyright © 2025 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@@ -19,53 +19,53 @@ NS_ASSUME_NONNULL_BEGIN
/**
* 初始化数据库
* @param accountId 账户ID
* @return 数据库实
* @return 数据库实<EFBFBD><EFBFBD>?
*/
- (instancetype)initWithAccountId:(NSInteger)accountId;
/**
* 创建或更新记
* 创建或更新记<EFBFBD><EFBFBD>?
* @param record 主机记录
* @return 是否成功
*/
- (BOOL)createOrUpdate:(HttpdnsHostRecord *)record;
/**
* 根据缓存键查询记
* @param cacheKey 缓存
* 根据缓存键查询记<EFBFBD><EFBFBD>?
* @param cacheKey 缓存<EFBFBD><EFBFBD>?
* @return 查询到的记录如果不存在则返回nil
*/
- (nullable HttpdnsHostRecord *)selectByCacheKey:(NSString *)cacheKey;
/**
* 根据缓存键删除记
* @param cacheKey 缓存
* 根据缓存键删除记<EFBFBD><EFBFBD>?
* @param cacheKey 缓存<EFBFBD><EFBFBD>?
* @return 是否成功
*/
- (BOOL)deleteByCacheKey:(NSString *)cacheKey;
/**
* 根据主机名数组批量删除记
* @param hostNameArr 主机名数
* @return 成功删除的记录数
* 根据主机名数组批量删除记<EFBFBD><EFBFBD>?
* @param hostNameArr 主机名数<EFBFBD><EFBFBD>?
* @return 成功删除的记录数<EFBFBD><EFBFBD>?
*/
- (NSInteger)deleteByHostNameArr:(NSArray<NSString *> *)hostNameArr;
/**
* 获取所有缓存记
* @return 所有缓存记录数
* 获取所有缓存记<EFBFBD><EFBFBD>?
* @return 所有缓存记录数<EFBFBD><EFBFBD>?
*/
- (NSArray<HttpdnsHostRecord *> *)getAllRecords;
/**
* 清理指定时间点已过期的记
* @param specifiedTime 指定的时间点epoch时间
* @return 清理的记录数
* 清理指定时间点已过期的记<EFBFBD><EFBFBD>?
* @param specifiedTime 指定的时间点epoch时间<EFBFBD><EFBFBD>?
* @return 清理的记录数<EFBFBD><EFBFBD>?
*/
- (NSInteger)cleanRecordAlreadExpiredAt:(NSTimeInterval)specifiedTime;
/**
* 删除所有记
* 删除所有记<EFBFBD><EFBFBD>?
* @return 是否成功
*/
- (BOOL)deleteAll;

View File

@@ -23,7 +23,7 @@
+ (NSString *)httpdnsDataDirectory;
+ (NSString *)scheduleCenterResultDirectory;
/// 多账号隔离:返回指定账号的调度结果目
/// 多账号隔离:返回指定账号的调度结果目<EFBFBD><EFBFBD>?
+ (NSString *)scheduleCenterResultDirectoryForAccount:(NSInteger)accountId;
+ (BOOL)saveJSON:(id)JSON toPath:(NSString *)path;

View File

@@ -21,8 +21,8 @@
#import "HttpdnsService.h"
#import "HttpdnsUtil.h"
static NSString *const ALICLOUD_HTTPDNS_ROOT_DIR_NAME = @"HTTPDNS";
static NSString *const ALICLOUD_HTTPDNS_HOST_CACHE_DIR_NAME = @"HostCache";
static NSString *const Trust_HTTPDNS_ROOT_DIR_NAME = @"HTTPDNS";
static NSString *const Trust_HTTPDNS_HOST_CACHE_DIR_NAME = @"HostCache";
static dispatch_queue_t _fileCacheQueue = 0;
@@ -33,7 +33,7 @@ static dispatch_queue_t _fileCacheQueue = 0;
+ (void)initialize {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_fileCacheQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.fileCacheQueue", DISPATCH_QUEUE_SERIAL);
_fileCacheQueue = dispatch_queue_create("com.Trust.sdk.httpdns.fileCacheQueue", DISPATCH_QUEUE_SERIAL);
});
}

View File

@@ -21,8 +21,8 @@
@interface HttpdnsScheduleCenter : NSObject
/// 针对多账号场景的调度中心构造方
/// 注意:若无需多账号隔离,可继续使sharedInstance
/// 针对多账号场景的调度中心构造方<EFBFBD><EFBFBD>?
/// 注意:若无需多账号隔离,可继续使<EFBFBD><EFBFBD>?sharedInstance
- (instancetype)initWithAccountId:(NSInteger)accountId;
- (void)initRegion:(NSString *)region;

View File

@@ -1,9 +1,9 @@
//
// HttpdnsScheduleExecutor.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by ElonChan地风 on 2017/4/11.
// Copyright © 2017年 alibaba-inc.com. All rights reserved.
// Copyright © 2017<EFBFBD><EFBFBD>?trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@@ -1,9 +1,9 @@
//
// HttpdnsScheduleExecutor.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by ElonChan on 2017/4/11.
// Copyright © 2017 alibaba-inc.com. All rights reserved.
// Copyright © 2017<EFBFBD><EFBFBD>?trustapp.com. All rights reserved.
//
#import "HttpdnsScheduleExecutor.h"
@@ -94,8 +94,8 @@
if (response.statusCode != 200) {
NSDictionary *dict = @{@"ResponseCode": [NSString stringWithFormat:@"%ld", (long)response.statusCode]};
if (pError) {
*pError = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE
*pError = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE
userInfo:dict];
}
return nil;
@@ -118,8 +118,8 @@
}
if (pError) {
*pError = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTP_PARSE_JSON_FAILED
*pError = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Failed to parse JSON response"}];
}
if (pError != NULL) {

View File

@@ -1,9 +1,9 @@
//
// HttpDnsLocker.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by 王贇 on 2023/8/16.
// Copyright © 2023 alibaba-inc.com. All rights reserved.
// Copyright © 2023 trustapp.com. All rights reserved.
//
#ifndef HttpDnsLocker_h

View File

@@ -1,9 +1,9 @@
//
// HttpDnsLocker.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by on 2023/8/16.
// Copyright © 2023 alibaba-inc.com. All rights reserved.
// Copyright © 2023 trustapp.com. All rights reserved.
//
#import "HttpDnsLocker.h"

View File

@@ -1,9 +1,9 @@
//
// HttpdnsHostObjectInMemoryCache.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/9/28.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@@ -11,10 +11,10 @@
NS_ASSUME_NONNULL_BEGIN
// 这个字典在HTTPDNS中只用于存储HttpdnsHostObject对象这个对象是整个框架的核心对象用于缓存和处理域名解析结
// 通常从缓存中获得这个对象之后,会根据不同场景改变一些字段的值,而且很可能发生在不同线程
// 这个字典在HTTPDNS中只用于存储HttpdnsHostObject对象这个对象是整个框架的核心对象用于缓存和处理域名解析结<EFBFBD><EFBFBD>?
// 通常从缓存中获得这个对象之后,会根据不同场景改变一些字段的值,而且很可能发生在不同线程<EFBFBD><EFBFBD>?
// 而不同线程从缓存中直接读取共享对象的话很有可能发生线程竞争的情况多线程访问某个对象的同一个字段在swift环境有较高概率发生crash
// 因此除了确保字典操作的线程安全拿出对象的时候也直接copy一个复制对象返回(HttpdnsHostObject对象实现了NSCopying协议)
// 因此除了确保字典操作的线程安全拿出对象的时候也直接copy一个复制对象返<EFBFBD><EFBFBD>?HttpdnsHostObject对象实现了NSCopying协议)
@interface HttpdnsHostObjectInMemoryCache : NSObject
- (void)setHostObject:(HttpdnsHostObject *)object forCacheKey:(NSString *)key;

View File

@@ -1,9 +1,9 @@
//
// HttpdnsHostObjectInMemoryCache.m
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2024/9/28.
// Copyright © 2024 alibaba-inc.com. All rights reserved.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import "HttpdnsHostObjectInMemoryCache.h"

View File

@@ -1,9 +1,9 @@
//
// HttpdnsIPQualityDetector.h
// AlicloudHttpDNS
// TrustHttpDNS
//
// Created by xuyecan on 2025/3/13.
// Copyright © 2025 alibaba-inc.com. All rights reserved.
// Copyright © 2025 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@@ -11,10 +11,10 @@
NS_ASSUME_NONNULL_BEGIN
/**
* IP质量检测回
* @param cacheKey 缓存
* IP质量检测回<EFBFBD><EFBFBD>?
* @param cacheKey 缓存<EFBFBD><EFBFBD>?
* @param ip IP地址
* @param costTime 连接耗时(毫秒)-1表示连接失败
* @param costTime 连接耗时(毫秒)<EFBFBD><EFBFBD>?1表示连接失败
*/
typedef void(^HttpdnsIPQualityCallback)(NSString *cacheKey, NSString *ip, NSInteger costTime);
@@ -32,10 +32,10 @@ typedef void(^HttpdnsIPQualityCallback)(NSString *cacheKey, NSString *ip, NSInte
/**
* 调度一个IP连接质量检测任务不会阻塞当前线程
* @param cacheKey 缓存键,通常是域
* @param cacheKey 缓存键,通常是域<EFBFBD><EFBFBD>?
* @param ip 要检测的IP地址
* @param port 连接端口如果为nil则默认使用80
* @param callback 检测完成后的回
* @param port 连接端口如果为nil则默认使<EFBFBD><EFBFBD>?0
* @param callback 检测完成后的回<EFBFBD><EFBFBD>?
*/
- (void)scheduleIPQualityDetection:(NSString *)cacheKey
ip:(NSString *)ip
@@ -45,12 +45,12 @@ typedef void(^HttpdnsIPQualityCallback)(NSString *cacheKey, NSString *ip, NSInte
#pragma mark - Methods exposed for testing
/**
* 执行IP连接质量检
* @param cacheKey 缓存键,通常是域
* 执行IP连接质量检<EFBFBD><EFBFBD>?
* @param cacheKey 缓存键,通常是域<EFBFBD><EFBFBD>?
* @param ip 要检测的IP地址
* @param port 连接端口如果为nil则默认使用80
* @param callback 检测完成后的回
* @note 此方法主要用于测
* @param port 连接端口如果为nil则默认使<EFBFBD><EFBFBD>?0
* @param callback 检测完成后的回<EFBFBD><EFBFBD>?
* @note 此方法主要用于测<EFBFBD><EFBFBD>?
*/
- (void)executeDetection:(NSString *)cacheKey
ip:(NSString *)ip
@@ -58,21 +58,21 @@ typedef void(^HttpdnsIPQualityCallback)(NSString *cacheKey, NSString *ip, NSInte
callback:(HttpdnsIPQualityCallback)callback;
/**
* 建立TCP连接并测量连接时
* 建立TCP连接并测量连接时<EFBFBD><EFBFBD>?
* @param ip 要连接的IP地址
* @param port 连接端口
* @return 连接耗时(毫秒)-1表示连接失败
* @note 此方法主要用于测
* @return 连接耗时(毫秒)<EFBFBD><EFBFBD>?1表示连接失败
* @note 此方法主要用于测<EFBFBD><EFBFBD>?
*/
- (NSInteger)tcpConnectToIP:(NSString *)ip port:(int)port;
/**
* 添加待处理任
* @param cacheKey 缓存键,通常是域
* 添加待处理任<EFBFBD><EFBFBD>?
* @param cacheKey 缓存键,通常是域<EFBFBD><EFBFBD>?
* @param ip 要检测的IP地址
* @param port 连接端口
* @param callback 检测完成后的回
* @note 此方法主要用于测
* @param callback 检测完成后的回<EFBFBD><EFBFBD>?
* @note 此方法主要用于测<EFBFBD><EFBFBD>?
*/
- (void)addPendingTask:(NSString *)cacheKey
ip:(NSString *)ip
@@ -80,14 +80,14 @@ typedef void(^HttpdnsIPQualityCallback)(NSString *cacheKey, NSString *ip, NSInte
callback:(HttpdnsIPQualityCallback)callback;
/**
* 处理待处理任务队
* @note 此方法主要用于测
* 处理待处理任务队<EFBFBD><EFBFBD>?
* @note 此方法主要用于测<EFBFBD><EFBFBD>?
*/
- (void)processPendingTasksIfNeeded;
/**
* 处理所有待处理任务
* @note 此方法主要用于测
* @note 此方法主要用于测<EFBFBD><EFBFBD>?
*/
- (void)processPendingTasks;

View File

@@ -463,7 +463,7 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
return HttpdnsReachableVia5G;
}
}
// 使广4G
// 使广<EFBFBD><EFBFBD>?G
return HttpdnsReachableVia4G;
#endif
}

View File

@@ -222,8 +222,8 @@
/**
sessionId
App
sessionId12base62
App<EFBFBD><EFBFBD>?
sessionId<EFBFBD><EFBFBD>?2base62
*/
+ (NSString *)generateSessionID {
static NSString *sessionId = nil;
@@ -256,11 +256,11 @@
+ (NSData *)encryptDataAESCBC:(NSData *)plaintext
withKey:(NSData *)key
error:(NSError **)error {
//
// <EFBFBD><EFBFBD>?
if (plaintext == nil || [plaintext length] == 0 || key == nil || [key length] != kCCKeySizeAES128) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Invalid input parameters"}];
}
return nil;
@@ -271,18 +271,18 @@
int result = SecRandomCopyBytes(kSecRandomDefault, kCCBlockSizeAES128, iv.mutableBytes);
if (result != 0) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Failed to generate random IV"}];
}
return nil;
}
// ()
// (<EFBFBD><EFBFBD>?
size_t bufferSize = [plaintext length] + kCCBlockSizeAES128;
size_t encryptedSize = 0;
//
// <EFBFBD><EFBFBD>?
NSMutableData *cipherData = [NSMutableData dataWithLength:bufferSize];
//
@@ -301,17 +301,17 @@
if (cryptStatus != kCCSuccess) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Encryption failed with status: %d", cryptStatus]}];
}
return nil;
}
//
// <EFBFBD><EFBFBD>?
[cipherData setLength:encryptedSize];
// IV
// IV<EFBFBD><EFBFBD>?
NSMutableData *resultData = [NSMutableData dataWithData:iv];
[resultData appendData:cipherData];
@@ -338,7 +338,7 @@
return nil;
}
//
// <EFBFBD><EFBFBD>?
NSString *cleanedString = [hexString stringByReplacingOccurrencesOfString:@" " withString:@""];
//
@@ -391,25 +391,25 @@
+ (NSData *)decryptDataAESCBC:(NSData *)ciphertext
withKey:(NSData *)key
error:(NSError **)error {
//
// <EFBFBD><EFBFBD>?
if (ciphertext == nil || [ciphertext length] <= kCCBlockSizeAES128 || key == nil || [key length] != kCCKeySizeAES128) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Invalid input parameters for decryption"}];
}
return nil;
}
// IV16
// IV16<EFBFBD><EFBFBD>?
NSData *iv = [ciphertext subdataWithRange:NSMakeRange(0, kCCBlockSizeAES128)];
NSData *actualCiphertext = [ciphertext subdataWithRange:NSMakeRange(kCCBlockSizeAES128, ciphertext.length - kCCBlockSizeAES128)];
//
// <EFBFBD><EFBFBD>?
size_t bufferSize = actualCiphertext.length + kCCBlockSizeAES128;
size_t decryptedSize = 0;
//
// <EFBFBD><EFBFBD>?
NSMutableData *decryptedData = [NSMutableData dataWithLength:bufferSize];
//
@@ -427,14 +427,14 @@
if (cryptStatus != kCCSuccess) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Decryption failed with status: %d", cryptStatus]}];
}
return nil;
}
//
// <EFBFBD><EFBFBD>?
[decryptedData setLength:decryptedSize];
return decryptedData;
@@ -453,14 +453,14 @@
if (dnsService.ttlDelegate && [dnsService.ttlDelegate respondsToSelector:@selector(httpdnsHost:ipType:ttl:)]) {
if ([self isNotEmptyArray:[hostObject getV4Ips]]) {
int64_t customV4TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:AlicloudHttpDNS_IPTypeV4 ttl:hostObject.v4ttl];
int64_t customV4TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:TrustHttpDNS_IPTypeV4 ttl:hostObject.v4ttl];
if (customV4TTL > 0) {
hostObject.v4ttl = customV4TTL;
}
}
if ([self isNotEmptyArray:[hostObject getV6Ips]]) {
int64_t customV6TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:AlicloudHttpDNS_IPTypeV6 ttl:hostObject.v6ttl];
int64_t customV6TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:TrustHttpDNS_IPTypeV6 ttl:hostObject.v6ttl];
if (customV6TTL > 0) {
hostObject.v6ttl = customV6TTL;
}