ObjFW  Check-in [457f722d18]

Overview
Comment:OFDNSResolver: Pass the FQDN to the callback
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 457f722d182b3427c6816a0608c96132c270001a2c5db0fd65b41c0f20cb6e35
User & Date: js on 2018-08-12 22:21:17
Other Links: manifest | tags
Context
2018-08-13
00:00
OFDNSResolver: Periodic config reload check-in: 507d999b53 user: js tags: trunk
2018-08-12
22:21
OFDNSResolver: Pass the FQDN to the callback check-in: 457f722d18 user: js tags: trunk
12:37
OFDNSResolver: Parse authority and additional RRs check-in: 6305a0c7a4 user: js tags: trunk
Changes

Modified src/OFDNSResolver.h from [015a85d33b] to [4f664e02c6].

128
129
130
131
132
133
134
135
136
137
138
139












140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

155







156







157
158
159
160
161
162
163

/*!
 * @brief Asynchronously resolves the specified host.
 *
 * @param host The host to resolve
 * @param target The target to call with the result once resolving is done
 * @param selector The selector to call on the target. The signature must be
 *		   `void (OFDNSResolver *resolver,
 *		   nullable OFArray<OFDNSResourceRecord *> *answerRecords,
 *		   nullable OFArray<OFDNSResourceRecord *> *authorityRecords,
 *		   nullable OFArray<OFDNSResourceRecord *> *additionalRecords,
 *		   nullable id context, nullable id exception)`.












 * @param context A context object to pass along to the target
 */
- (void)asyncResolveHost: (OFString *)host
		  target: (id)target
		selector: (SEL)selector
		 context: (nullable id)context;

/*!
 * @brief Asynchronously resolves the specified host.
 *
 * @param host The host to resolve
 * @param recordClass The desired class of the records to query
 * @param recordType The desired type of the records to query
 * @param target The target to call with the result once resolving is done
 * @param selector The selector to call on the target. The signature must be

 *		   `void (OFArray<OFDNSResourceRecord *> *response, id context,







 *		   id exception)`.







 * @param context A context object to pass along to the target
 */
- (void)asyncResolveHost: (OFString *)host
	     recordClass: (of_dns_resource_record_class_t)recordClass
	      recordType: (of_dns_resource_record_type_t)recordType
		  target: (id)target
		selector: (SEL)selector







|



|
>
>
>
>
>
>
>
>
>
>
>
>















>
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190

/*!
 * @brief Asynchronously resolves the specified host.
 *
 * @param host The host to resolve
 * @param target The target to call with the result once resolving is done
 * @param selector The selector to call on the target. The signature must be
 *		   `void (OFDNSResolver *resolver, OFString *domainName,
 *		   nullable OFArray<OFDNSResourceRecord *> *answerRecords,
 *		   nullable OFArray<OFDNSResourceRecord *> *authorityRecords,
 *		   nullable OFArray<OFDNSResourceRecord *> *additionalRecords,
 *		   nullable id context, nullable id exception)`.@n
 *		   `resolver` is the acting resolver.@n
 *		   `domainName` is the fully qualified domain name used to
 *		   resolve the host.@n
 *		   `answerRecords` are the answer records from the name server.
 *		   @n
 *		   `authorityRecords` are the authority records from the name
 *		   server.@n
 *		   `additionalRecords` are additional records sent by the name
 *		   server.
 *		   `context` is the context object originally passed.@n
 *		   `exception` is an exception that happened during resolving,
 *		   otherwise nil.
 * @param context A context object to pass along to the target
 */
- (void)asyncResolveHost: (OFString *)host
		  target: (id)target
		selector: (SEL)selector
		 context: (nullable id)context;

/*!
 * @brief Asynchronously resolves the specified host.
 *
 * @param host The host to resolve
 * @param recordClass The desired class of the records to query
 * @param recordType The desired type of the records to query
 * @param target The target to call with the result once resolving is done
 * @param selector The selector to call on the target. The signature must be
 *		   `void (OFDNSResolver *resolver, OFString *domainName,
 *		   nullable OFArray<OFDNSResourceRecord *> *answerRecords,
 *		   nullable OFArray<OFDNSResourceRecord *> *authorityRecords,
 *		   nullable OFArray<OFDNSResourceRecord *> *additionalRecords,
 *		   nullable id context, nullable id exception)`.@n
 *		   `resolver` is the acting resolver.@n
 *		   `domainName` is the fully qualified domain name used to
 *		   resolve the host.@n
 *		   `answerRecords` are the answer records from the name server.
 *		   @n
 *		   `authorityRecords` are the authority records from the name
 *		   server.@n
 *		   `additionalRecords` are additional records sent by the name
 *		   server.
 *		   `context` is the context object originally passed.@n
 *		   `exception` is an exception that happened during resolving,
 *		   otherwise nil.
 * @param context A context object to pass along to the target
 */
