feat: sync httpdns sdk/platform updates without large binaries
This commit is contained in:
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