带阿里标识的版本
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#import "HttpdnsEdgeService.h"
|
||||
#import "HttpdnsEdgeService.h"
|
||||
|
||||
#import <CommonCrypto/CommonCrypto.h>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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; // 同时支持IPv4和IPv6
|
||||
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
|
||||
// connectedRT默认为0
|
||||
// connectedRT默认<EFBFBD><EFBFBD>?
|
||||
[v4IpObjects addObject:ipObj];
|
||||
}
|
||||
}
|
||||
@@ -123,17 +123,17 @@
|
||||
[hostObject setV4Ips:v4IpObjects];
|
||||
[hostObject setV6Ips:v6IpObjects];
|
||||
|
||||
// IPv4和IPv6的默认TTL为60秒
|
||||
// IPv4和IPv6的默认TTL<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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
// 设置IPv4的TTL
|
||||
[self setTTLForHostObject:hostObject fromData:v4Data forIPv6:NO];
|
||||
|
||||
// 处理v4的extra字段,优先使用
|
||||
// 处理v4的extra字段,优先使<EFBFBD><EFBFBD>?
|
||||
[self processExtraInfo:v4Data forHostObject:hostObject];
|
||||
|
||||
// 检查是否有no_ip_code字段,表示无IPv4记录
|
||||
@@ -259,7 +259,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
|
||||
hostObject.hasNoIpv4Record = YES;
|
||||
}
|
||||
} else {
|
||||
// 没有IPv4地址但有v4节点,可能是无记录
|
||||
// 没有IPv4地址但有v4节点,可能是无记<EFBFBD><EFBFBD>?
|
||||
hostObject.hasNoIpv4Record = YES;
|
||||
}
|
||||
}
|
||||
@@ -289,12 +289,12 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
|
||||
hostObject.hasNoIpv6Record = YES;
|
||||
}
|
||||
} else {
|
||||
// 没有IPv6地址但有v6节点,可能是无记录
|
||||
// 没有IPv6地址但有v6节点,可能是无记<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) {
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
// 缓存是以cacheKey为准,这里返回前,要把host替换成用户请求的这个
|
||||
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;
|
||||
|
||||
@@ -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 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析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 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析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 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6
|
||||
/// @handler 解析结果回调
|
||||
- (void)resolveHostAsync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType completionHandler:(void (^)(HttpdnsResult * nullable))handler;
|
||||
|
||||
/// 异步解析域名,不会阻塞当前线程,会在从缓存中获取到有效结果,或从服务器拿到最新解析结果后,通过回调返回结果
|
||||
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结果
|
||||
/// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结<EFBFBD><EFBFBD>?
|
||||
/// @param host 需要解析的域名
|
||||
/// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析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 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6
|
||||
/// @return 解析结果
|
||||
- (nullable HttpdnsResult *)resolveHostSyncNonBlocking:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType;
|
||||
|
||||
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为空
|
||||
/// 先查询缓存,缓存中存在有效结果(未过期,或者过期但配置了可以复用过期解析结果),则直接返回结果,如果缓存未命中,则发起异步解析请求
|
||||
/// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为<EFBFBD><EFBFBD>?
|
||||
/// 先查询缓存,缓存中存在有效结<EFBFBD><EFBFBD>?未过期,或者过期但配置了可以复用过期解析结<EFBFBD><EFBFBD>?,则直接返回结果,如果缓存未命中,则发起异步解析请求
|
||||
/// @param host 需要解析的域名
|
||||
/// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析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;
|
||||
|
||||
/// 清理已经配置的软件自定义解析全局参数
|
||||
|
||||
@@ -44,12 +44,12 @@ static HttpDnsService *httpdnsSharedStubInstance;
|
||||
@property (nonatomic, copy) NSString *aesSecretKey;
|
||||
@property (nonatomic, assign) BOOL hasConfiguredAccount;
|
||||
|
||||
// 每次访问的签名有效期,SDK内部定死,当前不暴露设置接口,有效期定为10分钟。
|
||||
// 每次访问的签名有效期,SDK内部定死,当前不暴露设置接口,有效期定为10分钟<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 {
|
||||
// 初始化过程包含了region配置更新流程,region切换会导致缓存清空,立即做预解析可能是没有意义的
|
||||
// 这是sdk接口设计的历史问题,目前没有太好办法,这里0.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 {
|
||||
// 不再生效,保留接口
|
||||
// 是否开启自定义IP排序,由是否设置IPRankingDatasource和IPRankingDatasource中是否能根据host找到对应的IP来决定
|
||||
// 不再生效,保留接<EFBFBD><EFBFBD>?
|
||||
// 是否开启自定义IP排序,由是否设置IPRankingDatasource和IPRankingDatasource中是否能根据host找到对应的IP来决<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>?
|
||||
// 虽然判断是ipv6only,但现实中只有实验室才会有这种情况,考虑判断网络协议栈是有误判可能的,权衡之下,还是应该请求ipv4
|
||||
// 如果用户是在明确的实验室环境中做测试,他应该直接指定请求type为ipv6
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 { \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
// 注意,_hasNoIpv4Record为true时,说明域名没有配置ipv4ip,不是需要去请求的情况
|
||||
// 注意,_hasNoIpv4Record为true时,说明域名没有配置ipv4ip,不是需要去请求的情<EFBFBD><EFBFBD>?
|
||||
if ([HttpdnsUtil isEmptyArray:[self getV4Ips]] && !_hasNoIpv4Record) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
} else if (queryType & HttpdnsQueryIPTypeIpv6 && !_hasNoIpv6Record) {
|
||||
// 注意,_hasNoIpv6Record为true时,说明域名没有配置ipv6ip,不是需要去请求的情况
|
||||
// 注意,_hasNoIpv6Record为true时,说明域名没有配置ipv6ip,不是需要去请求的情<EFBFBD><EFBFBD>?
|
||||
if ([HttpdnsUtil isEmptyArray:[self getV6Ips]] && !_hasNoIpv6Record) {
|
||||
return YES;
|
||||
}
|
||||
@@ -202,14 +202,14 @@
|
||||
}
|
||||
|
||||
- (HttpdnsHostRecord *)toDBRecord {
|
||||
// 将IP对象数组转换为IP字符串数组
|
||||
// 将IP对象数组转换为IP字符串数<EFBFBD><EFBFBD>?
|
||||
NSArray<NSString *> *v4IpStrings = [self getV4IpStrings];
|
||||
NSArray<NSString *> *v6IpStrings = [self getV6IpStrings];
|
||||
|
||||
// 创建当前时间作为modifyAt
|
||||
NSDate *currentDate = [NSDate date];
|
||||
|
||||
// 使用hostName作为cacheKey,保持与fromDBRecord方法的一致性
|
||||
// 使用hostName作为cacheKey,保持与fromDBRecord方法的一致<EFBFBD><EFBFBD>?
|
||||
return [[HttpdnsHostRecord alloc] initWithId:0 // 数据库会自动分配ID
|
||||
cacheKey:self.cacheKey
|
||||
hostName:self.hostName
|
||||
@@ -271,17 +271,17 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据connectedRT值对IP列表进行排序,-1值放在最后
|
||||
// 根据connectedRT值对IP列表进行排序<EFBFBD><EFBFBD>?1值放在最<EFBFBD><EFBFBD>?
|
||||
[mutableIpObjects sortUsingComparator:^NSComparisonResult(HttpdnsIpObject *obj1, HttpdnsIpObject *obj2) {
|
||||
// 如果obj1的connectedRT为-1,将其排在后面
|
||||
// 如果obj1的connectedRT<EFBFBD><EFBFBD>?1,将其排在后<EFBFBD><EFBFBD>?
|
||||
if (obj1.connectedRT == -1) {
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
// 如果obj2的connectedRT为-1,将其排在后面
|
||||
// 如果obj2的connectedRT<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);
|
||||
}];
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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参数,针对软件自定义解析场景使用
|
||||
|
||||
@@ -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>?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HttpdnsNWHTTPClient : NSObject
|
||||
|
||||
/// 全局共享实例,复用底层连接池;线程安全
|
||||
/// 全局共享实例,复用底层连接池;线程安<EFBFBD><EFBFBD>?
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
- (nullable HttpdnsNWHTTPClientResponse *)performRequestWithURLString:(NSString *)urlString
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 - 只读
|
||||
|
||||
// 测试辅助方法
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
+ (NSString *)httpdnsDataDirectory;
|
||||
+ (NSString *)scheduleCenterResultDirectory;
|
||||
/// 多账号隔离:返回指定账号的调度结果目录
|
||||
/// 多账号隔离:返回指定账号的调度结果目<EFBFBD><EFBFBD>?
|
||||
+ (NSString *)scheduleCenterResultDirectoryForAccount:(NSInteger)accountId;
|
||||
|
||||
+ (BOOL)saveJSON:(id)JSON toPath:(NSString *)path;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
@interface HttpdnsScheduleCenter : NSObject
|
||||
|
||||
/// 针对多账号场景的调度中心构造方法
|
||||
/// 注意:若无需多账号隔离,可继续使用 sharedInstance
|
||||
/// 针对多账号场景的调度中心构造方<EFBFBD><EFBFBD>?
|
||||
/// 注意:若无需多账号隔离,可继续使<EFBFBD><EFBFBD>?sharedInstance
|
||||
- (instancetype)initWithAccountId:(NSInteger)accountId;
|
||||
|
||||
- (void)initRegion:(NSString *)region;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -463,7 +463,7 @@ static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRea
|
||||
return HttpdnsReachableVia5G;
|
||||
}
|
||||
}
|
||||
// 默认以使用最广泛的4G兜底
|
||||
// 默认以使用最广泛<EFBFBD><EFBFBD>?G兜底
|
||||
return HttpdnsReachableVia4G;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@
|
||||
|
||||
/**
|
||||
生成sessionId
|
||||
App打开生命周期只生成一次,不做持久化
|
||||
sessionId为12位,采用base62编码
|
||||
App打开生命周期只生成一次,不做持久<EFBFBD><EFBFBD>?
|
||||
sessionId<EFBFBD><EFBFBD>?2位,采用base62编码
|
||||
*/
|
||||
+ (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;
|
||||
}
|
||||
|
||||
// 提取IV(前16字节)和实际的密文
|
||||
// 提取IV(前16字节)和实际的密<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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user