/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #import // 头文件包含需使用相对目录,确保通过 CocoaPods 安装后能被模块化编译找到 // #import "HttpdnsRequest.h" // #import "HttpdnsResult.h" // #import "HttpdnsDegradationDelegate.h" // #import "HttpdnsLoggerProtocol.h" #import "HttpdnsRequest.h" #import "HttpDnsResult.h" #import "HttpdnsLoggerProtocol.h" #import "HttpdnsDegradationDelegate.h" #define Trust_HTTPDNS_DEPRECATED(explain) __attribute__((deprecated(explain))) #ifndef TrustHDNS_STACK_KEY #define TrustHDNS_STACK_KEY #define TrustHDNS_IPV4 @"TrustHDNS_IPV4" #define TrustHDNS_IPV6 @"TrustHDNS_IPV6" #endif NS_ASSUME_NONNULL_BEGIN @protocol HttpdnsTTLDelegate /// 自定义HOST的TTL时长 /// @return 返回需要自定义的TTL时长 /// @param host 域名 /// @param ipType 当前查询的IP类型 /// @param ttl 当次域名解析返回的TTL - (int64_t)httpdnsHost:(NSString * _Nonnull)host ipType:(TrustHttpDNS_IPType)ipType ttl:(int64_t)ttl; @end @interface HttpDnsService: NSObject @property (nonatomic, assign, readonly) NSInteger accountID; @property (nonatomic, copy, readonly, nullable) NSString *secretKey; @property (nonatomic, copy, readonly, nullable) NSString *aesSecretKey; @property (nonatomic, weak, setter=setDelegateForDegradationFilter:) id delegate Trust_HTTPDNS_DEPRECATED("不再建议通过设置此回调实现降级逻辑,而是自行在调用HTTPDNS解析域名前做判断"); @property (nonatomic, weak) id ttlDelegate; + (nonnull instancetype)sharedInstance; /// 获取指定账号对应?HttpDnsService 实例 /// @param accountID 账号 ID /// @return 已初始化的实例,若账号尚未注册则返回 nil + (nullable instancetype)getInstanceByAccountId:(NSInteger)accountID; /*! * @brief 无需鉴权功能的初始化接口 * @details 初始化,设置 HTTPDNS 服务 Account ID。使用本接口初始化,请求将无任何签名保护,请谨慎使用? * 您可以从控制台获取您?Account ID ? * 此方法会初始化为单例? * 注意:本接口?.2.1起废弃,后续将进行移除? * @param accountID 您的 HTTPDNS Account ID */ - (nonnull instancetype)initWithAccountID:(NSInteger)accountID Trust_HTTPDNS_DEPRECATED("Deprecated. This method will be removed in the future. Use -[HttpDnsService initWithAccountID:secretKey:] instead."); /*! * @brief 启用鉴权功能的初始化接口 * @details 初始化、开启鉴权功能,并设?HTTPDNS 服务 Account ID,鉴权功能对应的 secretKey? * 您可以从控制台获取您?Account ID 、secretKey信息? * 此方法会初始化为单例? * @param accountID 您的 HTTPDNS Account ID * @param secretKey 鉴权对应?secretKey */ - (nonnull instancetype)initWithAccountID:(NSInteger)accountID secretKey:(NSString * _Nonnull)secretKey; /*! * @brief 启用鉴权功能、加密功能的初始化接? * @details 初始化、开启鉴权功能、开启AES加密,并设置 HTTPDNS 服务 Account ID,鉴权功能对应的 secretKey,加密功能对应的 aesSecretKey? * 您可以从控制台获取您?Account ID 、secretKey、aesSecretKey 信息? * 此方法会初始化为单例? * @param accountID 您的 HTTPDNS Account ID * @param secretKey 鉴权对应?secretKey * @param aesSecretKey 加密功能对应?aesSecretKey */ - (nonnull instancetype)initWithAccountID:(NSInteger)accountID secretKey:(NSString * _Nonnull)secretKey aesSecretKey:(NSString * _Nullable)aesSecretKey; /// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间? /// 注意,校正操作在 APP 的一个生命周期内生效,APP 重启后需要重新设置才能重新生? /// @param authCurrentTime 用于校正的时间戳,单位为? - (void)setAuthCurrentTime:(NSUInteger)authCurrentTime Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setInternalAuthTimeBaseBySpecifyingCurrentTime:] instead."); /// 开启鉴权功能后,鉴权的签名计算默认读取设备当前时间。若担心设备时间不准确导致签名不准确,可以使用此接口校正 APP 内鉴权计算使用的时间? /// 注意,校正操作在 APP 的一个生命周期内生效,APP 重启后需要重新设置才能重新生? /// @param currentTime 用于校正的时间戳,单位为? - (void)setInternalAuthTimeBaseBySpecifyingCurrentTime:(NSTimeInterval)currentTime; /// 设置持久化缓存功? /// @param enable YES: 开?NO: 关闭 - (void)setCachedIPEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setPersistentCacheIPEnabled:] instead."); /// 设置持久化缓存功? /// 开启后,每次解析会将结果持久化缓存到本地,当下次应用启动时,可以从本地加载缓存解析结果,提高应用启动时获取解析结果的速度 /// 加载时,会丢弃已经过期的解析结果 /// @param enable YES: 开?NO: 关闭 - (void)setPersistentCacheIPEnabled:(BOOL)enable; /// 设置持久化缓存功? /// 开启后,每次解析会将结果持久化缓存到本地,当下次应用启动时,可以从本地加载缓存解析结果,提高应用启动时获取解析结果的速度 /// 加载时,会丢弃过期时间已经超过指定值的解析结果 /// @param enable YES: 开?NO: 关闭 /// @param duration 决定丢弃IP的过期时间阈值,单位为秒,过期超过这个时间范围的IP会被丢弃,取值范围为0-1年。这个值仅在开启持久化缓存功能时才有意? - (void)setPersistentCacheIPEnabled:(BOOL)enable discardRecordsHasExpiredFor:(NSTimeInterval)duration; /// 是否允许 HTTPDNS 返回 TTL 过期域名?ip ,建议允许(默认不允许) /// @param enable YES: 开?NO: 关闭 - (void)setExpiredIPEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setReuseExpiredIPEnabled:] instead."); /// 是否允许 HTTPDNS 返回 TTL 过期域名?ip ,建议允许(默认不允许) /// @param enable YES: 开?NO: 关闭 - (void)setReuseExpiredIPEnabled:(BOOL)enable; /// 设置 HTTPDNS 域名解析请求类型 ( HTTP / HTTPS ) /// 若不调用该接口,默认?HTTP 请求? /// HTTP 请求基于底层 CFNetwork 实现,不?ATS 限制? /// @param enable YES: HTTPS请求 NO: HTTP请求 - (void)setHTTPSRequestEnabled:(BOOL)enable; /// 声明App是否配置了ATS为AllowsArbitraryLoads,默认认为没有配? /// 若做了声明,则当指定走HTTP方式解析域名时,解析链路会走系统NSURLSession逻辑 /// 否则,会走定制的CFHTTP链路,避免被ATS拦截请求 - (void)setHasAllowedArbitraryLoadsInATS:(BOOL)hasAllowedArbitraryLoadsInATS; /// 设置底层HTTPDNS网络请求超时时间,单位为? /// 需要注意,这个值只决定底层解析请求的网络超时时间,而非同步解析接口、异步解析接口的最长阻塞或者等待时? /// 同步解析接口、异步解析接口的最长阻塞或者等待时间,需要调用接口时设置request参数中的`resolveTimeoutInSecond`决定 /// @param timeoutInterval 超时时间,单位为? - (void)setNetworkingTimeoutInterval:(NSTimeInterval)timeoutInterval; /// 指定region,指定后会读取该region对应配置作为初始化配? /// 一般情况下无需设置,SDK内部会默认路由全球范围内最近的接入? /// @param region 需要指定的region,缺省为中国大陆 - (void)setRegion:(NSString *)region; /// 域名预解?(默认解析双栈记录) /// 通常用于启动后立即向SDK设置您后续可能会使用到的热点域名,以便SDK提前解析,减少后续解析域名时请求的时? /// 如果是在运行过程中调用,SDK也会立即解析设置的域名数组中的域名,刷新这些域名的解析结? /// /// @param hosts 预解析列表数? - (void)setPreResolveHosts:(NSArray *)hosts; /// 域名预解析,可以指定预解析auto、ipv4、ipv6、both /// 通常用于启动后立即向SDK设置您后续可能会使用到的热点域名,以便SDK提前解析,减少后续解析域名时请求的时? /// 如果是在运行过程中调用,SDK也会立即解析设置的域名数组中的域名,刷新这些域名的解析结? /// /// @param hosts 预解析列表数? /// @param ipType 指定预解析记录类? - (void)setPreResolveHosts:(NSArray *)hosts byIPType:(HttpdnsQueryIPType)ipType; /// 域名预解? /// @param hosts 域名 /// @param ipType 4: ipv4; 6: ipv6; 64: ipv4+ipv6 - (void)setPreResolveHosts:(NSArray *)hosts queryIPType:(TrustHttpDNS_IPType)ipType Trust_HTTPDNS_DEPRECATED("Deprecated, this method will be removed in the future. Use -[HttpDnsService setPreResolveHosts:byIPType:] instead."); /// 本地日志 log 开? /// @param enable YES: 打开 NO: 关闭 - (void)setLogEnabled:(BOOL)enable; /// 设置网络切换时是否自动更新所有域名解析结? /// 如果打开此开关,在网络切换时,会自动刷新所有域名的解析结果,但会产生一定流量消? /// @param enable YES: 开?NO: 关闭 - (void)setPreResolveAfterNetworkChanged:(BOOL)enable; /// 设置当httpdns解析失败时是否降级到localDNS尝试解析 /// 降级生效时,SDNS参数不生效,降级逻辑只解析域名,返回的结果默认使?0?若未指定该域名自定义TTL)作为TTL? /// 降级请求也不会再对ip进行优先排序 /// 默认关闭,不会自动降? /// @param enable YES:自动降?NO:不自动降级 - (void)setDegradeToLocalDNSEnabled:(BOOL)enable; /// 设置IP排优规则 /// @param IPRankingDatasource 设置对应域名的端口号 /// @{host: port} - (void)setIPRankingDatasource:(NSDictionary *)IPRankingDatasource; /// 设置是否 开?IPv6 结果解析。只有开启状态下,对域名的解析才会尝试解析v6记录并返回v6的结? /// @param enable YES: 开?NO: 关闭 - (void)enableIPv6:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService setIPv6Enabled:] instead."); /// 设置是否 开?IPv6 结果解析。只有开启状态下,对域名的解析才会尝试解析v6记录并返回v6的结? /// 已弃用。默认支持IPv6。如果不需要IPv6类型的结果,只需在请求时指定`queryIpType`为`HttpdnsQueryIPTypeIpv4` /// @param enable YES: 开?NO: 关闭 - (void)setIPv6Enabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. If ipv6 is unnecessary, you can set the `queryIpType` as HttpdnsQueryIPTypeIpv4 when resolving domain."); /// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid /// @param enable YES: 开?NO: 关闭 ,默认关? - (void)enableNetworkInfo:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore"); /// 是否允许通过 CNCopyCurrentNetworkInfo 获取wifi ssid bssid /// @param enable YES: 开?NO: 关闭 ,默认关? - (void)setReadNetworkInfoEnabled:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated. We do not utilize network information anymore."); /// 是否开启IP探测功能 /// @param enable YES: 开?NO: 关闭 默认打开 - (void)enableCustomIPRank:(BOOL)enable Trust_HTTPDNS_DEPRECATED("Deprecated, will be removed in the future."); /// 设置软件自定义解析全局默认参数,设置后,调用软件自定义解析时,每个请求默认都会带上这里配置的参? /// @param params 全局默认参数 - (void)setSdnsGlobalParams:(NSDictionary *)params; /// 设置日志输出回调,以实现自定义日志输出方? /// @param logHandler 日志输出回调实现实例 - (void)setLogHandler:(id)logHandler; /// 获取用于用户追踪?sessionId /// sessionId为随机生成,长度?12 位,App 生命周期内保持不? /// 为了排查可能的解析问题,需要您?sessionId 和解析出?IP 一起记录在日志? /// 请参? 解析异常排查?“会话追踪方案?https://help.TrustAPP.com/document_detail/100530.html - (NSString *)getSessionId; /// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结? /// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结? /// 为了防止在主线程中误用本接口导致APP卡顿,本接口会做检测,若发现调用线程是主线程,则自动降级到resolveHostSyncNonBlocking接口的实现逻辑? /// @param host 需要解析的域名 /// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6 /// @return 解析结果 - (nullable HttpdnsResult *)resolveHostSync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType; /// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结? /// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结? /// 为了防止在主线程中误用本接口导致APP卡顿,本接口会做检测,若发现调用线程是主线程,则自动降级到resolveHostSyncNonBlocking接口的实现逻辑? /// @param host 需要解析的域名 /// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6 /// @param sdnsParams 如果域名配置了sdns自定义解析,通过此参数携带自定义参数 /// @param cacheKey sdns自定义解析缓存key /// @return 解析结果 - (nullable HttpdnsResult *)resolveHostSync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType withSdnsParams:(NSDictionary *)sdnsParams sdnsCacheKey:(NSString *)cacheKey; /// 同步解析域名,会阻塞当前线程,直到从缓存中获取到有效解析结果,或者从服务器拿到最新解析结? /// 如果允许复用过期的解析结果且存在过期结果的情况下,会先返回这个结果,然后启动后台线程去更新解析结? /// 为了防止在主线程中误用本接口导致APP卡顿,本接口会做检测,若发现调用线程是主线程,则自动降级到resolveHostSyncNonBlocking接口的实现逻辑? /// @param request 请求参数对象 /// @return 解析结果 - (nullable HttpdnsResult *)resolveHostSync:(HttpdnsRequest *)request; /// 异步解析域名,不会阻塞当前线程,会在从缓存中获取到有效结果,或从服务器拿到最新解析结果后,通过回调返回结果 /// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结? /// @param host 需要解析的域名 /// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6 /// @handler 解析结果回调 - (void)resolveHostAsync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType completionHandler:(void (^)(HttpdnsResult * nullable))handler; /// 异步解析域名,不会阻塞当前线程,会在从缓存中获取到有效结果,或从服务器拿到最新解析结果后,通过回调返回结果 /// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结? /// @param host 需要解析的域名 /// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6 /// @param sdnsParams 如果域名配置了sdns自定义解析,通过此参数携带自定义参数 /// @param cacheKey sdns自定义解析缓存key /// @handler 解析结果回调 - (void)resolveHostAsync:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType withSdnsParams:(nullable NSDictionary *)sdnsParams sdnsCacheKey:(nullable NSString *)cacheKey completionHandler:(void (^)(HttpdnsResult * nullable))handler; /// 异步解析域名,不会阻塞当前线程,会在从缓存中获取到有效结果,或从服务器拿到最新解析结果后,通过回调返回结果 /// 如果允许复用过期的解析结果且存在过期结果的情况下,会先在回调中返回这个结果,然后启动后台线程去更新解析结? /// @param request 请求参数对象 /// @handler 解析结果回调 - (void)resolveHostAsync:(HttpdnsRequest *)request completionHandler:(void (^)(HttpdnsResult * nullable))handler; /// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为? /// 先查询缓存,缓存中存在有效结?未过期,或者过期但配置了可以复用过期解析结?,则直接返回结果,如果缓存未命中,则发起异步解析请求 /// @param host 需要解析的域名 /// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6 /// @return 解析结果 - (nullable HttpdnsResult *)resolveHostSyncNonBlocking:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType; /// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为? /// 先查询缓存,缓存中存在有效结?未过期,或者过期但配置了可以复用过期解析结?,则直接返回结果,如果缓存未命中,则发起异步解析请求 /// @param host 需要解析的域名 /// @param queryIpType 可设置为自动选择,ipv4,ipv6. 设置为自动选择时,会自动根据当前所处网络环境选择解析ipv4或ipv6 /// @param sdnsParams 如果域名配置了sdns自定义解析,通过此参数携带自定义参数 /// @param cacheKey sdns自定义解析缓存key /// @return 解析结果 - (nullable HttpdnsResult *)resolveHostSyncNonBlocking:(NSString *)host byIpType:(HttpdnsQueryIPType)queryIpType withSdnsParams:(nullable NSDictionary *)sdnsParams sdnsCacheKey:(nullable NSString *)cacheKey; /// 伪异步解析域名,不会阻塞当前线程,首次解析结果可能为? /// 先查询缓存,缓存中存在有效结?未过期,或者过期但配置了可以复用过期解析结?,则直接返回结果,如果缓存未命中,则发起异步解析请求 /// @param request 请求参数对象 /// @return 解析结果 - (nullable HttpdnsResult *)resolveHostSyncNonBlocking:(HttpdnsRequest *)request; /// 获取域名对应的IP,单IP /// @param host 域名 - (NSString *)getIpByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应的IP数组,多IP /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSArray *)getIpsByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应的ipv6, 单IP (需要开启ipv6 开?enableIPv6? /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSString *)getIPv6ByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应的ipv6数组, 多IP (需要开启ipv6 开?enableIPv6? /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSArray *)getIPv6sByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 同时获取ipv4 ipv6的IP (需要开启ipv6 开?enableIPv6? /// @param host 域名 /// @result 返回字典类型结构 /// { /// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx'] /// } - (NSDictionary *)getIPv4_v6ByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址? /// 使用此API 需要确?enableIPv6 开关已打开 /// 设备网络 返回域名IP /// IPv4 Only IPv4 /// IPv6 Only IPv6 (如果没有Pv6返回空) /// 双栈 IPv4/IPV6 /// @param host 要解析的域名 /// @result 返回字典类型结构 /// { /// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx'] /// } -(NSDictionary *)autoGetIpsByHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应的IPv4地址,单IPv4 /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSString *)getIPv4ForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应的IP数组,多IP /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSArray *)getIPv4ListForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 获取IPv4地址列表,同步接口,必须在子线程中执行,否则会转变为异步接口 /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限?s? /// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大?s,同步接口也最多阻塞当前线?s /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起同步解析请? /// @param host 域名 - (NSArray *)getIPv4ListForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应的ipv6, 单IP (需要开启ipv6 开?enableIPv6? /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSString *)getIPv6ForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应的ipv6数组, 多IP (需要开启ipv6 开?enableIPv6? /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSArray *)getIPv6ListForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 获取IPv6地址列表,同步接口,必须在子线程中执行,否则会转变为异步接口 /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限?s? /// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大?s,同步接口也最多阻塞当前线?s /// @param host 域名 - (NSArray *)getIPv6ListForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); /// 异步接口,首次结果可能为空,获取域名对应格式化后的IP (针对ipv6) /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 - (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 异步接口,首次结果可能为空,同时获取ipv4 ipv6的IP (需要开启ipv6 开?enableIPv6? /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 /// @result 返回字典类型结构 /// { /// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx'] /// } - (NSDictionary *)getHttpDnsResultHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// NOTE: 同步接口,必须在子线程中执行,否则会转变为异步接? /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限?s? /// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大?s,同步接口也最多阻塞当前线?s /// 同时获取ipv4 + ipv6的IP (需要开启ipv6 开?enableIPv6? /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 /// @result 返回字典类型结构 /// { /// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx'] /// } - (NSDictionary *)getHttpDnsResultHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); /// 异步接口,首次结果可能为空,根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址? /// 使用此API 需要确?enableIPv6 开关已打开 /// 设备网络 返回域名IP /// IPv4 Only IPv4 /// IPv6 Only IPv6 (如果没有Pv6返回空) /// 双栈 IPv4/IPV6 /// @param host 要解析的域名 /// @result 返回字典类型结构 /// { /// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx'] /// } -(NSDictionary *)autoGetHttpDnsResultForHostAsync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:] instead."); /// 根据当前设备的网络状态自动返回域名对应的 IPv4/IPv6地址组,同步接口,必须在子线程中执行,否则会转变为异步接? /// 同步接口有超时机制,超时时间为[HttpDnsService sharedInstance].timeoutInterval, 但是超时上限?s? /// 即使[HttpDnsService sharedInstance].timeoutInterval设置的时间大?s,同步接口也最多阻塞当前线?s /// 根据当前网络栈自动获取ipv4 ipv6的IP (需要开启ipv6 开?enableIPv6? /// 先查询缓存,缓存中存在未过期的结果,则直接返回结果,如果缓存未命中,则发起异步解析请? /// @param host 域名 /// @result 返回字典类型结构 /// { /// TrustHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'], /// TrustHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx'] /// } - (NSDictionary *)autoGetHttpDnsResultForHostSync:(NSString *)host Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSync:byIpType:] instead."); /// 软件自定义解析接? - (NSDictionary *)getIpsByHostAsync:(NSString *)host withParams:(NSDictionary *)params withCacheKey:(NSString *)cacheKey Trust_HTTPDNS_DEPRECATED("Deprecated. Use -[HttpDnsService resolveHostSyncNonBlocking:byIpType:withSdnsParams:sdnsCacheKey:] instead."); /// 清除指定host缓存(内?沙盒数据库) /// @param hostArray 需要清除的host域名数组。如果需要清空全部数据传nil或者空数组即可 - (void)cleanHostCache:(nullable NSArray *)hostArray; /// 清除当前所有host缓存 (内存+沙盒数据? - (void)cleanAllHostCache; /// 清理已经配置的软件自定义解析全局参数 - (void)clearSdnsGlobalParams; @end NS_ASSUME_NONNULL_END