dnsId
参数,用于域名解析鉴权。dnsKey
参数,加密方式为 DES 时传入此项。dnsKey
参数,加密方式为 AES 时传入此项。token
参数,加密方式为 HTTPS 时传入此项。名称 | 适用说明 |
MSDKDns.xcframework | 适用 “Build Setting->C++ Language Dialect” 配置为 “GNU++98”,“Build Setting->C++ Standard Library” 为 “libstdc++(GNU C++ standard library)” 的工程。 |
MSDKDns_intl.xcframework | MSDKDns.xcframework 的国际站版本 |
MSDKDns_C11.xcframework | 适用于该两项配置分别为 “GNU++11”和“libc++(LLVM C++ standard library with C++11 support)”的工程。 |
MSDKDns_C11_intl.xcframework | MSDKDns_C11.xcframework 的国际站版本 |
# 适用“Build Setting->C++ Language Dialect”配置为**“GNU++98”**,“Build Setting->C++ Standard Library”为**“libstdc++(GNU C++ standard library)”**的工程。pod 'MSDKDns_intl'# 适用于该两项配置分别为**“GNU++11”**和**“libc++(LLVM C++ standard library with C++11 support)”**的工程。# pod 'MSDKDns_C11_intl'
pod install
,再使用后缀为 .xcworkspace
的文件打开工程。//.m文件使用如下方式:DnsConfig config = {.dnsId = dns授权id, // 从移动解析腾讯云控制台中获取,可以参考上文“前期准备”的截图,“授权ID”在左上角位置.dnsKey = @"加密密钥",.encryptType = HttpDnsEncryptTypeDES,.debug = YES,.timeout = 2000,};[[MSDKDns sharedInstance] initConfig: &config];// .mm文件可以使用如下方式:DnsConfig *config = new DnsConfig();config->dnsId = dns授权id; // 从移动解析腾讯云控制台中获取,可以参考上文“前期准备”的截图,“授权ID”在左上角位置config->dnsKey = @"加密密钥";config->encryptType = HttpDnsEncryptTypeDES;config->debug = YES;config->timeout = 2000;[[MSDKDns sharedInstance] initConfig: config];
let msdkDns = MSDKDns.sharedInstance() as? MSDKDns;msdkDns?.initConfig(with: ["dnsId": "dns授权id", // 从移动解析腾讯云控制台中获取,可以参考上文“前期准备”的截图,“授权ID”在左上角位置"dnsKey": "加密密钥","encryptType": 0, // 0 -> des,1 -> aes,2 -> https]);
api name:HDNSGetHostByName, data: { ... }
日志,并检查 HTTPDNS(日志上为 hdns_ip)和 LocalDns(日志上为 ldns_ip)相关日志,可以确认接入是否成功。NSURL *httpDnsURL = [NSURL URLWithString:@"使用解析结果ip拼接的URL"];float timeOut = 设置的超时时间;NSMutableURLRequest *mutableReq = [NSMutableURLRequest requestWithURL:httpDnsURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: timeOut];[mutableReq setValue:@"原域名" forHTTPHeaderField:@"host"];NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:mutableReq delegate:self];[connection start];
NSURL *httpDnsURL = [NSURL URLWithString:@"使用解析结果ip拼接的URL"];float timeOut = 设置的超时时间;NSMutableURLRequest *mutableReq = [NSMutableURLRequest requestWithURL:httpDnsURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: timeOut];[mutableReq setValue:@"原域名" 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 = "使用解析结果ip拼接的URL";Dictionary<string, string> headers = new Dictionary<string, string> ();headers["host"] = "原域名";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;}}
本页内容是否解决了您的问题?