feat: sync httpdns sdk/platform updates without large binaries
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// HttpdnsInternalConstant.h
|
||||
// TrustHttpDNS
|
||||
//
|
||||
// Created by xuyecan on 2025/03/10.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef HTTPDNS_INTERNAL_CONSTANT_H
|
||||
#define HTTPDNS_INTERNAL_CONSTANT_H
|
||||
|
||||
static const int HTTPDNS_MAX_REQUEST_RETRY_TIME = 1;
|
||||
|
||||
static const int HTTPDNS_MAX_MANAGE_HOST_NUM = 100;
|
||||
|
||||
static const int HTTPDNS_PRE_RESOLVE_BATCH_SIZE = 5;
|
||||
|
||||
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";
|
||||
|
||||
// 在iOS14和iOS16,网络信息的获取权限受到越来越紧的限<E79A84><E99990>?
|
||||
// 除非用户主动声明需要相关entitlement,不然只能拿到空信息
|
||||
// 考虑大多数用户并不会申请这些权限,我们放弃针对细节的网络信息做缓存粒度隔<E5BAA6><E99A94>?
|
||||
// 出于兼容性考虑,网络运营商只有default一种类<E7A78D><E7B1BB>?
|
||||
#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 Trust_HTTPDNS_ERROR_MESSAGE_KEY = @"ErrorMessage";
|
||||
|
||||
static NSString *const kTrustHttpdnsRegionConfigV4HostKey = @"service_ip";
|
||||
static NSString *const kTrustHttpdnsRegionConfigV6HostKey = @"service_ipv6";
|
||||
|
||||
static NSString *const kTrustHttpdnsRegionKey = @"HttpdnsRegion";
|
||||
|
||||
#define SECONDS_OF_ONE_YEAR 365 * 24 * 60 * 60
|
||||
|
||||
static NSString *const Trust_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 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 Trust_HTTP_UNSUPPORTED_STATUS_CODE = 10013;
|
||||
static NSInteger const Trust_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;
|
||||
|
||||
#endif
|
||||
21
HttpDNSSDK/sdk/ios/NewHttpDNS/Config/HttpdnsPublicConstant.h
Normal file
21
HttpDNSSDK/sdk/ios/NewHttpDNS/Config/HttpdnsPublicConstant.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// HttpdnsPublicConstant.h
|
||||
// TrustHttpDNS
|
||||
//
|
||||
// Created by xuyecan on 2024/6/16.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef PublicConstant_h
|
||||
#define PublicConstant_h
|
||||
|
||||
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"
|
||||
|
||||
|
||||
#endif /* PublicConstant_h */
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// HttpdnsRegionConfigLoader.h
|
||||
// TrustHttpDNS
|
||||
//
|
||||
// Created by xuyecan on 2024/6/16.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface HttpdnsRegionConfigLoader : NSObject
|
||||
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
+ (NSArray<NSString *> *)getAvailableRegionList;
|
||||
|
||||
- (NSArray *)getSeriveV4HostList:(NSString *)region;
|
||||
|
||||
- (NSArray *)getUpdateV4FallbackHostList:(NSString *)region;
|
||||
|
||||
- (NSArray *)getSeriveV6HostList:(NSString *)region;
|
||||
|
||||
- (NSArray *)getUpdateV6FallbackHostList:(NSString *)region;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
112
HttpDNSSDK/sdk/ios/NewHttpDNS/Config/HttpdnsRegionConfigLoader.m
Normal file
112
HttpDNSSDK/sdk/ios/NewHttpDNS/Config/HttpdnsRegionConfigLoader.m
Normal file
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// HttpdnsRegionConfigLoader.m
|
||||
// TrustHttpDNS
|
||||
//
|
||||
// Created by xuyecan on 2024/6/16.
|
||||
// Copyright © 2024 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#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 NSArray<NSString *> *Trust_HTTPDNS_AVAILABLE_REGION_LIST = nil;
|
||||
|
||||
@interface HttpdnsRegionConfigLoader ()
|
||||
|
||||
@property (nonatomic, strong) NSDictionary *regionConfig;
|
||||
|
||||
@end
|
||||
|
||||
@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
|
||||
];
|
||||
}
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static HttpdnsRegionConfigLoader *instance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
instance = [[HttpdnsRegionConfigLoader alloc] init];
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
[self loadRegionConfig];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSArray<NSString *> *)getAvailableRegionList {
|
||||
return Trust_HTTPDNS_AVAILABLE_REGION_LIST;
|
||||
}
|
||||
|
||||
- (void)loadRegionConfig {
|
||||
self.regionConfig = @{
|
||||
Trust_HTTPDNS_DEFAULT_REGION_KEY: @{
|
||||
kServiceV4Key: @[@"203.107.1.1", @"203.107.1.97", @"203.107.1.100", @"203.119.238.240", @"106.11.25.239", @"59.82.99.47"],
|
||||
kUpdateV4FallbackHostKey: @[@"resolvers-cn.httpdns.TrustAPPcs.com"],
|
||||
kServiceV6Key: @[@"2401:b180:7001::31d", @"2401:b180:2000:30::1c", @"2401:b180:2000:20::10", @"2401:b180:2000:30::1c"],
|
||||
kUpdateV6FallbackHostKey: @[@"resolvers-cn.httpdns.TrustAPPcs.com"]
|
||||
},
|
||||
Trust_HTTPDNS_HONGKONG_REGION_KEY: @{
|
||||
kServiceV4Key: @[@"47.56.234.194", @"47.56.119.115"],
|
||||
kUpdateV4FallbackHostKey: @[@"resolvers-hk.httpdns.TrustAPPcs.com"],
|
||||
kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"],
|
||||
kUpdateV6FallbackHostKey: @[@"resolvers-hk.httpdns.TrustAPPcs.com"]
|
||||
},
|
||||
Trust_HTTPDNS_SINGAPORE_REGION_KEY: @{
|
||||
kServiceV4Key: @[@"161.117.200.122", @"47.74.222.190"],
|
||||
kUpdateV4FallbackHostKey: @[@"resolvers-sg.httpdns.TrustAPPcs.com"],
|
||||
kServiceV6Key: @[@"240b:4000:f10::178", @"240b:4000:f10::188"],
|
||||
kUpdateV6FallbackHostKey: @[@"resolvers-sg.httpdns.TrustAPPcs.com"]
|
||||
},
|
||||
Trust_HTTPDNS_GERMANY_REGION_KEY: @{
|
||||
kServiceV4Key: @[@"47.89.80.182", @"47.246.146.77"],
|
||||
kUpdateV4FallbackHostKey: @[@"resolvers-de.httpdns.TrustAPPcs.com"],
|
||||
kServiceV6Key: @[@"2404:2280:3000::176", @"2404:2280:3000::188"],
|
||||
kUpdateV6FallbackHostKey: @[@"resolvers-de.httpdns.TrustAPPcs.com"]
|
||||
},
|
||||
Trust_HTTPDNS_AMERICA_REGION_KEY: @{
|
||||
kServiceV4Key: @[@"47.246.131.175", @"47.246.131.141"],
|
||||
kUpdateV4FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"],
|
||||
kServiceV6Key: @[@"2404:2280:4000::2bb", @"2404:2280:4000::23e"],
|
||||
kUpdateV6FallbackHostKey: @[@"resolvers-us.httpdns.TrustAPPcs.com"]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
- (NSArray *)getSeriveV4HostList:(NSString *)region {
|
||||
NSDictionary *regionConfing = [self.regionConfig objectForKey:region];
|
||||
return [regionConfing objectForKey:kServiceV4Key];
|
||||
}
|
||||
|
||||
- (NSArray *)getUpdateV4FallbackHostList:(NSString *)region {
|
||||
NSDictionary *regionConfing = [self.regionConfig objectForKey:region];
|
||||
return [regionConfing objectForKey:kUpdateV4FallbackHostKey];
|
||||
}
|
||||
|
||||
- (NSArray *)getSeriveV6HostList:(NSString *)region {
|
||||
NSDictionary *regionConfing = [self.regionConfig objectForKey:region];
|
||||
return [regionConfing objectForKey:kServiceV6Key];
|
||||
}
|
||||
|
||||
- (NSArray *)getUpdateV6FallbackHostList:(NSString *)region {
|
||||
NSDictionary *regionConfing = [self.regionConfig objectForKey:region];
|
||||
return [regionConfing objectForKey:kUpdateV6FallbackHostKey];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user