- (void)asyncResolveHost: (OFString *)host
	     recordClass: (of_dns_resource_record_class_t)recordClass
	      recordType: (of_dns_resource_record_type_t)recordType
		  target: (id)target
		selector: (SEL)selector

Modified src/OFDNSResolver.m from [3362d8ffb1] to [ec8c7e0a0c].

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
 *
 *  - Resolve with each search domain
 *  - Fallback to TCP
 */

@interface OFDNSResolverQuery: OFObject
{
	OFString *_host;
	of_dns_resource_record_class_t _recordClass;
	of_dns_resource_record_type_t _recordType;
	OFNumber *_ID;
	OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains;
	size_t _nameServersIndex, _searchDomainsIndex;
	size_t _attempt;
	id _target;
	SEL _selector;
	id _context;
	OFData *_queryData;
	OFTimer *_cancelTimer;
}

@property (readonly, nonatomic) OFString *host;
@property (readonly, nonatomic) of_dns_resource_record_class_t recordClass;
@property (readonly, nonatomic) of_dns_resource_record_type_t recordType;
@property (readonly, nonatomic) OFNumber *ID;
@property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *nameServers;
@property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *searchDomains;
@property (nonatomic) size_t nameServersIndex;
@property (nonatomic) size_t searchDomainsIndex;
@property (nonatomic) size_t attempt;
@property (readonly, nonatomic) id target;
@property (readonly, nonatomic) SEL selector;
@property (readonly, nonatomic) id context;
@property (readonly, nonatomic) OFData *queryData;
@property (retain, nonatomic) OFTimer *cancelTimer;

- (instancetype)initWithHost: (OFString *)host

		 recordClass: (of_dns_resource_record_class_t)recordClass
		  recordType: (of_dns_resource_record_type_t)recordType
			  ID: (OFNumber *)ID
		 nameServers: (OFArray OF_GENERIC(OFString *) *)nameServers
	       searchDomains: (OFArray OF_GENERIC(OFString *) *)searchDomains
		      target: (id)target
		    selector: (SEL)selector







|













|















>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 *
 *  - Resolve with each search domain
 *  - Fallback to TCP
 */

@interface OFDNSResolverQuery: OFObject
{
	OFString *_host, *_domainName;
	of_dns_resource_record_class_t _recordClass;
	of_dns_resource_record_type_t _recordType;
	OFNumber *_ID;
	OFArray OF_GENERIC(OFString *) *_nameServers, *_searchDomains;
	size_t _nameServersIndex, _searchDomainsIndex;
	size_t _attempt;
	id _target;
	SEL _selector;
	id _context;
	OFData *_queryData;
	OFTimer *_cancelTimer;
}

@property (readonly, nonatomic) OFString *host, *domainName;
@property (readonly, nonatomic) of_dns_resource_record_class_t recordClass;
@property (readonly, nonatomic) of_dns_resource_record_type_t recordType;
@property (readonly, nonatomic) OFNumber *ID;
@property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *nameServers;
@property (readonly, nonatomic) OFArray OF_GENERIC(OFString *) *searchDomains;
@property (nonatomic) size_t nameServersIndex;
@property (nonatomic) size_t searchDomainsIndex;
@property (nonatomic) size_t attempt;
@property (readonly, nonatomic) id target;
@property (readonly, nonatomic) SEL selector;
@property (readonly, nonatomic) id context;
@property (readonly, nonatomic) OFData *queryData;
@property (retain, nonatomic) OFTimer *cancelTimer;

- (instancetype)initWithHost: (OFString *)host
		  domainName: (OFString *)domainName
		 recordClass: (of_dns_resource_record_class_t)recordClass
		  recordType: (of_dns_resource_record_type_t)recordType
			  ID: (OFNumber *)ID
		 nameServers: (OFArray OF_GENERIC(OFString *) *)nameServers
	       searchDomains: (OFArray OF_GENERIC(OFString *) *)searchDomains
		      target: (id)target
		    selector: (SEL)selector
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527

