Name | Applicable Scope |
MSDKDns.xcframework | Applicable to projects with "Build Setting->C Language Dialect" configured as "GNU++98" and "Build Setting->C++ Standard Library" as "libstdc (GNU C standard library)" . |
MSDKDns_intl.xcframework | MSDKDns.xcframework version for Tencent Cloud International. |
MSDKDns_C11.xcframework | Applicable to projects with "Build Setting->C Language Dialect" and "Build Setting->C Standard Library" configured as "GNU++11" and "libc++(LLVM C standard library with C11 support)", respectively. |
MSDKDns_C11_intl.xcframework | MSDKDns_C11.xcframework version for Tencent Cloud International. |
sudo gem install cocoapods
pod init
# Applies to projects with "Build Setting->C++ Language Dialect" configured as **"GNU++98"** and "Build Setting->C++ Standard Library" as **"libstdc++(GNU C++ standard library)"**.pod 'MSDKDns_intl'# Applies to projects with these two configurations set as **"GNU++11"** and **"libc++(LLVM C++ standard library with C++11 support)"**.# pod 'MSDKDns_C11_intl'
pod install
pod update
MSDKDns_C11_intl.framework (or MSDKDns_framework, depending on the project configuration)

#import <MSDKDns_C11_intl/MSDKDns.h>
// Support for importing in the bridging header file#import "MSDKDns_C11_intl/MSDKDns.h"
// Use in .m files in the following ways:DnsConfig config = {.dnsId = dns authorization id, // Obtain in the mobile domain name resolution Tencent Cloud console. Refer to the "preliminary preparation" screenshot above. The "authorization id" is located at the top-left corner..dnsKey = @"secretkey",.encryptType = HttpDnsEncryptTypeDES,.debug = YES,.timeout = 2000,};[[MSDKDns sharedInstance] initConfig: &config];// Use in .mm files in the following ways:DnsConfig *config = new DnsConfig();config->dnsId = dns authorization id; // Obtain in the console of Tencent Cloud Mobile Domain Name Resolution, refer to the above text "preliminary preparation" screenshot, "authorization id" is at the top-left corner.config->dnsKey = @"secretkey";config->encryptType = HttpDnsEncryptTypeDES;config->debug = YES;config->timeout = 2000;[[MSDKDns sharedInstance] initConfig: config];
let msdkDns = MSDKDns.sharedInstance() as? MSDKDns;msdkDns?.initConfig(with: ["dnsId": "dns authorization id", // Obtain in the console of Tencent Cloud Mobile Domain Name Resolution, see the screenshot in the "preliminary preparation" section, the "authorization id" is at the top-left corner"dnsKey": "secretkey","encryptType": 0, // 0 -> des,1 -> aes]);
api name:HDNSGetHostByName, data: { ... } log, and check the log info of the local DNS ( ldns_ip in the log) and HTTPDNS ( hdns_ip in the log) to determine whether the connection is successful.NSURL *httpDnsURL = [NSURL URLWithString:@"URL concatenated with parsing result ip"];float timeOut = timeout period;NSMutableURLRequest *mutableReq = [NSMutableURLRequest requestWithURL:httpDnsURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: timeOut];[mutableReq setValue:@"original domain name" forHTTPHeaderField:@"host"];NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:mutableReq delegate:self];[connection start];
NSURL *httpDnsURL = [NSURL URLWithString:@"URL concatenated with parsing result ip"];float timeOut = timeout period;NSMutableURLRequest *mutableReq = [NSMutableURLRequest requestWithURL:httpDnsURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: timeOut];[mutableReq setValue:@"original domain name" forHTTPHeaderField:@"host"];NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue currentQueue]];NSURLSessionTask *task = [session dataTaskWithRequest:mutableReq];[task resume];
curl -H "host:www.qq.com" http://192.168.0.111/aaa.txt.
string httpDnsURL = "URL concatenated with parsing result ip";Dictionary<string, string> headers = new Dictionary<string, string> ();headers["host"] = "original domain name";WWW conn = new WWW (url, null, headers);yield return conn;if (conn.error != null) {print("error is happened:"+ conn.error);} else {print("request ok" + conn.text);}
NSURL *httpDnsURL = [NSURL URLWithString:@"URL concatenated with parsing result ip"];float timeOut = timeout period;NSMutableURLRequest *mutableReq = [NSMutableURLRequest requestWithURL:httpDnsURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: timeOut];[mutableReq setValue:@"original domain name" forHTTPHeaderField:@"host"];NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];AFHTTPSessionManager* sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:config];sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];NSURLSessionDataTask *task = [sessionManager dataTaskWithRequest:mutableRequploadProgress:nildownloadProgress:nilcompletionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {if (!error) {NSString *responseString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];NSLog(@"request complete ==== response: %@ ===== error: nil", responseString);} else {NSLog(@"request complete ==== response: nil ===== error: %@", error);}}];[task resume];
- (BOOL)isUseHTTPProxy {CFDictionaryRef dicRef = CFNetworkCopySystemProxySettings();const CFStringRef proxyCFstr = (const CFStringRef)CFDictionaryGetValue(dicRef, (const void*)kCFNetworkProxiesHTTPProxy);NSString *proxy = (__bridge NSString *)proxyCFstr;if (proxy) {return YES;} else {return NO;}}
Feedback