dnsId
parameter in the SDK used for DNS authentication.dnsKey
parameter in the SDK, which you need to pass in when using the DES encryption method.dnsKey
parameter in the SDK, which you need to pass in when using the AES encryption method.token
parameter in the SDK, which you need to pass in when using the HTTPS encryption method.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 |
Podfile
of the project:# 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)"**.pod 'MSDKDns_intl'# 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 C++11 support)"**, respectively.# pod 'MSDKDns_C11_intl'
pod install
, and open the project with a file with the .xcworkspace
extension.MSDKDns_C11_intl.framework
(or MSDKDns_intl.framework
, depending on the project configuration)-ObjC
flag in Other Linker Flags
.// Use the following method for a .m file:DnsConfig config = {.dnsId = DNS authorization ID, // Obtain the authorization ID from the HTTPDNS console, as shown in the upper-left corner of the screenshot in the "Preparations" section above..dnsKey = @"Encryption key",.encryptType = HttpDnsEncryptTypeDES,.debug = YES,.timeout = 2000,};[[MSDKDns sharedInstance] initConfig: &config];// Use the following method for a .mm file:DnsConfig *config = new DnsConfig();config->dnsId = DNS authorization ID; // Obtain the authorization ID from the HTTPDNS console, as shown in the upper-left corner of the screenshot in the "Preparations" section above.config->dnsKey = @"Encryption key";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 the authorization ID from the HTTPDNS console, as shown in the upper-left corner of the screenshot in the "Preparations" section above."dnsKey": "Encryption key","encryptType": 0, // 0: DES; 1: AES; 2: HTTPS]);
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 obtained by concatenating the resolved IP"];float timeOut = The set timeout period;NSMutableURLRequest *mutableReq = [NSMutableURLRequest requestWithURL:httpDnsURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: timeOut];[mutableReq setValue:@"original domain" forHTTPHeaderField:@"host"];NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:mutableReq delegate:self];[connection start];
NSURL *httpDnsURL = [NSURL URLWithString:@"URL obtained by concatenating the resolved IP"];float timeOut = The set timeout period;NSMutableURLRequest *mutableReq = [NSMutableURLRequest requestWithURL:httpDnsURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: timeOut];[mutableReq setValue:@"original domain" forHTTPHeaderField:@"host"];NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue currentQueue]];NSURLSessionTask *task = [session dataTaskWithRequest:mutableReq];[task resume];
www.qq.com
and the IP obtained by HTTPDNS is 192.168.0.111
, you can perform a call as follows:curl -H "host:www.qq.com" http://192.168.0.111/aaa.txt.
string httpDnsURL = "URL obtained by concatenating the resolved IP";Dictionary<string, string> headers = new Dictionary<string, string> ();headers["host"] = "Original domain";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);}
- (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;}}
- (BOOL)isUseHTTPSProxy {CFDictionaryRef dicRef = CFNetworkCopySystemProxySettings();const CFStringRef proxyCFstr = (const CFStringRef)CFDictionaryGetValue(dicRef, (const void*)kCFNetworkProxiesHTTPSProxy);NSString *proxy = (__bridge NSString *)proxyCFstr;if (proxy) {return YES;} else {return NO;}}
Was this page helpful?