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

@@ -1,6 +1,6 @@
//
// HttpdnsInternalConstant.h
// TrustHttpDNS
// NewHttpDNS
//
// Created by xuyecan on 2025/03/10.
// 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 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>?
// 除非用户主动声明需要相关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"
// 调度地址示例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 kTrustHttpdnsRegionConfigV6HostKey = @"service_ipv6";
static NSString *const kNewHttpdnsRegionConfigV4HostKey = @"service_ip";
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
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 Trust_HTTPDNS_HTTP_COMMON_ERROR_CODE = 10004;
static NSInteger const NEW_HTTPDNS_HTTPS_COMMON_ERROR_CODE = 10003;
static NSInteger const NEW_HTTPDNS_HTTP_COMMON_ERROR_CODE = 10004;
static NSInteger const Trust_HTTPDNS_HTTPS_TIMEOUT_ERROR_CODE = 10005;
static NSInteger const Trust_HTTPDNS_HTTP_TIMEOUT_ERROR_CODE = 10006;
static NSInteger const Trust_HTTPDNS_HTTP_OPEN_STREAM_ERROR_CODE = 10007;
static NSInteger const Trust_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE = 10008;
static NSInteger const NEW_HTTPDNS_HTTPS_TIMEOUT_ERROR_CODE = 10005;
static NSInteger const NEW_HTTPDNS_HTTP_TIMEOUT_ERROR_CODE = 10006;
static NSInteger const NEW_HTTPDNS_HTTP_OPEN_STREAM_ERROR_CODE = 10007;
static NSInteger const NEW_HTTPDNS_HTTPS_NO_DATA_ERROR_CODE = 10008;
static NSInteger const Trust_HTTP_UNSUPPORTED_STATUS_CODE = 10013;
static NSInteger const Trust_HTTP_PARSE_JSON_FAILED = 10014;
static NSInteger const NEW_HTTP_UNSUPPORTED_STATUS_CODE = 10013;
static NSInteger const NEW_HTTP_PARSE_JSON_FAILED = 10014;
// 加密错误<E99499><E8AFAF>?
static NSInteger const Trust_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE = 10021;
static NSInteger const Trust_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE = 10022;
static NSInteger const Trust_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE = 10023;
static NSInteger const NEW_HTTPDNS_ENCRYPT_INVALID_PARAMS_ERROR_CODE = 10021;
static NSInteger const NEW_HTTPDNS_ENCRYPT_RANDOM_IV_ERROR_CODE = 10022;
static NSInteger const NEW_HTTPDNS_ENCRYPT_FAILED_ERROR_CODE = 10023;
#endif

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
//
// HttpdnsRegionConfigLoader.m
// TrustHttpDNS
// NewHttpDNS
//
// Created by xuyecan on 2024/6/16.
// Copyright © 2024 trustapp.com. All rights reserved.
@@ -9,12 +9,12 @@
#import "HttpdnsRegionConfigLoader.h"
#import "HttpdnsPublicConstant.h"
static NSString *const kServiceV4Key = @"Trust_HTTPDNS_SERVICE_HOST_V4_KEY";
static NSString *const kUpdateV4FallbackHostKey = @"Trust_HTTPDNS_UPDATE_HOST_V4_KEY";
static NSString *const kServiceV6Key = @"Trust_HTTPDNS_SERVICE_HOST_V6_KEY";
static NSString *const kUpdateV6FallbackHostKey = @"Trust_HTTPDNS_UPDATE_HOST_V6_KEY";
static NSString *const kServiceV4Key = @"NEW_HTTPDNS_SERVICE_HOST_V4_KEY";
static NSString *const kUpdateV4FallbackHostKey = @"NEW_HTTPDNS_UPDATE_HOST_V4_KEY";
static NSString *const kServiceV6Key = @"NEW_HTTPDNS_SERVICE_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 ()
@@ -25,12 +25,12 @@ static NSArray<NSString *> *Trust_HTTPDNS_AVAILABLE_REGION_LIST = nil;
@implementation HttpdnsRegionConfigLoader
+ (void)initialize {
Trust_HTTPDNS_AVAILABLE_REGION_LIST = @[
Trust_HTTPDNS_DEFAULT_REGION_KEY,
Trust_HTTPDNS_HONGKONG_REGION_KEY,
Trust_HTTPDNS_SINGAPORE_REGION_KEY,
Trust_HTTPDNS_GERMANY_REGION_KEY,
Trust_HTTPDNS_AMERICA_REGION_KEY
NEW_HTTPDNS_AVAILABLE_REGION_LIST = @[
NEW_HTTPDNS_DEFAULT_REGION_KEY,
NEW_HTTPDNS_HONGKONG_REGION_KEY,
NEW_HTTPDNS_SINGAPORE_REGION_KEY,
NEW_HTTPDNS_GERMANY_REGION_KEY,
NEW_HTTPDNS_AMERICA_REGION_KEY
];
}
@@ -51,40 +51,40 @@ static NSArray<NSString *> *Trust_HTTPDNS_AVAILABLE_REGION_LIST = nil;
}
+ (NSArray<NSString *> *)getAvailableRegionList {
return Trust_HTTPDNS_AVAILABLE_REGION_LIST;
return NEW_HTTPDNS_AVAILABLE_REGION_LIST;
}
- (void)loadRegionConfig {
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"],
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"],
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"],
kUpdateV4FallbackHostKey: @[@"resolvers-hk.httpdns.TrustAPPcs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-hk.httpdns.NewAPPcs.com"],
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"],
kUpdateV4FallbackHostKey: @[@"resolvers-sg.httpdns.TrustAPPcs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-sg.httpdns.NewAPPcs.com"],
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"],
kUpdateV4FallbackHostKey: @[@"resolvers-de.httpdns.TrustAPPcs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-de.httpdns.NewAPPcs.com"],
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"],
kUpdateV4FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"],
kUpdateV4FallbackHostKey: @[@"resolvers-us.httpdns.NewAPPcs.com"],
kServiceV6Key: @[@"2404:2280:4000::2bb", @"2404:2280:4000::23e"],
kUpdateV6FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"]
kUpdateV6FallbackHostKey: @[@"resolvers-us.httpdns.NewAPPcs.com"]
}
};
}