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

View File

@@ -3,23 +3,24 @@ Pod::Spec.new do |s|
s.version = "1.0.0" s.version = "1.0.0"
s.summary = "New Mobile Service HTTPDNS iOS SDK (source distribution)." s.summary = "New Mobile Service HTTPDNS iOS SDK (source distribution)."
s.description = <<-DESC s.description = <<-DESC
HTTPDNS iOS SDK 源码分发版本,提供通过 HTTP(S) 进行域名解析<E8A7A3><E69E90>? IPv4/IPv6 支持、鉴权签名、可选参数加密、内存与 SQLite 持久化缓存<E7BC93><E5AD98>? 区域调度与降级到本地解析等能力<E883BD><E58A9B>? DESC HTTPDNS iOS SDK source distribution with DNS resolution over HTTP(S),
IPv4/IPv6 support, authentication, optional encryption, memory and
SQLite persistent caching, regional scheduling and local DNS fallback.
DESC
s.homepage = "https://www.aliyun.com/product/httpdns" s.homepage = "https://www.aliyun.com/product/httpdns"
s.authors = { "zhouzhuo" => "yecan.xyc@alibaba-inc.com" } s.authors = { "zhouzhuo" => "yecan.xyc@alibaba-inc.com" }
# 注意:发布到 Specs 仓库前,请将 git 地址指向正式仓库并按版本<E78988><E69CAC>?tag
s.source = { :git => "https://github.com/aliyun/alibabacloud-httpdns-ios-sdk", :tag => s.version.to_s } s.source = { :git => "https://github.com/aliyun/alibabacloud-httpdns-ios-sdk", :tag => s.version.to_s }
s.platform = :ios, "12.0" s.platform = :ios, "12.0"
s.requires_arc = true s.requires_arc = true
# 以源码方式集成仅收<E4BB85><E694B6>?SDK 源码目录
s.source_files = "NewHttpDNS/**/*.{h,m}" s.source_files = "NewHttpDNS/**/*.{h,m}"
# 资源隐私清<E7A781><E6B885>? s.resources = "resource/PrivacyInfo.xcprivacy" s.resources = "resource/PrivacyInfo.xcprivacy"
# 公开头文件<E4BBB6><EFBC88>?umbrella 头导入的稳定接口<E68EA5><E58FA3>? s.public_header_files = [ s.public_header_files = [
"NewHttpDNS/NewHttpDNS.h", "NewHttpDNS/NewHttpDNS.h",
"NewHttpDNS/HttpdnsService.h", "NewHttpDNS/HttpdnsService.h",
"NewHttpDNS/HttpdnsEdgeService.h", "NewHttpDNS/HttpdnsEdgeService.h",
@@ -32,11 +33,9 @@ Pod::Spec.new do |s|
"NewHttpDNS/IpStack/HttpdnsIpStackDetector.h" "NewHttpDNS/IpStack/HttpdnsIpStackDetector.h"
] ]
# 系统库与框架
s.frameworks = ["CoreTelephony", "SystemConfiguration"] s.frameworks = ["CoreTelephony", "SystemConfiguration"]
s.libraries = ["sqlite3.0", "resolv", "z"] s.libraries = ["sqlite3.0", "resolv", "z"]
# 链接器参数:保留 ObjectiveC 分类
s.pod_target_xcconfig = { s.pod_target_xcconfig = {
'OTHER_LDFLAGS' => '$(inherited) -ObjC' 'OTHER_LDFLAGS' => '$(inherited) -ObjC'
} }

View File

