Skip to content

Commit

Permalink
optimize dns resolver timeout desc
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSen-qn committed Aug 25, 2021
1 parent 65b20a0 commit e0f0007
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion HappyDNS/Dns/QNDnsResolver.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ - (void)request:(NSString *)host
[locker unlock];

if (shouldCallBack) {
complete(nil, kQNDnsInvalidParamError(@"resolver timeout"));
NSString *error = [NSString stringWithFormat:@"resolver timeout for server:%@ host:%@",[self.servers description], host];
complete(nil, kQNDnsInvalidParamError(error));
}
});

Expand Down
5 changes: 3 additions & 2 deletions HappyDNSTests/DohResolverTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ @implementation DohResolverTest

- (void)testSimpleDns {
NSString *host = @"en.wikipedia.org";
NSString *serverUrl = @"https://223.6.6.6/dns-query";
NSError *err = nil;

NSArray *typeArray = @[@(kQNTypeA), @(kQNTypeAAAA)];
for (NSNumber *type in typeArray) {
QNDohResolver *server = [QNDohResolver resolverWithServer:@"https://dns.alidns.com/dns-query" recordType:type.intValue timeout:5];
QNDohResolver *server = [QNDohResolver resolverWithServer:serverUrl recordType:type.intValue timeout:2];
NSArray *records = [server query:[[QNDomain alloc] init:host] networkInfo:nil error:&err];
NSLog(@"== records:%@", records);
XCTAssertNil(err, "query error:%@", err);
Expand All @@ -31,7 +32,7 @@ - (void)testSimpleDns {
}

for (NSNumber *type in typeArray) {
QNDohResolver *server = [QNDohResolver resolverWithServers:@[@"https://dns.alidns.com/dns-query"] recordType:type.intValue timeout:5];
QNDohResolver *server = [QNDohResolver resolverWithServers:@[serverUrl] recordType:type.intValue timeout:5];
QNDnsManager *manager = [[QNDnsManager alloc] init:@[server] networkInfo:nil];
NSArray *records = [manager queryRecords:host];
NSLog(@"== records:%@", records);
Expand Down

0 comments on commit e0f0007

Please sign in to comment.