带阿里标识的版本

This commit is contained in:
robin
2026-02-28 18:55:33 +08:00
parent 150799f41d
commit 5d0b7c7e91
477 changed files with 10813 additions and 4044 deletions

View File

@@ -71,8 +71,8 @@ typedef struct {
+ (void)initialize {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_persistentCacheConcurrentQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.persistentCacheOperationQueue", DISPATCH_QUEUE_CONCURRENT);
_asyncResolveHostQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.asyncResolveHostQueue", DISPATCH_QUEUE_CONCURRENT);
_persistentCacheConcurrentQueue = dispatch_queue_create("com.Trust.sdk.httpdns.persistentCacheOperationQueue", DISPATCH_QUEUE_CONCURRENT);
_asyncResolveHostQueue = dispatch_queue_create("com.Trust.sdk.httpdns.asyncResolveHostQueue", DISPATCH_QUEUE_CONCURRENT);
});
}
@@ -113,7 +113,7 @@ typedef struct {
//
[self->_httpdnsDB cleanRecordAlreadExpiredAt:[[NSDate date] timeIntervalSince1970] - duration];
//
// <EFBFBD><EFBFBD>?
[self loadCacheFromDbToMemory];
});
}
@@ -139,7 +139,7 @@ typedef struct {
return;
}
// 5
// <EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?
NSUInteger totalCount = hosts.count;
for (NSUInteger i = 0; i < totalCount; i += HTTPDNS_PRE_RESOLVE_BATCH_SIZE) {
NSUInteger length = MIN(HTTPDNS_PRE_RESOLVE_BATCH_SIZE, totalCount - i);
@@ -190,21 +190,21 @@ typedef struct {
if (isCachedResultUsable) {
if (isResolvingRequired) {
//
//
// <EFBFBD><EFBFBD>?
[self determineResolvingHostNonBlocking:request];
}
// cacheKeyhost
result.hostName = host;
HttpdnsLogDebug("Reuse available cache for cacheKey: %@, result: %@", cacheKey, result);
//
// <EFBFBD><EFBFBD>?
return result;
}
if (request.isBlockingRequest) {
//
// <EFBFBD><EFBFBD>?
return [self determineResolveHostBlocking:request];
} else {
//
// <EFBFBD><EFBFBD>?
[self determineResolvingHostNonBlocking:request];
return nil;
}
@@ -264,14 +264,14 @@ typedef struct {
if ([hostObject isExpiredUnderQueryIpType:queryType]) {
if (self.atomicExpiredIPEnabled || [hostObject isLoadFromDB]) {
//
// <EFBFBD><EFBFBD>?
HttpdnsLogDebug("The ips is expired, but we accept it, host: %@, queryType: %ld, expiredIpEnabled: %d, isLoadFromDB: %d",
hostObject.hostName, queryType, self.atomicExpiredIPEnabled, [hostObject isLoadFromDB]);
//
// <EFBFBD><EFBFBD>?
return (HostObjectExamingResult){YES, YES};
}
//
// <EFBFBD><EFBFBD>?
return (HostObjectExamingResult){NO, YES};
}
@@ -310,7 +310,7 @@ typedef struct {
return nil;
}
// host
// host<EFBFBD><EFBFBD>?
result = resultArray.firstObject;
} else {
if (!self.degradeToLocalDNSEnabled) {
@@ -332,7 +332,7 @@ typedef struct {
// merge
HttpdnsHostObject *lookupResult = [self mergeLookupResultToManager:result host:host cacheKey:cacheKey underQueryIpType:queryIPType];
//
// <EFBFBD><EFBFBD>?
return [lookupResult copy];
}
@@ -483,7 +483,7 @@ typedef struct {
HttpdnsNetworkStatus currentStatus = [[HttpdnsReachability sharedInstance] currentReachabilityStatus];
NSString *currentStatusString = [[HttpdnsReachability sharedInstance] currentReachabilityString];
//
// <EFBFBD><EFBFBD>?
// 1
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
[[HttpdnsIpStackDetector sharedInstance] redetectIpStack];
@@ -493,23 +493,23 @@ typedef struct {
BOOL statusChanged = (_lastNetworkStatus != currentStatus);
// :
// -
// -
// - <EFBFBD><EFBFBD>?
// - <EFBFBD><EFBFBD>?
NSTimeInterval elapsedTime = currentTimestamp - _lastUpdateTimestamp;
if (elapsedTime >= 5 || (statusChanged && elapsedTime >= 1)) {
HttpdnsLogDebug("Processing network change: oldStatus: %ld, newStatus: %ld(%@), elapsedTime=%.2f seconds",
_lastNetworkStatus, currentStatus, currentStatusString, elapsedTime);
//
// 2
// 2<EFBFBD><EFBFBD>?
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
HttpdnsScheduleCenter *scheduleCenter = self.ownerService.scheduleCenter;
[scheduleCenter asyncUpdateRegionScheduleConfig];
});
//
// cacheKey hostName
// SDNS 使 cacheKey
// cacheKey hostName<EFBFBD><EFBFBD>?
// SDNS 使 cacheKey <EFBFBD><EFBFBD>?
NSArray *allKeys = [_hostObjectInMemoryCache allCacheKeys];
NSMutableArray<NSString *> *hostArray = [NSMutableArray array];
for (NSString *key in allKeys) {
@@ -524,10 +524,10 @@ typedef struct {
}
}
//
// 3
// <EFBFBD><EFBFBD>?
// 3<EFBFBD><EFBFBD>?
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
// hostName SDNS cacheKey
// hostName <EFBFBD><EFBFBD>?SDNS cacheKey <EFBFBD><EFBFBD>?
for (NSString *host in hostArray) {
[self->_hostObjectInMemoryCache removeHostObjectByCacheKey:host];
}
@@ -538,7 +538,7 @@ typedef struct {
}
});
//
// <EFBFBD><EFBFBD>?
_lastNetworkStatus = currentStatus;
_lastUpdateTimestamp = currentTimestamp;
} else {
@@ -552,7 +552,7 @@ typedef struct {
- (dispatch_queue_t)cacheQueue {
if (!_cacheQueue) {
_cacheQueue = dispatch_queue_create("com.alibaba.sdk.httpdns.cacheDisableStatusQueue", DISPATCH_QUEUE_SERIAL);
_cacheQueue = dispatch_queue_create("com.Trust.sdk.httpdns.cacheDisableStatusQueue", DISPATCH_QUEUE_SERIAL);
}
return _cacheQueue;
}
@@ -573,7 +573,7 @@ typedef struct {
HttpdnsHostObject *hostObject = [HttpdnsHostObject fromDBRecord:hostRecord];
// App使
// App使<EFBFBD><EFBFBD>?
[hostObject setIsLoadFromDB:YES];
[self->_hostObjectInMemoryCache setHostObject:hostObject forCacheKey:cacheKey];
@@ -596,7 +596,7 @@ typedef struct {
}
}
//
// <EFBFBD><EFBFBD>?
dispatch_async(_persistentCacheConcurrentQueue, ^{
[self->_httpdnsDB deleteByHostNameArr:hostArray];
});
@@ -605,7 +605,7 @@ typedef struct {
- (void)cleanMemoryAndPersistentCacheOfAllHosts {
[_hostObjectInMemoryCache removeAllHostObjects];
//
// <EFBFBD><EFBFBD>?
dispatch_async(_persistentCacheConcurrentQueue, ^{
[self->_httpdnsDB deleteAll];
});
@@ -622,7 +622,7 @@ typedef struct {
}
#pragma mark -
#pragma mark -
#pragma mark - <EFBFBD><EFBFBD>?
- (NSString *)showMemoryCache {
NSString *cacheDes;