@@ -1,4 +1,4 @@
// !$*UTF8*$! // !$*UTF8*$!
{ {
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
@@ -1110,10 +1110,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_ENABLE_MODULE_DEBUGGING = NO; CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Automatic;
COMPILER_INDEX_STORE_ENABLE = NO; COMPILER_INDEX_STORE_ENABLE = NO;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1140,7 +1141,9 @@
"-ObjC", "-ObjC",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.new.sdk.ios.NewHttpDNS; PRODUCT_BUNDLE_IDENTIFIER = com.new.sdk.ios.NewHttpDNS;
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.new.sdk.httpdns;
PRODUCT_NAME = NewHttpDNS; PRODUCT_NAME = NewHttpDNS;
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = YES; SUPPORTS_MACCATALYST = YES;
}; };
@@ -1150,10 +1153,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_ENABLE_MODULE_DEBUGGING = NO; CLANG_ENABLE_MODULE_DEBUGGING = NO;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Automatic;
COMPILER_INDEX_STORE_ENABLE = NO; COMPILER_INDEX_STORE_ENABLE = NO;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
@@ -1179,7 +1183,9 @@
"-ObjC", "-ObjC",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.new.sdk.ios.NewHttpDNS; PRODUCT_BUNDLE_IDENTIFIER = com.new.sdk.ios.NewHttpDNS;
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.new.sdk.httpdns;
PRODUCT_NAME = NewHttpDNS; PRODUCT_NAME = NewHttpDNS;
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = YES; SUPPORTS_MACCATALYST = YES;
}; };
@@ -1268,7 +1274,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = VSW2PKYTD7; DEVELOPMENT_TEAM = RJ28T64WU2;
ENABLE_USER_SCRIPT_SANDBOXING = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@@ -1313,7 +1319,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = VSW2PKYTD7; DEVELOPMENT_TEAM = RJ28T64WU2;
ENABLE_USER_SCRIPT_SANDBOXING = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsInternalConstant.h // HttpdnsInternalConstant.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2025/03/10. // Created by xuyecan on 2025/03/10.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.
@@ -19,7 +19,7 @@ static const int HTTPDNS_DEFAULT_REQUEST_TIMEOUT_INTERVAL = 3;
static const NSUInteger HTTPDNS_DEFAULT_AUTH_TIMEOUT_INTERVAL = 10 * 60; static const NSUInteger HTTPDNS_DEFAULT_AUTH_TIMEOUT_INTERVAL = 10 * 60;
static NSString *const Trust_HTTPDNS_VALID_SERVER_CERTIFICATE_IP = @"203.107.1.1"; static NSString *const NEW_HTTPDNS_VALID_SERVER_CERTIFICATE_IP = @"203.107.1.1";
// 在iOS14和iOS16网络信息的获取权限受到越来越紧的限<E79A84><E99990>? // 在iOS14和iOS16网络信息的获取权限受到越来越紧的限<E79A84><E99990>?
// 除非用户主动声明需要相关entitlement不然只能拿到空信息 // 除非用户主动声明需要相关entitlement不然只能拿到空信息
@@ -28,33 +28,33 @@ static NSString *const Trust_HTTPDNS_VALID_SERVER_CERTIFICATE_IP = @"203.107.1.1
#define HTTPDNS_DEFAULT_NETWORK_CARRIER_NAME @"default" #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 // 调度地址示例http://106.11.90.200/sc/httpdns_config?account_id=153519&platform=ios&sdk_version=1.6.1
static NSString *const Trust_HTTPDNS_SCHEDULE_CENTER_REQUEST_HOST = @"httpdns-sc.TrustAPPcs.com"; static NSString *const NEW_HTTPDNS_SCHEDULE_CENTER_REQUEST_HOST = @"httpdns-sc.NewAPPcs.com";
static NSString *const Trust_HTTPDNS_ERROR_MESSAGE_KEY = @"ErrorMessage"; static NSString *const NEW_HTTPDNS_ERROR_MESSAGE_KEY = @"ErrorMessage";
static NSString *const kTrustHttpdnsRegionConfigV4HostKey = @"service_ip"; static NSString *const kNewHttpdnsRegionConfigV4HostKey = @"service_ip";
static NSString *const kTrustHttpdnsRegionConfigV6HostKey = @"service_ipv6"; static NSString *const kNewHttpdnsRegionConfigV6HostKey = @"service_ipv6";
static NSString *const kTrustHttpdnsRegionKey = @"HttpdnsRegion"; static NSString *const kNewHttpdnsRegionKey = @"HttpdnsRegion";
#define SECONDS_OF_ONE_YEAR 365 * 24 * 60 * 60 #define SECONDS_OF_ONE_YEAR 365 * 24 * 60 * 60
static NSString *const Trust_HTTPDNS_ERROR_DOMAIN = @"HttpdnsErrorDomain"; static NSString *const NEW_HTTPDNS_ERROR_DOMAIN = @"HttpdnsErrorDomain";
static NSInteger const Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE = 10003; static NSInteger const NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE = 10003;
static NSInteger const Trust_HTTPDNS_HTTP_COMMON_ERROR_CODE = 10004; static NSInteger const NEW_HTTPDNS_HTTP_COMMON_ERROR_CODE = 10004;
static NSInteger const Trust_HTTPDNS_HTTPS_TIMEOUT_ERROR_CODE = 10005; static NSInteger const NEW_HTTPDNS_HTTPS_TIMEOUT_ERROR_CODE = 10005;
static NSInteger const Trust_HTTPDNS_HTTP_TIMEOUT_ERROR_CODE = 10006; static NSInteger const NEW_HTTPDNS_HTTP_TIMEOUT_ERROR_CODE = 10006;
static NSInteger const Trust_HTTPDNS_HTTP_OPEN_STREAM_ERROR_CODE = 10007; static NSInteger const NEW_HTTPDNS_HTTP_OPEN_STREAM_ERROR_CODE = 10007;
static NSInteger const Trust_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE = 10008; static NSInteger const NEW_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE = 10008;
static NSInteger const Trust_HTTP_UNSUPPORTED_STATUS_CODE = 10013; static NSInteger const NEW_HTTP_UNSUPPORTED_STATUS_CODE = 10013;
static NSInteger const Trust_HTTP_PARSE_JSON_FAILED = 10014; static NSInteger const NEW_HTTP_PARSE_JSON_FAILED = 10014;
// 加密错误<E99499><E8AFAF>? // 加密错误<E99499><E8AFAF>?
static NSInteger const Trust_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE = 10021; static NSInteger const NEW_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE = 10021;
static NSInteger const Trust_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE = 10022; static NSInteger const NEW_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE = 10022;
static NSInteger const Trust_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE = 10023; static NSInteger const NEW_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE = 10023;
#endif #endif

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsPublicConstant.h // HttpdnsPublicConstant.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/6/16. // Created by xuyecan on 2024/6/16.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.
@@ -11,11 +11,11 @@
static NSString *const HTTPDNS_IOS_SDK_VERSION = @"1.0.0"; static NSString *const HTTPDNS_IOS_SDK_VERSION = @"1.0.0";
#define Trust_HTTPDNS_DEFAULT_REGION_KEY @"cn" #define NEW_HTTPDNS_DEFAULT_REGION_KEY @"cn"
#define Trust_HTTPDNS_HONGKONG_REGION_KEY @"hk" #define NEW_HTTPDNS_HONGKONG_REGION_KEY @"hk"
#define Trust_HTTPDNS_SINGAPORE_REGION_KEY @"sg" #define NEW_HTTPDNS_SINGAPORE_REGION_KEY @"sg"
#define Trust_HTTPDNS_GERMANY_REGION_KEY @"de" #define NEW_HTTPDNS_GERMANY_REGION_KEY @"de"
#define Trust_HTTPDNS_AMERICA_REGION_KEY @"us" #define NEW_HTTPDNS_AMERICA_REGION_KEY @"us"
#endif /* PublicConstant_h */ #endif /* PublicConstant_h */

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsRegionConfigLoader.h // HttpdnsRegionConfigLoader.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/6/16. // Created by xuyecan on 2024/6/16.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsRegionConfigLoader.m // HttpdnsRegionConfigLoader.m
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/6/16. // Created by xuyecan on 2024/6/16.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.
@@ -9,12 +9,12 @@
#import "HttpdnsRegionConfigLoader.h" #import "HttpdnsRegionConfigLoader.h"
#import "HttpdnsPublicConstant.h" #import "HttpdnsPublicConstant.h"
static NSString *const kServiceV4Key = @"Trust_HTTPDNS_SERVICE_HOST_V4_KEY"; static NSString *const kServiceV4Key = @"NEW_HTTPDNS_SERVICE_HOST_V4_KEY";
static NSString *const kUpdateV4FallbackHostKey = @"Trust_HTTPDNS_UPDATE_HOST_V4_KEY"; static NSString *const kUpdateV4FallbackHostKey = @"NEW_HTTPDNS_UPDATE_HOST_V4_KEY";
static NSString *const kServiceV6Key = @"Trust_HTTPDNS_SERVICE_HOST_V6_KEY"; static NSString *const kServiceV6Key = @"NEW_HTTPDNS_SERVICE_HOST_V6_KEY";
static NSString *const kUpdateV6FallbackHostKey = @"Trust_HTTPDNS_UPDATE_HOST_V6_KEY"; static NSString *const kUpdateV6FallbackHostKey = @"NEW_HTTPDNS_UPDATE_HOST_V6_KEY";
static NSArray<NSString *> *Trust_HTTPDNS_AVAILABLE_REGION_LIST = nil; static NSArray<NSString *> *NEW_HTTPDNS_AVAILABLE_REGION_LIST = nil;
@interface HttpdnsRegionConfigLoader () @interface HttpdnsRegionConfigLoader ()
@@ -25,12 +25,12 @@ static NSArray<NSString *> *Trust_HTTPDNS_AVAILABLE_REGION_LIST = nil;
@implementation HttpdnsRegionConfigLoader @implementation HttpdnsRegionConfigLoader
+ (void)initialize { + (void)initialize {
Trust_HTTPDNS_AVAILABLE_REGION_LIST = @[ NEW_HTTPDNS_AVAILABLE_REGION_LIST = @[
Trust_HTTPDNS_DEFAULT_REGION_KEY, NEW_HTTPDNS_DEFAULT_REGION_KEY,
Trust_HTTPDNS_HONGKONG_REGION_KEY, NEW_HTTPDNS_HONGKONG_REGION_KEY,
Trust_HTTPDNS_SINGAPORE_REGION_KEY, NEW_HTTPDNS_SINGAPORE_REGION_KEY,
Trust_HTTPDNS_GERMANY_REGION_KEY, NEW_HTTPDNS_GERMANY_REGION_KEY,
Trust_HTTPDNS_AMERICA_REGION_KEY NEW_HTTPDNS_AMERICA_REGION_KEY
]; ];
} }
@@ -51,40 +51,40 @@ static NSArray<NSString *> *Trust_HTTPDNS_AVAILABLE_REGION_LIST = nil;
} }
+ (NSArray<NSString *> *)getAvailableRegionList { + (NSArray<NSString *> *)getAvailableRegionList {
return Trust_HTTPDNS_AVAILABLE_REGION_LIST; return NEW_HTTPDNS_AVAILABLE_REGION_LIST;
} }
- (void)loadRegionConfig { - (void)loadRegionConfig {
self.regionConfig = @{ self.regionConfig = @{
Trust_HTTPDNS_DEFAULT_REGION_KEY: @{ NEW_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"], 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.TrustAPPcs.com"], kUpdateV4FallbackHostKey: @[@"resolvers-cn.httpdns.NewAPPcs.com"],
kServiceV6Key: @[@"2401:b180:7001::31d", @"2401:b180:2000:30::1c", @"2401:b180:2000:20::10", @"2401:b180:2000:30::1c"], kServiceV6Key: @[@"2401:b180:7001::31d", @"2401:b180:2000:30::1c", @"2401:b180:2000:20::10", @"2401:b180:2000:30::1c"],
kUpdateV6FallbackHostKey: @[@"resolvers-cn.httpdns.TrustAPPcs.com"] kUpdateV6FallbackHostKey: @[@"resolvers-cn.httpdns.NewAPPcs.com"]
}, },
Trust_HTTPDNS_HONGKONG_REGION_KEY: @{ NEW_HTTPDNS_HONGKONG_REGION_KEY: @{
kServiceV4Key: @[@"47.56.234.194", @"47.56.119.115"], kServiceV4Key: @[@"47.56.234.194", @"47.56.119.115"],
kUpdateV4FallbackHostKey: @[@"resolvers-hk.httpdns.TrustAPPcs.com"], kUpdateV4FallbackHostKey: @[@"resolvers-hk.httpdns.NewAPPcs.com"],
kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"], kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"],
kUpdateV6FallbackHostKey: @[@"resolvers-hk.httpdns.TrustAPPcs.com"] kUpdateV6FallbackHostKey: @[@"resolvers-hk.httpdns.NewAPPcs.com"]
}, },
Trust_HTTPDNS_SINGAPORE_REGION_KEY: @{ NEW_HTTPDNS_SINGAPORE_REGION_KEY: @{
kServiceV4Key: @[@"161.117.200.122", @"47.74.222.190"], kServiceV4Key: @[@"161.117.200.122", @"47.74.222.190"],
kUpdateV4FallbackHostKey: @[@"resolvers-sg.httpdns.TrustAPPcs.com"], kUpdateV4FallbackHostKey: @[@"resolvers-sg.httpdns.NewAPPcs.com"],
kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"], kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"],
kUpdateV6FallbackHostKey: @[@"resolvers-sg.httpdns.TrustAPPcs.com"] kUpdateV6FallbackHostKey: @[@"resolvers-sg.httpdns.NewAPPcs.com"]
}, },
Trust_HTTPDNS_GERMANY_REGION_KEY: @{ NEW_HTTPDNS_GERMANY_REGION_KEY: @{
kServiceV4Key: @[@"47.89.80.182", @"47.246.146.77"], kServiceV4Key: @[@"47.89.80.182", @"47.246.146.77"],
kUpdateV4FallbackHostKey: @[@"resolvers-de.httpdns.TrustAPPcs.com"], kUpdateV4FallbackHostKey: @[@"resolvers-de.httpdns.NewAPPcs.com"],
kServiceV6Key: @[@"2404:2280:3000::176", @"2404:2280:3000::188"], kServiceV6Key: @[@"2404:2280:3000::176", @"2404:2280:3000::188"],
kUpdateV6FallbackHostKey: @[@"resolvers-de.httpdns.TrustAPPcs.com"] kUpdateV6FallbackHostKey: @[@"resolvers-de.httpdns.NewAPPcs.com"]
}, },
Trust_HTTPDNS_AMERICA_REGION_KEY: @{ NEW_HTTPDNS_AMERICA_REGION_KEY: @{
kServiceV4Key: @[@"47.246.131.175", @"47.246.131.141"], kServiceV4Key: @[@"47.246.131.175", @"47.246.131.141"],
kUpdateV4FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"], kUpdateV4FallbackHostKey: @[@"resolvers-us.httpdns.NewAPPcs.com"],
kServiceV6Key: @[@"2404:2280:4000::2bb", @"2404:2280:4000::23e"], kServiceV6Key: @[@"2404:2280:4000::2bb", @"2404:2280:4000::23e"],
kUpdateV6FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"] kUpdateV6FallbackHostKey: @[@"resolvers-us.httpdns.NewAPPcs.com"]
} }
}; };
} }

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsLocalResolver.h // HttpdnsLocalResolver.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2025/3/16. // Created by xuyecan on 2025/3/16.
// Copyright © 2025 trustapp.com. All rights reserved. // Copyright © 2025 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsLocalResolver.m // HttpdnsLocalResolver.m
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2025/3/16. // Created by xuyecan on 2025/3/16.
// Copyright © 2025 trustapp.com. All rights reserved. // Copyright © 2025 trustapp.com. All rights reserved.