528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544

545
546
547
548
549
550
551

	[ret makeImmutable];

	return ret;
}

static void callback(id target, SEL selector, OFDNSResolver *resolver,
    OFArray *answerRecords, OFArray *authorityRecords,
    OFArray *additionalRecords, id context, id exception)
{
	void (*method)(id, SEL, OFDNSResolver *, OFArray *, OFArray *,
	    OFArray *, id, id) = (void (*)(id, SEL, OFDNSResolver *, OFArray *,
	    OFArray *, OFArray *, id, id))
	    [target methodForSelector: selector];

	method(target, selector, resolver, answerRecords, authorityRecords,
	    additionalRecords, context, exception);
}

@implementation OFDNSResolverQuery
@synthesize host = _host, recordClass = _recordClass, recordType = _recordType;
@synthesize ID = _ID, nameServers = _nameServers;
@synthesize searchDomains = _searchDomains;
@synthesize nameServersIndex = _nameServersIndex;
@synthesize searchDomainsIndex = _searchDomainsIndex, attempt = _attempt;
@synthesize target = _target, selector = _selector, context = _context;
@synthesize queryData = _queryData, cancelTimer = _cancelTimer;

- (instancetype)initWithHost: (OFString *)host

		 recordClass: (of_dns_resource_record_class_t)recordClass
		  recordType: (of_dns_resource_record_type_t)recordType
			  ID: (OFNumber *)ID
		 nameServers: (OFArray OF_GENERIC(OFString *) *)nameServers
	       searchDomains: (OFArray OF_GENERIC(OFString *) *)searchDomains
		      target: (id)target
		    selector: (SEL)selector
		     context: (id)context
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFMutableData *queryData;
		uint16_t tmp;

		_host = [host copy];

		_recordClass = recordClass;
		_recordType = recordType;
		_ID = [ID retain];
		_nameServers = [nameServers copy];
		_searchDomains = [searchDomains copy];
		_target = [target retain];
		_selector = selector;







|


|
|
|


|
|



|
|







>

















>







500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554

	[ret makeImmutable];

	return ret;
}

static void callback(id target, SEL selector, OFDNSResolver *resolver,
    OFString *domainName, OFArray *answerRecords, OFArray *authorityRecords,
    OFArray *additionalRecords, id context, id exception)
{
	void (*method)(id, SEL, OFDNSResolver *, OFString *, OFArray *,
	    OFArray *, OFArray *, id, id) = (void (*)(id, SEL, OFDNSResolver *,
	    OFString *, OFArray *, OFArray *, OFArray *, id, id))
	    [target methodForSelector: selector];

	method(target, selector, resolver, domainName, answerRecords,
	    authorityRecords, additionalRecords, context, exception);
}

@implementation OFDNSResolverQuery
@synthesize host = _host, domainName = _domainName, recordClass = _recordClass;
@synthesize recordType = _recordType, ID = _ID, nameServers = _nameServers;
@synthesize searchDomains = _searchDomains;
@synthesize nameServersIndex = _nameServersIndex;
@synthesize searchDomainsIndex = _searchDomainsIndex, attempt = _attempt;
@synthesize target = _target, selector = _selector, context = _context;
@synthesize queryData = _queryData, cancelTimer = _cancelTimer;

