带阿里标识的版本

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

@@ -13,7 +13,7 @@
@class HttpdnsNWHTTPClient;
// /
// <EFBFBD><EFBFBD>?<EFBFBD><EFBFBD>?
@interface HttpdnsNWHTTPExchange : NSObject
@property (nonatomic, strong, readonly) NSMutableData *buffer;
@@ -99,7 +99,7 @@
_host = [host copy];
_port = [port copy];
_useTLS = useTLS;
_queue = dispatch_queue_create("com.alibaba.sdk.httpdns.network.connection.reuse", DISPATCH_QUEUE_SERIAL);
_queue = dispatch_queue_create("com.Trust.sdk.httpdns.network.connection.reuse", DISPATCH_QUEUE_SERIAL);
_stateSemaphore = dispatch_semaphore_create(0);
_state = nw_connection_state_invalid;
_lastUsedDate = [NSDate date];
@@ -135,14 +135,14 @@
if (secTrust && strongSelf) {
SecTrustRef trustRef = sec_trust_copy_ref(secTrust);
if (trustRef) {
NSString *validIP = ALICLOUD_HTTPDNS_VALID_SERVER_CERTIFICATE_IP;
NSString *validIP = Trust_HTTPDNS_VALID_SERVER_CERTIFICATE_IP;
isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:validIP];
if (!isValid && [HttpdnsUtil isNotEmptyString:strongSelf.host]) {
isValid = [strongSelf.client evaluateServerTrust:trustRef forDomain:strongSelf.host];
}
if (!isValid && !strongSelf.stateError) {
strongSelf.stateError = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
strongSelf.stateError = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"TLS trust validation failed"}];
}
CFRelease(trustRef);
@@ -220,8 +220,8 @@
- (BOOL)openWithTimeout:(NSTimeInterval)timeout error:(NSError **)error {
if (self.invalidated) {
if (error) {
*error = _stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection invalid"}];
}
return NO;
@@ -237,8 +237,8 @@
if (waitResult != 0) {
self.invalidated = YES;
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection setup timed out"}];
}
nw_connection_cancel(_connectionHandle);
@@ -250,8 +250,8 @@
}
if (error) {
*error = _stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection failed to become ready"}];
}
return NO;
@@ -277,8 +277,8 @@
error:(NSError **)error {
if (!requestData || requestData.length == 0) {
if (error) {
*error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Empty HTTP request"}];
}
return nil;
@@ -286,8 +286,8 @@
if (![self isViable] || self.currentExchange) {
if (error) {
*error = _stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
*error = _stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection not ready"}];
}
return nil;
@@ -299,16 +299,16 @@
dispatch_sync(_queue, ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection released unexpectedly"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
return;
}
if (strongSelf.invalidated || strongSelf.currentExchange) {
exchange.error = strongSelf.stateError ?: [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = strongSelf.stateError ?: [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection is busy"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
@@ -320,8 +320,8 @@
if (exchange.finished) {
return;
}
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Request timed out"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
@@ -366,8 +366,8 @@
if (waitResult != 0) {
if (!exchange.error) {
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Request wait timed out"}];
}
[self invalidate];
@@ -428,8 +428,8 @@
if (is_complete) {
exchange.remoteClosed = YES;
if (!exchange.finished) {
exchange.error = [NSError errorWithDomain:ALICLOUD_HTTPDNS_ERROR_DOMAIN
code:ALICLOUD_HTTPDNS_HTTPS_COMMON_ERROR_CODE
exchange.error = [NSError errorWithDomain:Trust_HTTPDNS_ERROR_DOMAIN
code:Trust_HTTPDNS_HTTPS_COMMON_ERROR_CODE
userInfo:@{NSLocalizedDescriptionKey: @"Connection closed before response completed"}];
exchange.finished = YES;
dispatch_semaphore_signal(exchange.semaphore);
@@ -452,7 +452,7 @@
}
if (isComplete) {
//
// <EFBFBD><EFBFBD>?
exchange.remoteClosed = YES;
}
@@ -527,7 +527,7 @@
@end
#if DEBUG
//
// <EFBFBD><EFBFBD>?
@implementation HttpdnsNWReusableConnection (DebugInspection)
- (void)debugSetLastUsedDate:(nullable NSDate *)date {