View File

@@ -59,7 +59,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
+ (void)initialize { + (void)initialize {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
_streamOperateSyncQueue = dispatch_queue_create("com.Trust.sdk.httpdns.runloopOperateQueue.HttpdnsRequest", DISPATCH_QUEUE_SERIAL); _streamOperateSyncQueue = dispatch_queue_create("com.New.sdk.httpdns.runloopOperateQueue.HttpdnsRequest", DISPATCH_QUEUE_SERIAL);
}); });
} }
@@ -594,7 +594,7 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
if (!service) { if (!service) {
HttpdnsLogDebug("Missing service for accountId: %ld; ensure request.accountId is set and service initialized", (long)request.accountId); HttpdnsLogDebug("Missing service for accountId: %ld; ensure request.accountId is set and service initialized", (long)request.accountId);
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE userInfo:@{NSLocalizedDescriptionKey: @"HttpDnsService not found for accountId"}]; *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE userInfo:@{NSLocalizedDescriptionKey: @"HttpDnsService not found for accountId"}];
} }
return nil; return nil;
} }
@@ -631,8 +631,8 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
- (NSArray<HttpdnsHostObject *> *)sendRequest:(NSString *)urlStr queryIpType:(HttpdnsQueryIPType)queryIpType error:(NSError **)error { - (NSArray<HttpdnsHostObject *> *)sendRequest:(NSString *)urlStr queryIpType:(HttpdnsQueryIPType)queryIpType error:(NSError **)error {
if (![HttpdnsUtil isNotEmptyString:urlStr]) { if (![HttpdnsUtil isNotEmptyString:urlStr]) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Empty resolve URL due to missing scheduler"}]; userInfo:@{NSLocalizedDescriptionKey: @"Empty resolve URL due to missing scheduler"}];
} }
return nil; return nil;
@@ -654,8 +654,8 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
if (httpResponse.statusCode != 200) { if (httpResponse.statusCode != 200) {
if (error) { if (error) {
NSString *errorMessage = [NSString stringWithFormat:@"Unsupported http status code: %ld", (long)httpResponse.statusCode]; NSString *errorMessage = [NSString stringWithFormat:@"Unsupported http status code: %ld", (long)httpResponse.statusCode];
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_UNSUPPORTED_STATUS_CODE code:NEW_HTTP_UNSUPPORTED_STATUS_CODE
userInfo:@{NSLocalizedDescriptionKey: errorMessage}]; userInfo:@{NSLocalizedDescriptionKey: errorMessage}];
} }
return nil; return nil;
@@ -673,8 +673,8 @@ static dispatch_queue_t _streamOperateSyncQueue = 0;
NSDictionary *json = [HttpdnsUtil getValidDictionaryFromJson:jsonValue]; NSDictionary *json = [HttpdnsUtil getValidDictionaryFromJson:jsonValue];
if (!json) { if (!json) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTP_PARSE_JSON_FAILED code:NEW_HTTP_PARSE_JSON_FAILED
userInfo:@{NSLocalizedDescriptionKey: @"Failed to parse JSON response"}]; userInfo:@{NSLocalizedDescriptionKey: @"Failed to parse JSON response"}];
} }
return nil; return nil;

View File