- (instancetype)initWithHost: (OFString *)host
		  domainName: (OFString *)domainName
		 recordClass: (of_dns_resource_record_class_t)recordClass
		  recordType: (of_dns_resource_record_type_t)recordType
			  ID: (OFNumber *)ID
		 nameServers: (OFArray OF_GENERIC(OFString *) *)nameServers
	       searchDomains: (OFArray OF_GENERIC(OFString *) *)searchDomains
		      target: (id)target
		    selector: (SEL)selector
		     context: (id)context
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		OFMutableData *queryData;
		uint16_t tmp;

		_host = [host copy];
		_domainName = [domainName copy];
		_recordClass = recordClass;
		_recordType = recordType;
		_ID = [ID retain];
		_nameServers = [nameServers copy];
		_searchDomains = [searchDomains copy];
		_target = [target retain];
		_selector = selector;
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
		/* ANCOUNT, NSCOUNT and ARCOUNT */
		[queryData increaseCountBy: 6];

		/* Question */

		/* QNAME */
		for (OFString *component in
		    [host componentsSeparatedByString: @"."]) {
			size_t length = [component UTF8StringLength];
			uint8_t length8;

			if (length > 63 || [queryData count] + length > 512)
				@throw [OFOutOfRangeException exception];

			length8 = (uint8_t)length;







|







575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
		/* ANCOUNT, NSCOUNT and ARCOUNT */
		[queryData increaseCountBy: 6];

		/* Question */

		/* QNAME */
		for (OFString *component in
		    [domainName componentsSeparatedByString: @"."]) {
			size_t length = [component UTF8StringLength];
			uint8_t length8;

			if (length > 63 || [queryData count] + length > 512)
				@throw [OFOutOfRangeException exception];

			length8 = (uint8_t)length;
611
612
613
614
615
616
617

618
619
620
621
622
623
624

	return self;
}

- (void)dealloc
{
	[_host release];

	[_ID release];
	[_nameServers release];
	[_searchDomains release];
	[_target release];
	[_context release];
	[_queryData release];
	[_cancelTimer release];







>







614
615
616
617
618
619
620
621
622
623
624
625
626
627
628

	return self;
}

- (void)dealloc
{
	[_host release];
	[_domainName release];
	[_ID release];
	[_nameServers release];
	[_searchDomains release];
	[_target release];
	[_context release];
	[_queryData release];
	[_cancelTimer release];
973
974
975
976
977
978
979

980
981
982
983
984
985
986
987
988
989
990
991
992
993









994
995

996
997
998
999
1000
1001
1002
	      recordType: (of_dns_resource_record_type_t)recordType
		  target: (id)target
		selector: (SEL)selector
		 context: (id)context
{
	void *pool = objc_autoreleasePoolPush();
	OFNumber *ID;

	OFDNSResolverQuery *query;

	/* TODO: Properly try all search domains */
	if (![host hasSuffix: @"."])
		host = [host stringByAppendingString: @"."];

	if ([host UTF8StringLength] > 253)
		@throw [OFOutOfRangeException exception];

	/* Random, unused ID */
	do {
		ID = [OFNumber numberWithUInt16: (uint16_t)of_random()];
	} while ([_queries objectForKey: ID] != nil);










	query = [[[OFDNSResolverQuery alloc]
	    initWithHost: host

	     recordClass: recordClass
	      recordType: recordType
		      ID: ID
	     nameServers: _nameServers
	   searchDomains: _searchDomains
		  target: target
		selector: selector







>


<
<
<
<
<
<
<





>
>
>
>
>
>
>
>
>


>







977
978
979
980
981
982
983
984
985
986







987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
	      recordType: (of_dns_resource_record_type_t)recordType
		  target: (id)target
		selector: (SEL)selector
		 context: (id)context
{
	void *pool = objc_autoreleasePoolPush();
	OFNumber *ID;
	OFString *domainName;
	OFDNSResolverQuery *query;








	/* Random, unused ID */
	do {
		ID = [OFNumber numberWithUInt16: (uint16_t)of_random()];
	} while ([_queries objectForKey: ID] != nil);

	if ([host hasSuffix: @"."])
		domainName = host;
	else
		/* TODO: Properly try all search domains */
		domainName = [host stringByAppendingString: @"."];

	if ([domainName UTF8StringLength] > 253)
		@throw [OFOutOfRangeException exception];

	query = [[[OFDNSResolverQuery alloc]
	    initWithHost: host
	      domainName: domainName
	     recordClass: recordClass
	      recordType: recordType
		      ID: ID
	     nameServers: _nameServers
	   searchDomains: _searchDomains
		  target: target
		selector: selector
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114

1115
1116
1117
1118
1119
1120
1121
1122
		     selector: @selector(of_socket:didSendBuffer:bytesSent:
				   receiver:context:exception:)
		      context: query];
}

- (void)of_queryWithIDTimedOut: (OFDNSResolverQuery *)query
{
	id target, context;
	SEL selector;
	OFResolveHostFailedException *exception;

	if (query == nil)
		return;

	if ([query nameServersIndex] + 1 < [[query nameServers] count]) {
		[query setNameServersIndex: [query nameServersIndex] + 1];
		[self of_sendQuery: query];
		return;
	}

	if ([query attempt] < ATTEMPTS) {
		[query setAttempt: [query attempt] + 1];
		[query setNameServersIndex: 0];
		[self of_sendQuery: query];
		return;
	}

	target = [[[query target] retain] autorelease];
	selector = [query selector];
	context = [[[query context] retain] autorelease];

	exception = [OFResolveHostFailedException
	    exceptionWithHost: [query host]
		  recordClass: [query recordClass]
		   recordType: [query recordType]
			error: OF_DNS_RESOLVER_ERROR_TIMEOUT];

	[_queries removeObjectForKey: [query ID]];

	callback(target, selector, self, nil, nil, nil, context, exception);
}

- (size_t)of_socket: (OFUDPSocket *)sock
      didSendBuffer: (void **)buffer
	  bytesSent: (size_t)bytesSent
	   receiver: (of_socket_address_t *)receiver
	    context: (OFDNSResolverQuery *)query
	  exception: (id)exception
{
	if (exception != nil) {
		id target = [[[query target] retain] autorelease];
		SEL selector = [query selector];
		id context = [[[query context] retain] autorelease];

		[_queries removeObjectForKey: [query ID]];


		callback(target, selector, self, nil, nil, nil, context,
		    exception);

		return 0;
	}

	[sock asyncReceiveIntoBuffer: [self allocMemoryWithSize: 512]
			      length: 512







<
<


















|
|
<







<
|
|










|
<
<
<


>
|







1067
1068
1069
1070
1071
1072
1073


1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093

1094
1095
1096
1097
1098
1099
1100

1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113



1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
		     selector: @selector(of_socket:didSendBuffer:bytesSent:
				   receiver:context:exception:)
		      context: query];
}

- (void)of_queryWithIDTimedOut: (OFDNSResolverQuery *)query
{


	OFResolveHostFailedException *exception;

	if (query == nil)
		return;

	if ([query nameServersIndex] + 1 < [[query nameServers] count]) {
		[query setNameServersIndex: [query nameServersIndex] + 1];
		[self of_sendQuery: query];
		return;
	}

	if ([query attempt] < ATTEMPTS) {
		[query setAttempt: [query attempt] + 1];
		[query setNameServersIndex: 0];
		[self of_sendQuery: query];
		return;
	}

	query = [[query retain] autorelease];
	[_queries removeObjectForKey: [query ID]];


	exception = [OFResolveHostFailedException
	    exceptionWithHost: [query host]
		  recordClass: [query recordClass]
		   recordType: [query recordType]
			error: OF_DNS_RESOLVER_ERROR_TIMEOUT];


	callback([query target], [query selector], self, [query domainName],
	    nil, nil, nil, [query context], exception);
}

- (size_t)of_socket: (OFUDPSocket *)sock
      didSendBuffer: (void **)buffer
	  bytesSent: (size_t)bytesSent
	   receiver: (of_socket_address_t *)receiver
	    context: (OFDNSResolverQuery *)query
	  exception: (id)exception
{
	if (exception != nil) {
		query = [[query retain] autorelease];



		[_queries removeObjectForKey: [query ID]];

		callback([query target], [query selector], self,
		    [query domainName], nil, nil, nil, [query context],
		    exception);

		return 0;
	}

	[sock asyncReceiveIntoBuffer: [self allocMemoryWithSize: 512]
			      length: 512
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250

1251
1252
1253
1254
1255
1256
1257

		answerRecords = parseSection(buffer, length, &i, numAnswers);
		authorityRecords = parseSection(buffer, length, &i,
		    numAuthorityRecords);
		additionalRecords = parseSection(buffer, length, &i,
		    numAdditionalRecords);
	} @catch (id e) {
		callback([query target], [query selector], self, nil, nil, nil,
		    [query context], e);
		return false;
	}

	callback([query target], [query selector], self, answerRecords,
	    authorityRecords, additionalRecords, [query context], nil);


	return false;
}

- (void)close
{
	void *pool = objc_autoreleasePoolPush();







|
|



|
|
>







1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260

		answerRecords = parseSection(buffer, length, &i, numAnswers);
		authorityRecords = parseSection(buffer, length, &i,
		    numAuthorityRecords);
		additionalRecords = parseSection(buffer, length, &i,
		    numAdditionalRecords);
	} @catch (id e) {
		callback([query target], [query selector], self,
		    [query domainName], nil, nil, nil, [query context], e);
		return false;
	}

	callback([query target], [query selector], self, [query domainName],
	    answerRecords, authorityRecords, additionalRecords,
	    [query context], nil);

	return false;
}

- (void)close
{
	void *pool = objc_autoreleasePoolPush();
1274
1275
1276
1277
1278
1279
1280
1281

1282
1283
1284
1285
1286
1287
1288
1289

		exception = [OFResolveHostFailedException
		    exceptionWithHost: [query host]
			  recordClass: [query recordClass]
			   recordType: [query recordType]
				error: OF_DNS_RESOLVER_ERROR_CANCELED];

		callback([query target], [query selector], self, nil, nil, nil,

		    [query context], exception);
	}

	[_queries removeAllObjects];

	objc_autoreleasePoolPop(pool);
}
@end







|
>
|







1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293

		exception = [OFResolveHostFailedException
		    exceptionWithHost: [query host]
			  recordClass: [query recordClass]
			   recordType: [query recordType]
				error: OF_DNS_RESOLVER_ERROR_CANCELED];

		callback([query target], [query selector], self,
		    [query domainName], nil, nil, nil, [query context],
		    exception);
	}

	[_queries removeAllObjects];

	objc_autoreleasePoolPop(pool);
}
@end

Modified utils/ofdns/OFDNS.m from [3c9332d43f] to [f7027f3fe4].

24
25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53

@interface OFDNS: OFObject <OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(OFDNS)

@implementation OFDNS
-	(void)DNSResolver: (OFDNSResolver *)resolver

  didReceiveAnswerRecords: (OFArray *)answerRecords
	 authorityRecords: (OFArray *)authorityRecords
	additionalRecords: (OFArray *)additionalRecords
		  context: (id)context
		exception: (id)exception
{
	if (exception != nil) {
		[of_stderr writeFormat: @"Failed to resolve: %@\n", exception];
		[OFApplication terminateWithStatus: 1];
	}

	[of_stdout writeFormat: @"Answer records: %@\n"

				@"Authority records: %@\n"
				@"Additional records: %@\n",
				answerRecords, authorityRecords,
				additionalRecords];

	[OFApplication terminate];
}

- (void)applicationDidFinishLaunching
{







|
>
|
|
|
|
|






|
>


|







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

@interface OFDNS: OFObject <OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(OFDNS)

@implementation OFDNS
-    (void)DNSResolver: (OFDNSResolver *)resolver
  didResolveDomainName: (OFString *)domainName
	 answerRecords: (OFArray *)answerRecords
      authorityRecords: (OFArray *)authorityRecords
     additionalRecords: (OFArray *)additionalRecords
	       context: (id)context
	     exception: (id)exception
{
	if (exception != nil) {
		[of_stderr writeFormat: @"Failed to resolve: %@\n", exception];
		[OFApplication terminateWithStatus: 1];
	}

	[of_stdout writeFormat: @"FQDN: %@\n"
				@"Answer records: %@\n"
				@"Authority records: %@\n"
				@"Additional records: %@\n",
				domainName, answerRecords, authorityRecords,
				additionalRecords];

	[OFApplication terminate];
}

- (void)applicationDidFinishLaunching
{
79
80
81
82
83
84
85
86
87
88
89
90
91
92
		[resolver setNameServers:
		    [OFArray arrayWithObject: [arguments objectAtIndex: 3]]];

	[resolver asyncResolveHost: [arguments objectAtIndex: 0]
		       recordClass: recordClass
			recordType: recordType
			    target: self
			  selector: @selector(DNSResolver:
					didReceiveAnswerRecords:
					authorityRecords:additionalRecords:
					context:exception:)
			   context: nil];
}
@end







|
<
|
|



81
82
83
84
85
86
87
88

89
90
91
92
93
		[resolver setNameServers:
		    [OFArray arrayWithObject: [arguments objectAtIndex: 3]]];

	[resolver asyncResolveHost: [arguments objectAtIndex: 0]
		       recordClass: recordClass
			recordType: recordType
			    target: self
			  selector: @selector(DNSResolver:didResolveDomainName:

					answerRecords:authorityRecords:
					additionalRecords:context:exception:)
			   context: nil];
}
@end