ObjFW  Check-in [1124f7d4d4]

Overview
Comment:OFDNSResolver: Add support for {NS,PTR,TXT} RRs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1124f7d4d4b886c12c354e430f4e5041cc44b37ba74ff56cf29d151c59804e8a
User & Date: js on 2018-07-31 23:48:30
Other Links: manifest | tags
Context
2018-08-01
23:02
OFDNSResourceRecord: Cleaner subclass separation check-in: 17397bfad4 user: js tags: trunk
2018-07-31
23:48
OFDNSResolver: Add support for {NS,PTR,TXT} RRs check-in: 1124f7d4d4 user: js tags: trunk
00:41
OFDNSResolver: Add support for parsing MX records check-in: 650fdd14e3 user: js tags: trunk
Changes

Modified src/OFDNSResolver.m from [1105a5a101] to [7f7fd809d0].

267
268
269
270
271
272
273
















274
275
276
277
278
279
280
281
282
283
284
285
286
287
















288
289
290
291
292
293
294
			    buffer[i], buffer[i + 1],
			    buffer[i + 2], buffer[i + 3]];

			return [[[OFADNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
















				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_CNAME:
			j = i;

			data = parseName(buffer, length, &j,
			    ALLOWED_POINTER_LEVELS);

			if (j != i + dataLength)
				@throw [OFInvalidServerReplyException
				    exception];

			return [[[OFCNAMEDNSResourceRecord alloc]
			    initWithName: name
















			     recordClass: recordClass
			      recordType: recordType
				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_MX:
			if (dataLength < 2)
				@throw [OFInvalidServerReplyException







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>














>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
			    buffer[i], buffer[i + 1],
			    buffer[i + 2], buffer[i + 3]];

			return [[[OFADNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_NS:
			j = i;

			data = parseName(buffer, length, &j,
			    ALLOWED_POINTER_LEVELS);

			if (j != i + dataLength)
				@throw [OFInvalidServerReplyException
				    exception];

			return [[[OFNSDNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_CNAME:
			j = i;

			data = parseName(buffer, length, &j,
			    ALLOWED_POINTER_LEVELS);

			if (j != i + dataLength)
				@throw [OFInvalidServerReplyException
				    exception];

			return [[[OFCNAMEDNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_PTR:
			j = i;

			data = parseName(buffer, length, &j,
			    ALLOWED_POINTER_LEVELS);

			if (j != i + dataLength)
				@throw [OFInvalidServerReplyException
				    exception];

			return [[[OFPTRDNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_MX:
			if (dataLength < 2)
				@throw [OFInvalidServerReplyException
306
307
308
309
310
311
312










313
314
315
316
317
318
319
				    exception];

			return [[[OFMXDNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
			      preference: preference










				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_AAAA:
			if (dataLength != 16)
				@throw [OFInvalidServerReplyException
				    exception];








>
>
>
>
>
>
>
>
>
>







338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
				    exception];

			return [[[OFMXDNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
			      preference: preference
				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_TXT:
			data = [OFData dataWithItems: &buffer[i]
					       count: dataLength];

			return [[[OFTXTDNSResourceRecord alloc]
			    initWithName: name
			     recordClass: recordClass
			      recordType: recordType
				    data: data
				     TTL: TTL] autorelease];
		case OF_DNS_RESOURCE_RECORD_TYPE_AAAA:
			if (dataLength != 16)
				@throw [OFInvalidServerReplyException
				    exception];

Modified src/OFDNSResourceRecord.h from [610fb854ae] to [494b9e3242].

198
199
200
201
202
203
204







































205
206
207
208
209
210
211
		 recordClass: (of_dns_resource_record_class_t)recordClass
		  recordType: (of_dns_resource_record_type_t)recordType
		  preference: (uint16_t)preference
			data: (id)data
			 TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
@end








































#ifdef __cplusplus
extern "C" {
#endif
extern OFString *_Nonnull of_dns_resource_record_class_to_string(
    of_dns_resource_record_class_t recordClass);
extern OFString *_Nonnull of_dns_resource_record_type_to_string(
    of_dns_resource_record_type_t recordType);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
		 recordClass: (of_dns_resource_record_class_t)recordClass
		  recordType: (of_dns_resource_record_type_t)recordType
		  preference: (uint16_t)preference
			data: (id)data
			 TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER;
@end

/*!
 * @class OFNSDNSResourceRecord \
 *	  OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h
 *
 * @brief A class representing a CNAME DNS resource record.
 */
@interface OFNSDNSResourceRecord: OFDNSResourceRecord
/*!
 * A string with the authoritative host of the resource record.
 */
@property (readonly, nonatomic) OFString *data;
@end

/*!
 * @class OFPTRDNSResourceRecord \
 *	  OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h
 *
 * @brief A class representing a CNAME DNS resource record.
 */
@interface OFPTRDNSResourceRecord: OFDNSResourceRecord
/*!
 * A string with the domain name for the resource record.
 */
@property (readonly, nonatomic) OFString *data;
@end

/*!
 * @class OFTXTDNSResourceRecord \
 *	  OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h
 *
 * @brief A class representing a CNAME DNS resource record.
 */
@interface OFTXTDNSResourceRecord: OFDNSResourceRecord
/*!
 * Data with the text of the resource record.
 */
@property (readonly, nonatomic) OFString *data;
@end

#ifdef __cplusplus
extern "C" {
#endif
extern OFString *_Nonnull of_dns_resource_record_class_to_string(
    of_dns_resource_record_class_t recordClass);
extern OFString *_Nonnull of_dns_resource_record_type_to_string(
    of_dns_resource_record_type_t recordType);

Modified src/OFDNSResourceRecord.m from [698216c4aa] to [627ddd0813].

251
252
253
254
255
256
257












	    @">",
	    [self className], _name,
	    of_dns_resource_record_class_to_string(_recordClass),
	    of_dns_resource_record_type_to_string(_recordType), _preference,
	    _data, _TTL];
}
@end



















>
>
>
>
>
>
>
>
>
>
>
>
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
	    @">",
	    [self className], _name,
	    of_dns_resource_record_class_to_string(_recordClass),
	    of_dns_resource_record_type_to_string(_recordType), _preference,
	    _data, _TTL];
}
@end

@implementation OFNSDNSResourceRecord
@dynamic data;
@end

@implementation OFPTRDNSResourceRecord
@dynamic data;
@end

@implementation OFTXTDNSResourceRecord
@dynamic data;
@end