@@ -71,8 +71,8 @@ typedef struct {
+ (void)initialize { + (void)initialize {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
_persistentCacheConcurrentQueue = dispatch_queue_create("com.Trust.sdk.httpdns.persistentCacheOperationQueue", DISPATCH_QUEUE_CONCURRENT); _persistentCacheConcurrentQueue = dispatch_queue_create("com.New.sdk.httpdns.persistentCacheOperationQueue", DISPATCH_QUEUE_CONCURRENT);
_asyncResolveHostQueue = dispatch_queue_create("com.Trust.sdk.httpdns.asyncResolveHostQueue", DISPATCH_QUEUE_CONCURRENT); _asyncResolveHostQueue = dispatch_queue_create("com.New.sdk.httpdns.asyncResolveHostQueue", DISPATCH_QUEUE_CONCURRENT);
}); });
} }
@@ -552,7 +552,7 @@ typedef struct {
- (dispatch_queue_t)cacheQueue { - (dispatch_queue_t)cacheQueue {
if (!_cacheQueue) { if (!_cacheQueue) {
_cacheQueue = dispatch_queue_create("com.Trust.sdk.httpdns.cacheDisableStatusQueue", DISPATCH_QUEUE_SERIAL); _cacheQueue = dispatch_queue_create("com.New.sdk.httpdns.cacheDisableStatusQueue", DISPATCH_QUEUE_SERIAL);
} }
return _cacheQueue; return _cacheQueue;
} }

View File

@@ -24,19 +24,19 @@
// #import "HttpdnsDegradationDelegate.h" // #import "HttpdnsDegradationDelegate.h"
// #import "HttpdnsLoggerProtocol.h" // #import "HttpdnsLoggerProtocol.h"
#import <TrustHTTPDNS/HttpdnsRequest.h> #import <NewHTTPDNS/HttpdnsRequest.h>
#import <TrustHTTPDNS/HttpDnsResult.h> #import <NewHttpDNS/HttpDnsResult.h>
#import <TrustHTTPDNS/HttpdnsLoggerProtocol.h> #import <NewHttpDNS/HttpdnsLoggerProtocol.h>
#import <TrustHTTPDNS/HttpdnsDegradationDelegate.h> #import <NewHttpDNS/HttpdnsDegradationDelegate.h>
#define Trust_HTTPDNS_DEPRECATED(explain) __attribute__((deprecated(explain))) #define NEW_HTTPDNS_DEPRECATED(explain) __attribute__((deprecated(explain)))
#ifndef TrustHDNS_STACK_KEY #ifndef NewHDNS_STACK_KEY
#define TrustHDNS_STACK_KEY #define NewHDNS_STACK_KEY
#define TrustHDNS_IPV4 @"TrustHDNS_IPV4" #define NewHDNS_IPV4 @"NewHDNS_IPV4"
#define TrustHDNS_IPV6 @"TrustHDNS_IPV6" #define NewHDNS_IPV6 @"NewHDNS_IPV6"
#endif #endif
@@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 域名 /// @param host 域名
/// @param ipType 当前查询的IP类型 /// @param ipType 当前查询的IP类型
/// @param ttl 当次域名解析返回的TTL /// @param ttl 当次域名解析返回的TTL
- (int64_t)httpdnsHost:(NSString * _Nonnull)host ipType:(TrustHttpDNS_IPType)ipType ttl:(int64_t)ttl; - (int64_t)httpdnsHost:(NSString * _Nonnull)host ipType:(NewHttpDNS_IPType)ipType ttl:(int64_t)ttl;
@end @end
@@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy, readonly, nullable) NSString *aesSecretKey; @property (nonatomic, copy, readonly, nullable) NSString *aesSecretKey;
@property (nonatomic, weak, setter=setDelegateForDegradationFilter:) id<HttpDNSDegradationDelegate> delegate Trust_HTTPDNS_DEPRECATED("不再建议通过设置此回调实现降级逻辑而是自行在调用HTTPDNS解析域名前做判断"); @property (nonatomic, weak, setter=setDelegateForDegradationFilter:) id<HttpDNSDegradationDelegate> delegate NEW_HTTPDNS_DEPRECATED("不再建议通过设置此回调实现降级逻辑而是自行在调用HTTPDNS解析域名前做判断");
@property (nonatomic, weak) id<HttpdnsTTLDelegate> ttlDelegate; @property (nonatomic, weak) id<HttpdnsTTLDelegate> ttlDelegate;
@@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
* 注意本接口<E68EA5><E58FA3>?.2.1起废弃后续将进行移除<EFBFBD><EFBFBD>? * 注意本接口<E68EA5><E58FA3>?.2.1起废弃后续将进行移除<EFBFBD><EFBFBD>?
* @param accountID 您的 HTTPDNS Account ID * @param accountID 您的 HTTPDNS Account ID
*/ */
- (nonnull instancetype)initWithAccountID:(NSInteger)accountID Trust_HTTPDNS_DEPRECATED("Deprecated. This method will be removed in the future. Use -[HttpDnsService initWithAccountID:secretKey:] instead."); - (nonnull instancetype)initWithAccountID:(NSInteger)accountID NEW_HTTPDNS_DEPRECATED("Deprecated. This method will be removed in the future. Use -[HttpDnsService initWithAccountID:secretKey:] instead.");
/*! /*!
* @brief 启用鉴权功能的初始化接口 * @brief 启用鉴权功能的初始化接口
@@ -108,7 +108,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间<E697B6><E997B4>? /// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间<E697B6><E997B4>?
/// 注意,校正操作在 APP 的一个生命周期内生效APP 重启后需要重新设置才能重新生<E696B0><E7949F>? /// 注意,校正操作在 APP 的一个生命周期内生效APP 重启后需要重新设置才能重新生<E696B0><E7949F>?
/// @param authCurrentTime 用于校正的时间戳单位为<E4BD8D><E4B8BA>? /// @param authCurrentTime 用于校正的时间戳单位为<E4BD8D><E4B8BA>?
- (void)setAuthCurrentTime:(NSUInteger)authCurrentTime Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setInternalAuthTimeBaseBySpecifyingCurrentTime:] instead."); - (void)setAuthCurrentTime:(NSUInteger)authCurrentTime NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setInternalAuthTimeBaseBySpecifyingCurrentTime:] instead.");
/// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间<E697B6><E997B4>? /// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间<E697B6><E997B4>?
@@ -119,7 +119,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 设置持久化缓存功<E5AD98><E58A9F>? /// 设置持久化缓存功<E5AD98><E58A9F>?
/// @param enable YES: 开<><E5BC80>?NO: 关闭 /// @param enable YES: 开<><E5BC80>?NO: 关闭
- (void)setCachedIPEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setPersistentCacheIPEnabled:] instead."); - (void)setCachedIPEnabled:(BOOL)enable NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setPersistentCacheIPEnabled:] instead.");
/// 设置持久化缓存功<E5AD98><E58A9F>? /// 设置持久化缓存功<E5AD98><E58A9F>?
@@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 是否允许 HTTPDNS 返回 TTL 过期域名<E59F9F><E5908D>?ip ,建议允许(默认不允许) /// 是否允许 HTTPDNS 返回 TTL 过期域名<E59F9F><E5908D>?ip ,建议允许(默认不允许)
/// @param enable YES: 开<><E5BC80>?NO: 关闭 /// @param enable YES: 开<><E5BC80>?NO: 关闭
- (void)setExpiredIPEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setReuseExpiredIPEnabled:] instead."); - (void)setExpiredIPEnabled:(BOOL)enable NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setReuseExpiredIPEnabled:] instead.");
/// 是否允许 HTTPDNS 返回 TTL 过期域名<E59F9F><E5908D>?ip ,建议允许(默认不允许) /// 是否允许 HTTPDNS 返回 TTL 过期域名<E59F9F><E5908D>?ip ,建议允许(默认不允许)
@@ -191,7 +191,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 域名预解<E9A284><E8A7A3>? /// 域名预解<E9A284><E8A7A3>?
/// @param hosts 域名 /// @param hosts 域名
/// @param ipType 4: ipv4; 6: ipv6; 64: ipv4+ipv6 /// @param ipType 4: ipv4; 6: ipv6; 64: ipv4+ipv6
- (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."); - (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(NewHttpDNS_IPType)ipType NEW_HTTPDNS_DEPRECATED("Deprecated, this method will be removed in the future. Use -[HttpDnsService setPreResolveHosts:byIPType:] instead.");
/// 本地日志 log 开<><E5BC80>? /// 本地日志 log 开<><E5BC80>?
@@ -221,28 +221,28 @@ NS_ASSUME_NONNULL_BEGIN
/// 设置是否 开<><E5BC80>?IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结<E79A84><E7BB93>? /// 设置是否 开<><E5BC80>?IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结<E79A84><E7BB93>?
/// @param enable YES: 开<><E5BC80>?NO: 关闭 /// @param enable YES: 开<><E5BC80>?NO: 关闭
- (void)enableIPv6:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setIPv6Enabled:] instead."); - (void)enableIPv6:(BOOL)enable NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setIPv6Enabled:] instead.");
/// 设置是否 开<><E5BC80>?IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结<E79A84><E7BB93>? /// 设置是否 开<><E5BC80>?IPv6 结果解析。只有开启状态下对域名的解析才会尝试解析v6记录并返回v6的结<E79A84><E7BB93>?
/// 已弃用。默认支持IPv6。如果不需要IPv6类型的结果只需在请求时指定`queryIpType`为`HttpdnsQueryIPTypeIpv4` /// 已弃用。默认支持IPv6。如果不需要IPv6类型的结果只需在请求时指定`queryIpType`为`HttpdnsQueryIPTypeIpv4`
/// @param enable YES: 开<><E5BC80>?NO: 关闭 /// @param enable YES: 开<><E5BC80>?NO: 关闭
- (void)setIPv6Enabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. If ipv6 is unnecessary, you can set the `queryIpType` as HttpdnsQueryIPTypeIpv4 when resolving domain."); - (void)setIPv6Enabled:(BOOL)enable NEW_HTTPDNS_DEPRECATED("Deprecated. If ipv6 is unnecessary, you can set the `queryIpType` as HttpdnsQueryIPTypeIpv4 when resolving domain.");
/// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid /// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid
/// @param enable YES: 开<><E5BC80>?NO: 关闭 默认关<E8AEA4><E585B3>? /// @param enable YES: 开<><E5BC80>?NO: 关闭 默认关<E8AEA4><E585B3>?
- (void)enableNetworkInfo:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore"); - (void)enableNetworkInfo:(BOOL)enable NEW_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore");
/// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid /// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid
/// @param enable YES: 开<><E5BC80>?NO: 关闭 默认关<E8AEA4><E585B3>? /// @param enable YES: 开<><E5BC80>?NO: 关闭 默认关<E8AEA4><E585B3>?
- (void)setReadNetworkInfoEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore."); - (void)setReadNetworkInfoEnabled:(BOOL)enable NEW_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore.");
/// 是否开启IP探测功能 /// 是否开启IP探测功能
/// @param enable YES: 开<><E5BC80>?NO: 关闭 默认打开 /// @param enable YES: 开<><E5BC80>?NO: 关闭 默认打开
- (void)enableCustomIPRank:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated, will be removed in the future."); - (void)enableCustomIPRank:(BOOL)enable NEW_HTTPDNS_DEPRECATED("Deprecated, will be removed in the future.");
/// 设置软件自定义解析全局默认参数设置后调用软件自定义解析时每个请求默认都会带上这里配置的参<E79A84><E58F82>? /// 设置软件自定义解析全局默认参数设置后调用软件自定义解析时每个请求默认都会带上这里配置的参<E79A84><E58F82>?
@@ -333,31 +333,31 @@ NS_ASSUME_NONNULL_BEGIN
/// 获取域名对应的IP单IP /// 获取域名对应的IP单IP
/// @param host 域名 /// @param host 域名
- (NSString *)getIpByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSString *)getIpByHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的IP数组多IP /// 异步接口首次结果可能为空获取域名对应的IP数组多IP
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSArray *)getIpsByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSArray *)getIpsByHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>? /// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>?
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSString *)getIPv6ByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSString *)getIPv6ByHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>? /// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>?
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSArray *)getIPv6sByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSArray *)getIPv6sByHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 同时获取ipv4 ipv6的IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>? /// 同时获取ipv4 ipv6的IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>?
/// @param host 域名 /// @param host 域名
/// @result 返回字典类型结构 /// @result 返回字典类型结构
/// { /// {
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// NewHDNS_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'] /// NewHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// } /// }
- (NSDictionary <NSString *, NSArray *>*)getIPv4_v6ByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSDictionary <NSString *, NSArray *>*)getIPv4_v6ByHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址<E59CB0><E59D80>? /// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址<E59CB0><E59D80>?
/// 使用此API 需要确<E8A681><E7A1AE>?enableIPv6 开关已打开 /// 使用此API 需要确<E8A681><E7A1AE>?enableIPv6 开关已打开
@@ -368,48 +368,48 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 要解析的域名 /// @param host 要解析的域名
/// @result 返回字典类型结构 /// @result 返回字典类型结构
/// { /// {
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// NewHDNS_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'] /// NewHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// } /// }
-(NSDictionary <NSString *, NSArray *>*)autoGetIpsByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); -(NSDictionary <NSString *, NSArray *>*)autoGetIpsByHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的IPv4地址单IPv4 /// 异步接口首次结果可能为空获取域名对应的IPv4地址单IPv4
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSString *)getIPv4ForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSString *)getIPv4ForHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的IP数组多IP /// 异步接口首次结果可能为空获取域名对应的IP数组多IP
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSArray *)getIPv4ListForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSArray *)getIPv4ListForHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 获取IPv4地址列表同步接口必须在子线程中执行否则会转变为异步接口 /// 获取IPv4地址列表同步接口必须在子线程中执行否则会转变为异步接口
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>? /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>?
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<E997B4><E5A4A7>?s同步接口也最多阻塞当前线<E5898D><E7BABF>?s /// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<E997B4><E5A4A7>?s同步接口也最多阻塞当前线<E5898D><E7BABF>?s
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起同步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起同步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSArray *)getIPv4ListForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); - (NSArray *)getIPv4ListForHostSync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>? /// 异步接口首次结果可能为空获取域名对应的ipv6, 单IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>?
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSString *)getIPv6ForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSString *)getIPv6ForHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>? /// 异步接口首次结果可能为空获取域名对应的ipv6数组, 多IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>?
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSArray *)getIPv6ListForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSArray *)getIPv6ListForHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 获取IPv6地址列表同步接口必须在子线程中执行否则会转变为异步接口 /// 获取IPv6地址列表同步接口必须在子线程中执行否则会转变为异步接口
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>? /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>?
/// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<E997B4><E5A4A7>?s同步接口也最多阻塞当前线<E5898D><E7BABF>?s /// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大<E997B4><E5A4A7>?s同步接口也最多阻塞当前线<E5898D><E7BABF>?s
/// @param host 域名 /// @param host 域名
- (NSArray *)getIPv6ListForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); - (NSArray *)getIPv6ListForHostSync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 异步接口首次结果可能为空获取域名对应格式化后的IP (针对ipv6) /// 异步接口首次结果可能为空获取域名对应格式化后的IP (针对ipv6)
/// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>? /// 先查询缓存缓存中存在未过期的结果则直接返回结果如果缓存未命中则发起异步解析请<E69E90><E8AFB7>?
/// @param host 域名 /// @param host 域名
- (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 异步接口首次结果可能为空同时获取ipv4 ipv6的IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>? /// 异步接口首次结果可能为空同时获取ipv4 ipv6的IP 需要开启ipv6 开<><E5BC80>?enableIPv6<76><36>?
@@ -417,10 +417,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 域名 /// @param host 域名
/// @result 返回字典类型结构 /// @result 返回字典类型结构
/// { /// {
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// NewHDNS_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'] /// NewHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// } /// }
- (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); - (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// NOTE: 同步接口必须在子线程中执行否则会转变为异步接<E6ADA5><E68EA5>? /// NOTE: 同步接口必须在子线程中执行否则会转变为异步接<E6ADA5><E68EA5>?
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>? /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>?
@@ -430,10 +430,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 域名 /// @param host 域名
/// @result 返回字典类型结构 /// @result 返回字典类型结构
/// { /// {
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// NewHDNS_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'] /// NewHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// } /// }
- (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); - (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostSync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 异步接口,首次结果可能为空,根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址<E59CB0><E59D80>? /// 异步接口,首次结果可能为空,根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址<E59CB0><E59D80>?
/// 使用此API 需要确<E8A681><E7A1AE>?enableIPv6 开关已打开 /// 使用此API 需要确<E8A681><E7A1AE>?enableIPv6 开关已打开
@@ -444,10 +444,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 要解析的域名 /// @param host 要解析的域名
/// @result 返回字典类型结构 /// @result 返回字典类型结构
/// { /// {
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// NewHDNS_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'] /// NewHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// } /// }
-(NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); -(NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostAsync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead.");
/// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址组同步接口必须在子线程中执行否则会转变为异步接<E6ADA5><E68EA5>? /// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址组同步接口必须在子线程中执行否则会转变为异步接<E6ADA5><E68EA5>?
/// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>? /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限<E4B88A><E99990>?s<><73>?
@@ -457,13 +457,13 @@ NS_ASSUME_NONNULL_BEGIN
/// @param host 域名 /// @param host 域名
/// @result 返回字典类型结构 /// @result 返回字典类型结构
/// { /// {
/// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// NewHDNS_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'] /// NewHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']
/// } /// }
- (NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); - (NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostSync:(NSString *)host NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead.");
/// 软件自定义解析接<E69E90><E68EA5>? /// 软件自定义解析接<E69E90><E68EA5>?
- (NSDictionary *)getIpsByHostAsync:(NSString *)host withParams:(NSDictionary<NSString *, NSString *> *)params withCacheKey:(NSString *)cacheKey Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:withSdnsParams:sdnsCacheKey:] instead."); - (NSDictionary *)getIpsByHostAsync:(NSString *)host withParams:(NSDictionary<NSString *, NSString *> *)params withCacheKey:(NSString *)cacheKey NEW_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:withSdnsParams:sdnsCacheKey:] instead.");
/// 清除指定host缓存<EFBC88><E58685>?沙盒数据库) /// 清除指定host缓存<EFBC88><E58685>?沙盒数据库)

View File

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

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsIpStackDetector.h // HttpdnsIpStackDetector.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2025/3/16. // Created by xuyecan on 2025/3/16.
// Copyright © 2025 trustapp.com. All rights reserved. // Copyright © 2025 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsLog_Internal.h // HttpdnsLog_Internal.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by junmo on 2018/12/19. // Created by junmo on 2018/12/19.
// Copyright © 2018<31><38>?trustapp.com. All rights reserved. // Copyright © 2018<31><38>?trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsLoggerProtocol.h // HttpdnsLoggerProtocol.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by junmo on 2018/12/19. // Created by junmo on 2018/12/19.
// Copyright © 2018<31><38>?trustapp.com. All rights reserved. // Copyright © 2018<31><38>?trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsHostRecord.h // HttpdnsHostRecord.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by ElonChan地风 on 2017/5/3. // Created by ElonChan地风 on 2017/5/3.
// Copyright © 2017<31><37>?trustapp.com. All rights reserved. // Copyright © 2017<31><37>?trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsHostRecord.m // HttpdnsHostRecord.m
// TrustHttpDNS // NewHttpDNS
// //
// Created by ElonChan on 2017/5/3. // Created by ElonChan on 2017/5/3.
// Copyright © 2017<EFBFBD><EFBFBD>?trustapp.com. All rights reserved. // Copyright © 2017<EFBFBD><EFBFBD>?trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsRequest.h // HttpdnsRequest.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/5/19. // Created by xuyecan on 2024/5/19.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.
@@ -10,14 +10,14 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
#ifndef TrustHTTPDNSQUERYIPTYPE #ifndef NewHTTPDNSQUERYIPTYPE
#define TrustHTTPDNSQUERYIPTYPE #define NewHTTPDNSQUERYIPTYPE
typedef enum { typedef enum {
TrustHttpDNS_IPTypeV4 = 0, //ipv4 NewHttpDNS_IPTypeV4 = 0, //ipv4
TrustHttpDNS_IPTypeV6 = 1, //ipv6 NewHttpDNS_IPTypeV6 = 1, //ipv6
TrustHttpDNS_IPTypeV64 = 2, //ipv4 + ipv6 NewHttpDNS_IPTypeV64 = 2, //ipv4 + ipv6
} TrustHttpDNS_IPType; } NewHttpDNS_IPType;
typedef NS_OPTIONS(NSUInteger, HttpdnsQueryIPType) { typedef NS_OPTIONS(NSUInteger, HttpdnsQueryIPType) {
HttpdnsQueryIPTypeAuto NS_SWIFT_NAME(auto) = 0, HttpdnsQueryIPTypeAuto NS_SWIFT_NAME(auto) = 0,

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsRequest.m // HttpdnsRequest.m
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/5/19. // Created by xuyecan on 2024/5/19.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsRequest_Internal.h // HttpdnsRequest_Internal.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/6/19. // Created by xuyecan on 2024/6/19.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsResult.h // HttpdnsResult.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/5/15. // Created by xuyecan on 2024/5/15.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsResult.m // HttpdnsResult.m
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/5/15. // Created by xuyecan on 2024/5/15.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.

View File

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

View File

@@ -99,7 +99,7 @@
_host = [host copy]; _host = [host copy];
_port = [port copy]; _port = [port copy];
_useTLS = useTLS; _useTLS = useTLS;
_queue = dispatch_queue_create("com.Trust.sdk.httpdns.network.connection.reuse", DISPATCH_QUEUE_SERIAL); _queue = dispatch_queue_create("com.New.sdk.httpdns.network.connection.reuse", DISPATCH_QUEUE_SERIAL);
_stateSemaphore = dispatch_semaphore_create(0); _stateSemaphore = dispatch_semaphore_create(0);
_state = nw_connection_state_invalid; _state = nw_connection_state_invalid;
_lastUsedDate = [NSDate date]; _lastUsedDate = [NSDate date];
@@ -135,14 +135,14 @@
if (secTrust && strongSelf) { if (secTrust && strongSelf) {
SecTrustRef trustRef = sec_trust_copy_ref(secTrust); SecTrustRef trustRef = sec_trust_copy_ref(secTrust);
if (trustRef) { if (trustRef) {
NSString *validIP = Trust_HTTPDNS_VALID_SERVER_CERTIFICATE_IP; NSString *validIP = NEW_HTTPDNS_VALID_SERVER_CERTIFICATE_IP;
isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:validIP]; isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:validIP];
if (!isValid && [HttpdnsUtil isNotEmptyString:strongSelf.host]) { if (!isValid && [HttpdnsUtil isNotEmptyString:strongSelf.host]) {
isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:strongSelf.host]; isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:strongSelf.host];
} }
if (!isValid && !strongSelf.stateError) { if (!isValid && !strongSelf.stateError) {
strongSelf.stateError = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN strongSelf.stateError = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"TLS trust validation failed"}]; userInfo:@{NSLocalizedDescriptionKey: @"TLS trust validation failed"}];
} }
CFRelease(trustRef); CFRelease(trustRef);
@@ -220,8 +220,8 @@
- (BOOL)openWithTimeout:(NSTimeInterval)timeout error:(NSError **)error { - (BOOL)openWithTimeout:(NSTimeInterval)timeout error:(NSError **)error {
if (self.invalidated) { if (self.invalidated) {
if (error) { if (error) {
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = _stateError ?: [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection invalid"}]; userInfo:@{NSLocalizedDescriptionKey: @"Connection invalid"}];
} }
return NO; return NO;
@@ -237,8 +237,8 @@
if (waitResult != 0) { if (waitResult != 0) {
self.invalidated = YES; self.invalidated = YES;
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection setup timed out"}]; userInfo:@{NSLocalizedDescriptionKey: @"Connection setup timed out"}];
} }
nw_connection_cancel(_connectionHandle); nw_connection_cancel(_connectionHandle);
@@ -250,8 +250,8 @@
} }
if (error) { if (error) {
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = _stateError ?: [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection failed to become ready"}]; userInfo:@{NSLocalizedDescriptionKey: @"Connection failed to become ready"}];
} }
return NO; return NO;
@@ -277,8 +277,8 @@
error:(NSError **)error { error:(NSError **)error {
if (!requestData || requestData.length == 0) { if (!requestData || requestData.length == 0) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Empty HTTP request"}]; userInfo:@{NSLocalizedDescriptionKey: @"Empty HTTP request"}];
} }
return nil; return nil;
@@ -286,8 +286,8 @@
if (![self isViable] || self.currentExchange) { if (![self isViable] || self.currentExchange) {
if (error) { if (error) {
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = _stateError ?: [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection not ready"}]; userInfo:@{NSLocalizedDescriptionKey: @"Connection not ready"}];
} }
return nil; return nil;
@@ -299,16 +299,16 @@
dispatch_sync(_queue, ^{ dispatch_sync(_queue, ^{
__strong typeof(weakSelf) strongSelf = weakSelf; __strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) { if (!strongSelf) {
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN exchange.error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection released unexpectedly"}]; userInfo:@{NSLocalizedDescriptionKey: @"Connection released unexpectedly"}];
exchange.finished = YES; exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore); dispatch_semaphore_signal(exchange.semaphore);
return; return;
} }
if (strongSelf.invalidated || strongSelf.currentExchange) { if (strongSelf.invalidated || strongSelf.currentExchange) {
exchange.error = strongSelf.stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN exchange.error = strongSelf.stateError ?: [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection is busy"}]; userInfo:@{NSLocalizedDescriptionKey: @"Connection is busy"}];
exchange.finished = YES; exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore); dispatch_semaphore_signal(exchange.semaphore);
@@ -320,8 +320,8 @@
if (exchange.finished) { if (exchange.finished) {
return; return;
} }
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN exchange.error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Request timed out"}]; userInfo:@{NSLocalizedDescriptionKey: @"Request timed out"}];
exchange.finished = YES; exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore); dispatch_semaphore_signal(exchange.semaphore);
@@ -366,8 +366,8 @@
if (waitResult != 0) { if (waitResult != 0) {
if (!exchange.error) { if (!exchange.error) {
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN exchange.error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Request wait timed out"}]; userInfo:@{NSLocalizedDescriptionKey: @"Request wait timed out"}];
} }
[self invalidate]; [self invalidate];
@@ -428,8 +428,8 @@
if (is_complete) { if (is_complete) {
exchange.remoteClosed = YES; exchange.remoteClosed = YES;
if (!exchange.finished) { if (!exchange.finished) {
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN exchange.error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE code:NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection closed before response completed"}]; userInfo:@{NSLocalizedDescriptionKey: @"Connection closed before response completed"}];
exchange.finished = YES; exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore); dispatch_semaphore_signal(exchange.semaphore);

View File

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

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsDB.h // HttpdnsDB.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2025/3/15. // Created by xuyecan on 2025/3/15.
// Copyright © 2025 trustapp.com. All rights reserved. // Copyright © 2025 trustapp.com. All rights reserved.

View File

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

View File

@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#import "HttpdnsScheduleCenter.h"
#import "HttpdnsPersistenceUtils.h"
#import "HttpdnsLog_Internal.h"
#import "HttpdnsInternalConstant.h"
#import "HttpdnsRequestManager.h"
#import "HttpdnsService_Internal.h"
#import "HttpdnsScheduleExecutor.h"
#import "HttpdnsRemoteResolver.h"
#import "HttpdnsUtil.h"
#import "HttpdnsPublicConstant.h"
#import "HttpdnsRegionConfigLoader.h"
#import "HttpdnsIpStackDetector.h"
static NSString *const kLastUpdateUnixTimestampKey = @"last_update_unix_timestamp";
static NSString *const kScheduleRegionConfigLocalCacheFileName = @"schedule_center_result";
static int const MAX_UPDATE_RETRY_COUNT = 2;
@interface HttpdnsScheduleCenter ()

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsScheduleExecutor.h // HttpdnsScheduleExecutor.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by ElonChan地风 on 2017/4/11. // Created by ElonChan地风 on 2017/4/11.
// Copyright © 2017<31><37>?trustapp.com. All rights reserved. // Copyright © 2017<31><37>?trustapp.com. All rights reserved.

View File

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

View File

@@ -1,6 +1,6 @@
// //
// HttpDnsLocker.h // HttpDnsLocker.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by 王贇 on 2023/8/16. // Created by 王贇 on 2023/8/16.
// Copyright © 2023 trustapp.com. All rights reserved. // Copyright © 2023 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpDnsLocker.m // HttpDnsLocker.m
// TrustHttpDNS // NewHttpDNS
// //
// Created by on 2023/8/16. // Created by on 2023/8/16.
// Copyright © 2023 trustapp.com. All rights reserved. // Copyright © 2023 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsHostObjectInMemoryCache.h // HttpdnsHostObjectInMemoryCache.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/9/28. // Created by xuyecan on 2024/9/28.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsHostObjectInMemoryCache.m // HttpdnsHostObjectInMemoryCache.m
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2024/9/28. // Created by xuyecan on 2024/9/28.
// Copyright © 2024 trustapp.com. All rights reserved. // Copyright © 2024 trustapp.com. All rights reserved.

View File

@@ -1,6 +1,6 @@
// //
// HttpdnsIPQualityDetector.h // HttpdnsIPQualityDetector.h
// TrustHttpDNS // NewHttpDNS
// //
// Created by xuyecan on 2025/3/13. // Created by xuyecan on 2025/3/13.
// Copyright © 2025 trustapp.com. All rights reserved. // Copyright © 2025 trustapp.com. All rights reserved.

View File

@@ -259,8 +259,8 @@
// <EFBFBD><EFBFBD>? // <EFBFBD><EFBFBD>?
if (plaintext == nil || [plaintext length] == 0 || key == nil || [key length] != kCCKeySizeAES128) { if (plaintext == nil || [plaintext length] == 0 || key == nil || [key length] != kCCKeySizeAES128) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE code:NEW_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Invalid input parameters"}]; userInfo:@{NSLocalizedDescriptionKey: @"Invalid input parameters"}];
} }
return nil; return nil;
@@ -271,8 +271,8 @@
int result = SecRandomCopyBytes(kSecRandomDefault, kCCBlockSizeAES128, iv.mutableBytes); int result = SecRandomCopyBytes(kSecRandomDefault, kCCBlockSizeAES128, iv.mutableBytes);
if (result != 0) { if (result != 0) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE code:NEW_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Failed to generate random IV"}]; userInfo:@{NSLocalizedDescriptionKey: @"Failed to generate random IV"}];
} }
return nil; return nil;
@@ -301,8 +301,8 @@
if (cryptStatus != kCCSuccess) { if (cryptStatus != kCCSuccess) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE code:NEW_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Encryption failed with status: %d", cryptStatus]}]; userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Encryption failed with status: %d", cryptStatus]}];
} }
return nil; return nil;
@@ -394,8 +394,8 @@
// <EFBFBD><EFBFBD>? // <EFBFBD><EFBFBD>?
if (ciphertext == nil || [ciphertext length] <= kCCBlockSizeAES128 || key == nil || [key length] != kCCKeySizeAES128) { if (ciphertext == nil || [ciphertext length] <= kCCBlockSizeAES128 || key == nil || [key length] != kCCKeySizeAES128) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE code:NEW_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Invalid input parameters for decryption"}]; userInfo:@{NSLocalizedDescriptionKey: @"Invalid input parameters for decryption"}];
} }
return nil; return nil;
@@ -427,8 +427,8 @@
if (cryptStatus != kCCSuccess) { if (cryptStatus != kCCSuccess) {
if (error) { if (error) {
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN *error = [NSError errorWithDomain:NEW_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE code:NEW_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Decryption failed with status: %d", cryptStatus]}]; userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Decryption failed with status: %d", cryptStatus]}];
} }
return nil; return nil;
@@ -453,14 +453,14 @@
if (dnsService.ttlDelegate && [dnsService.ttlDelegate respondsToSelector:@selector(httpdnsHost:ipType:ttl:)]) { if (dnsService.ttlDelegate && [dnsService.ttlDelegate respondsToSelector:@selector(httpdnsHost:ipType:ttl:)]) {
if ([self isNotEmptyArray:[hostObject getV4Ips]]) { if ([self isNotEmptyArray:[hostObject getV4Ips]]) {
int64_t customV4TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:TrustHttpDNS_IPTypeV4 ttl:hostObject.v4ttl]; int64_t customV4TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:NewHttpDNS_IPTypeV4 ttl:hostObject.v4ttl];
if (customV4TTL > 0) { if (customV4TTL > 0) {
hostObject.v4ttl = customV4TTL; hostObject.v4ttl = customV4TTL;
} }
} }
if ([self isNotEmptyArray:[hostObject getV6Ips]]) { if ([self isNotEmptyArray:[hostObject getV6Ips]]) {
int64_t customV6TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:TrustHttpDNS_IPTypeV6 ttl:hostObject.v6ttl]; int64_t customV6TTL = [dnsService.ttlDelegate httpdnsHost:host ipType:NewHttpDNS_IPTypeV6 ttl:hostObject.v6ttl];
if (customV6TTL > 0) { if (customV6TTL > 0) {
hostObject.v6ttl = customV6TTL; hostObject.v6ttl = customV6TTL;
} }

View File

@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#import "HttpdnsService_Internal.h"
#import "HttpdnsRemoteResolver.h"
#import "HttpdnsInternalConstant.h"
#import "HttpdnsHostObject.h"
#import "HttpdnsRequest_Internal.h"
#import "HttpdnsUtil.h"
#import "HttpdnsRequest.h"
#import "HttpdnsLog_Internal.h"
#import "HttpdnsScheduleCenter.h"
#import "HttpdnsPublicConstant.h"
#import "HttpdnsRegionConfigLoader.h"
#import "HttpdnsIpStackDetector.h"
static dispatch_queue_t asyncTaskConcurrentQueue;
static NSMutableDictionary<NSNumber *, HttpDnsService *> *httpdnsServiceInstances;
static dispatch_queue_t httpdnsServiceInstancesQueue;
static HttpDnsService *httpdnsFirstInitializedInstance;
static HttpDnsService *httpdnsSharedStubInstance;
@interface HttpDnsService ()
@property (nonatomic, assign) NSInteger accountID;
@property (nonatomic, copy) NSString *secretKey;
@property (nonatomic, copy) NSString *aesSecretKey;
@property (nonatomic, assign) BOOL hasConfiguredAccount;
// 姣忔

View File

@@ -1,4 +1,4 @@
source 'https://github.com/CocoaPods/Specs.git' source 'https://cdn.cocoapods.org/'
source 'https://github.com/aliyun/aliyun-specs.git' source 'https://github.com/aliyun/aliyun-specs.git'
use_frameworks! use_frameworks!

View File

@@ -0,0 +1 @@
NewHttpDNS

View File

@@ -1,16 +1,59 @@
#!/bin/bash #!/bin/bash
# ---------------------------------------------------------------
# build_xc_framework.sh
# Build NewHttpDNS.xcframework (device + simulator)
# Usage: sh build_xc_framework.sh
# ---------------------------------------------------------------
set -euo pipefail
set -x SCHEME="NewHttpDNS"
PROJECT="NewHttpDNS.xcodeproj"
FRAMEWORK_ID="httpdns" CONFIGURATION="Release"
FRAMEWORK_NAME="NewHttpDNS" FRAMEWORK_NAME="NewHttpDNS"
BUILD_CONFIG="release" BUILD_DIR="$(pwd)/Build"
BUILD_DIR="`pwd`/Build"
# remove and make Build directory ARCHIVE_IOS="${BUILD_DIR}/ios.xcarchive"
rm -rf Build && mkdir Build ARCHIVE_SIM="${BUILD_DIR}/ios-simulator.xcarchive"
OUTPUT_XCF="${BUILD_DIR}/${FRAMEWORK_NAME}.xcframework"
# clone git@gitlab.alibaba-inc.com:alicloud-ams/ios-xcframework-build-script.git to Build directory echo "==> Cleaning old build artifacts..."
git clone git@gitlab.alibaba-inc.com:alicloud-ams/ios-xcframework-build-script.git Build/ios-xcframework-build-script rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
sh Build/ios-xcframework-build-script/build.sh $FRAMEWORK_ID $FRAMEWORK_NAME $BUILD_CONFIG $BUILD_DIR # ---- 1. Archive: iOS device (arm64) ----
echo "==> Archive: iOS device (arm64)..."
xcodebuild archive \
-project "${PROJECT}" \
-scheme "${SCHEME}" \
-configuration "${CONFIGURATION}" \
-destination "generic/platform=iOS" \
-archivePath "${ARCHIVE_IOS}" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
ENABLE_MODULE_VERIFIER=NO \
| tail -1
# ---- 2. Archive: iOS Simulator (arm64 + x86_64) ----
echo "==> Archive: iOS Simulator (arm64 + x86_64)..."
xcodebuild archive \
-project "${PROJECT}" \
-scheme "${SCHEME}" \
-configuration "${CONFIGURATION}" \
-destination "generic/platform=iOS Simulator" \
-archivePath "${ARCHIVE_SIM}" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
ENABLE_MODULE_VERIFIER=NO \
| tail -1
# ---- 3. Create XCFramework ----
echo "==> Creating XCFramework..."
xcodebuild -create-xcframework \
-framework "${ARCHIVE_IOS}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \
-framework "${ARCHIVE_SIM}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \
-output "${OUTPUT_XCF}"
echo ""
echo "=========================================="
echo " Done! Output: ${OUTPUT_XCF}"
echo "=========================================="