Overview
| Comment: | Throw an exception when there is no name server |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
f3573582e1e8154616da507766fc897f |
| User & Date: | js on 2020-06-21 17:53:21 |
| Other Links: | manifest | tags |
Context
|
2020-06-21
| ||
| 21:30 | Move parameters for of_pbkdf2() to a struct (check-in: b9641347e3 user: js tags: trunk) | |
| 17:53 | Throw an exception when there is no name server (check-in: f3573582e1 user: js tags: trunk) | |
| 15:57 | Ignore return value from _Unwind_RaiseException() (check-in: 0d383aeb8a user: js tags: trunk) | |
Changes
Modified src/OFDNSResolver.h from [074bf54ace] to [f593d54e00].
| ︙ | ︙ | |||
61 62 63 64 65 66 67 | /*! The server was unable to process due to an internal error */ OF_DNS_RESOLVER_ERROR_SERVER_FAILURE, /*! The server returned an error that the domain does not exist */ OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR, /*! The server does not have support for the requested query */ OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED, /*! The server refused the query */ | | > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /*! The server was unable to process due to an internal error */ OF_DNS_RESOLVER_ERROR_SERVER_FAILURE, /*! The server returned an error that the domain does not exist */ OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR, /*! The server does not have support for the requested query */ OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED, /*! The server refused the query */ OF_DNS_RESOLVER_ERROR_SERVER_REFUSED, /*! There was no name server to query */ OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER } of_dns_resolver_error_t; /*! * @protocol OFDNSResolverQueryDelegate OFDNSResolver.h ObjFW/OFDNSResolver.h * * @brief A delegate for performed DNS queries. */ |
| ︙ | ︙ |
Modified src/OFDNSResolver.m from [5d30f91158] to [e0d24431d9].
| ︙ | ︙ | |||
814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
/* Random, unused ID */
do {
ID = [OFNumber numberWithUInt16: (uint16_t)of_random()];
} while ([_queries objectForKey: ID] != nil);
if (query.domainName.UTF8StringLength > 253)
@throw [OFOutOfRangeException exception];
context = [[[OFDNSResolverContext alloc]
initWithQuery: query
ID: ID
settings: _settings
delegate: delegate] autorelease];
[self of_sendQueryForContext: context
| > > > > > > > > > > > | 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
/* Random, unused ID */
do {
ID = [OFNumber numberWithUInt16: (uint16_t)of_random()];
} while ([_queries objectForKey: ID] != nil);
if (query.domainName.UTF8StringLength > 253)
@throw [OFOutOfRangeException exception];
if (_settings->_nameServers.count == 0) {
id exception = [OFDNSQueryFailedException
exceptionWithQuery: query
error: OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER];
[delegate resolver: self
didPerformQuery: query
response: nil
exception: exception];
return;
}
context = [[[OFDNSResolverContext alloc]
initWithQuery: query
ID: ID
settings: _settings
delegate: delegate] autorelease];
[self of_sendQueryForContext: context
|
| ︙ | ︙ | |||
876 877 878 879 880 881 882 | length: BUFFER_LENGTH]; #endif exception = [OFDNSQueryFailedException exceptionWithQuery: context->_query error: OF_DNS_RESOLVER_ERROR_TIMEOUT]; | < < | | | | | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 |
length: BUFFER_LENGTH];
#endif
exception = [OFDNSQueryFailedException
exceptionWithQuery: context->_query
error: OF_DNS_RESOLVER_ERROR_TIMEOUT];
[context->_delegate resolver: self
didPerformQuery: context->_query
response: nil
exception: exception];
}
- (bool)of_handleResponseBuffer: (unsigned char *)buffer
length: (size_t)length
sender: (const of_socket_address_t *)sender
{
OFDictionary *answerRecords = nil, *authorityRecords = nil;
|
| ︙ | ︙ | |||
1037 1038 1039 1040 1041 1042 1043 |
} @catch (id e) {
exception = e;
}
if (exception != nil)
response = nil;
| < < | | | | | 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
} @catch (id e) {
exception = e;
}
if (exception != nil)
response = nil;
[context->_delegate resolver: self
didPerformQuery: context->_query
response: response
exception: exception];
return false;
}
- (bool)socket: (OFDatagramSocket *)sock
didReceiveIntoBuffer: (void *)buffer
length: (size_t)length
|
| ︙ | ︙ | |||
1271 1272 1273 1274 1275 1276 1277 |
while ((context = [enumerator nextObject]) != nil) {
OFDNSQueryFailedException *exception;
exception = [OFDNSQueryFailedException
exceptionWithQuery: context->_query
error: OF_DNS_RESOLVER_ERROR_CANCELED];
| < < | | | | | 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
while ((context = [enumerator nextObject]) != nil) {
OFDNSQueryFailedException *exception;
exception = [OFDNSQueryFailedException
exceptionWithQuery: context->_query
error: OF_DNS_RESOLVER_ERROR_CANCELED];
[context->_delegate resolver: self
didPerformQuery: context->_query
response: nil
exception: exception];
}
[_queries removeAllObjects];
objc_autoreleasePoolPop(pool);
}
@end
|
Modified src/exceptions/OFDNSQueryFailedException.m from [0c0fa9832e] to [1f9661bb22].
| ︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | return @"The server returned an error that the domain does not " @"exist."; case OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED: return @"The server does not have support for the requested " @"query."; case OF_DNS_RESOLVER_ERROR_SERVER_REFUSED: return @"The server refused the query."; default: return @"Unknown error."; } } @implementation OFDNSQueryFailedException @synthesize query = _query, error = _error; | > > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | return @"The server returned an error that the domain does not " @"exist."; case OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED: return @"The server does not have support for the requested " @"query."; case OF_DNS_RESOLVER_ERROR_SERVER_REFUSED: return @"The server refused the query."; case OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER: return @"There was no name server to query."; default: return @"Unknown error."; } } @implementation OFDNSQueryFailedException @synthesize query = _query, error = _error; |
| ︙ | ︙ |