feat: sync httpdns sdk/platform updates without large binaries
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// HttpdnsIPQualityDetector.h
|
||||
// TrustHttpDNS
|
||||
//
|
||||
// Created by xuyecan on 2025/3/13.
|
||||
// Copyright © 2025 trustapp.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* IP质量检测回<E6B58B><E59B9E>?
|
||||
* @param cacheKey 缓存<E7BC93><E5AD98>?
|
||||
* @param ip IP地址
|
||||
* @param costTime 连接耗时(毫秒)<E7A792><EFBC89>?1表示连接失败
|
||||
*/
|
||||
typedef void(^HttpdnsIPQualityCallback)(NSString *cacheKey, NSString *ip, NSInteger costTime);
|
||||
|
||||
@interface HttpdnsIPQualityDetector : NSObject
|
||||
|
||||
/**
|
||||
* 单例方法
|
||||
*/
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
/**
|
||||
* 获取当前等待队列中的任务数量
|
||||
*/
|
||||
- (NSUInteger)pendingTasksCount;
|
||||
|
||||
/**
|
||||
* 调度一个IP连接质量检测任务,不会阻塞当前线程
|
||||
* @param cacheKey 缓存键,通常是域<E698AF><E59F9F>?
|
||||
* @param ip 要检测的IP地址
|
||||
* @param port 连接端口,如果为nil则默认使<E8AEA4><E4BDBF>?0
|
||||
* @param callback 检测完成后的回<E79A84><E59B9E>?
|
||||
*/
|
||||
- (void)scheduleIPQualityDetection:(NSString *)cacheKey
|
||||
ip:(NSString *)ip
|
||||
port:(nullable NSNumber *)port
|
||||
callback:(HttpdnsIPQualityCallback)callback;
|
||||
|
||||
#pragma mark - Methods exposed for testing
|
||||
|
||||
/**
|
||||
* 执行IP连接质量检<E9878F><E6A380>?
|
||||
* @param cacheKey 缓存键,通常是域<E698AF><E59F9F>?
|
||||
* @param ip 要检测的IP地址
|
||||
* @param port 连接端口,如果为nil则默认使<E8AEA4><E4BDBF>?0
|
||||
* @param callback 检测完成后的回<E79A84><E59B9E>?
|
||||
* @note 此方法主要用于测<E4BA8E><E6B58B>?
|
||||
*/
|
||||
- (void)executeDetection:(NSString *)cacheKey
|
||||
ip:(NSString *)ip
|
||||
port:(nullable NSNumber *)port
|
||||
callback:(HttpdnsIPQualityCallback)callback;
|
||||
|
||||
/**
|
||||
* 建立TCP连接并测量连接时<E68EA5><E697B6>?
|
||||
* @param ip 要连接的IP地址
|
||||
* @param port 连接端口
|
||||
* @return 连接耗时(毫秒)<E7A792><EFBC89>?1表示连接失败
|
||||
* @note 此方法主要用于测<E4BA8E><E6B58B>?
|
||||
*/
|
||||
- (NSInteger)tcpConnectToIP:(NSString *)ip port:(int)port;
|
||||
|
||||
/**
|
||||
* 添加待处理任<E79086><E4BBBB>?
|
||||
* @param cacheKey 缓存键,通常是域<E698AF><E59F9F>?
|
||||
* @param ip 要检测的IP地址
|
||||
* @param port 连接端口
|
||||
* @param callback 检测完成后的回<E79A84><E59B9E>?
|
||||
* @note 此方法主要用于测<E4BA8E><E6B58B>?
|
||||
*/
|
||||
- (void)addPendingTask:(NSString *)cacheKey
|
||||
ip:(NSString *)ip
|
||||
port:(nullable NSNumber *)port
|
||||
callback:(HttpdnsIPQualityCallback)callback;
|
||||
|
||||
/**
|
||||
* 处理待处理任务队<E58AA1><E9989F>?
|
||||
* @note 此方法主要用于测<E4BA8E><E6B58B>?
|
||||
*/
|
||||
- (void)processPendingTasksIfNeeded;
|
||||
|
||||
/**
|
||||
* 处理所有待处理任务
|
||||
* @note 此方法主要用于测<E4BA8E><E6B58B>?
|
||||
*/
|
||||
- (void)processPendingTasks;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in New Issue
Block a user