Overview
Comment: | OFDNSResolver: Add support for parsing SOA records |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c165d49455fc8475c9413252165b3750 |
User & Date: | js on 2018-08-02 01:16:47 |
Other Links: | manifest | tags |
Context
2018-08-04
| ||
00:06 | OFDNSResolver: Add a fallback for localhost check-in: 4671310302 user: js tags: trunk | |
2018-08-02
| ||
01:16 | OFDNSResolver: Add support for parsing SOA records check-in: c165d49455 user: js tags: trunk | |
2018-08-01
| ||
23:02 | OFDNSResourceRecord: Cleaner subclass separation check-in: 17397bfad4 user: js tags: trunk | |
Changes
Modified src/OFDNSResolver.m from [4b3c509e3e] to [d938f274bb].
︙ | ︙ | |||
244 245 246 247 248 249 250 | return data; } static OF_KINDOF(OFDNSResourceRecord *) createResourceRecord(OFString *name, of_dns_resource_record_class_t recordClass, of_dns_resource_record_type_t recordType, uint32_t TTL, | | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | return data; } static OF_KINDOF(OFDNSResourceRecord *) createResourceRecord(OFString *name, of_dns_resource_record_class_t recordClass, of_dns_resource_record_type_t recordType, uint32_t TTL, const unsigned char *buffer, size_t length, size_t i, uint16_t dataLength) { if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_A && recordClass == OF_DNS_RESOURCE_RECORD_CLASS_IN) { OFString *address; if (dataLength != 4) @throw [OFInvalidServerReplyException exception]; |
︙ | ︙ | |||
285 286 287 288 289 290 291 292 293 294 295 296 297 298 | if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFCNAMEDNSResourceRecord alloc] initWithName: name recordClass: recordClass alias: alias TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_PTR) { size_t j = i; OFString *domainName = parseName(buffer, length, &j, ALLOWED_POINTER_LEVELS); if (j != i + dataLength) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 327 328 329 330 331 332 333 334 335 336 337 338 339 | if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFCNAMEDNSResourceRecord alloc] initWithName: name recordClass: recordClass alias: alias TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_SOA) { size_t j = i; OFString *primaryNameServer = parseName(buffer, length, &j, ALLOWED_POINTER_LEVELS); OFString *responsiblePerson; uint32_t serialNumber, refreshInterval, retryInterval; uint32_t expirationInterval, minTTL; if (j > i + dataLength) @throw [OFInvalidServerReplyException exception]; responsiblePerson = parseName(buffer, length, &j, ALLOWED_POINTER_LEVELS); if (dataLength - (j - i) != 20) @throw [OFInvalidServerReplyException exception]; serialNumber = (buffer[j] << 24) | (buffer[j + 1] << 16) | (buffer[j + 2] << 8) | buffer[j + 3]; refreshInterval = (buffer[j + 4] << 24) | (buffer[j + 5] << 16) | (buffer[j + 6] << 8) | buffer[j + 7]; retryInterval = (buffer[j + 8] << 24) | (buffer[j + 9] << 16) | (buffer[j + 10] << 8) | buffer[j + 11]; expirationInterval = (buffer[j + 12] << 24) | (buffer[j + 13] << 16) | (buffer[j + 14] << 8) | buffer[j + 15]; minTTL = (buffer[j + 16] << 24) | (buffer[j + 17] << 16) | (buffer[j + 18] << 8) | buffer[j + 19]; return [[[OFSOADNSResourceRecord alloc] initWithName: name recordClass: recordClass primaryNameServer: primaryNameServer responsiblePerson: responsiblePerson serialNumber: serialNumber refreshInterval: refreshInterval retryInterval: retryInterval expirationInterval: expirationInterval minTTL: minTTL TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_PTR) { size_t j = i; OFString *domainName = parseName(buffer, length, &j, ALLOWED_POINTER_LEVELS); if (j != i + dataLength) |
︙ | ︙ |
Modified src/OFDNSResourceRecord.h from [60ca2991f0] to [0348cf6ab0].
︙ | ︙ | |||
324 325 326 327 328 329 330 331 332 333 334 335 336 337 | */ - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass domainName: (OFString *)domainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFTXTDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a TXT DNS resource record. */ @interface OFTXTDNSResourceRecord: OFDNSResourceRecord | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | */ - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass domainName: (OFString *)domainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFSOADNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an SOA DNS resource record. */ @interface OFSOADNSResourceRecord: OFDNSResourceRecord { OFString *_primaryNameServer, *_responsiblePerson; uint32_t _serialNumber, _refreshInterval, _retryInterval; uint32_t _expirationInterval, _minTTL; } /*! * The the primary name server for the zone. */ @property (readonly, nonatomic) OFString *primaryNameServer; /*! * The mailbox of the person responsible for the zone. */ @property (readonly, nonatomic) OFString *responsiblePerson; /*! * The serial number of the original copy of the zone. */ @property (readonly, nonatomic) uint32_t serialNumber; /*! * The refresh interval of the zone. */ @property (readonly, nonatomic) uint32_t refreshInterval; /*! * The retry interval of the zone. */ @property (readonly, nonatomic) uint32_t retryInterval; /*! * The expiration interval of the zone. */ @property (readonly, nonatomic) uint32_t expirationInterval; /*! * The minimum TTL of the zone. */ @property (readonly, nonatomic) uint32_t minTTL; - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass recordType: (of_dns_resource_record_type_t)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFTXTDNSResourceRecord with the * specified name, class, text data and time to live. * * @param name The name for the resource record * @param recordClass The class code for the resource record * @param primaryNameServer The the primary name server for the zone * @param responsiblePerson The mailbox of the person responsible for the zone * @param serialNumber The serial number of the original copy of the zone * @param refreshInterval The refresh interval of the zone * @param retryInterval The retry interval of the zone * @param expirationInterval The expiration interval of the zone * @param minTTL The minimum TTL of the zone * @param TTL The time to live for the resource record */ - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval expirationInterval: (uint32_t)expirationInterval minTTL: (uint32_t)minTTL TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /*! * @class OFTXTDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a TXT DNS resource record. */ @interface OFTXTDNSResourceRecord: OFDNSResourceRecord |
︙ | ︙ |
Modified src/OFDNSResourceRecord.m from [86511b150e] to [22eebc795b].
︙ | ︙ | |||
681 682 683 684 685 686 687 688 689 690 691 692 693 694 | @"\tTTL = %" PRIu32 "\n" @">", [self className], _name, of_dns_resource_record_class_to_string(_recordClass), _domainName, _TTL]; } @end @implementation OFTXTDNSResourceRecord @synthesize textData = _textData; - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass recordType: (of_dns_resource_record_type_t)recordType | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 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 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 | @"\tTTL = %" PRIu32 "\n" @">", [self className], _name, of_dns_resource_record_class_to_string(_recordClass), _domainName, _TTL]; } @end @implementation OFSOADNSResourceRecord @synthesize primaryNameServer = _primaryNameServer; @synthesize responsiblePerson = _responsiblePerson; @synthesize serialNumber = _serialNumber, refreshInterval = _refreshInterval; @synthesize retryInterval = _retryInterval; @synthesize expirationInterval = _expirationInterval, minTTL = _minTTL; - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass recordType: (of_dns_resource_record_type_t)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval expirationInterval: (uint32_t)expirationInterval minTTL: (uint32_t)minTTL TTL: (uint32_t)TTL { self = [super initWithName: name recordClass: recordClass recordType: OF_DNS_RESOURCE_RECORD_TYPE_SOA TTL: TTL]; @try { _primaryNameServer = [primaryNameServer copy]; _responsiblePerson = [responsiblePerson copy]; _serialNumber = serialNumber; _refreshInterval = refreshInterval; _retryInterval = retryInterval; _expirationInterval = expirationInterval; _minTTL = minTTL; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_primaryNameServer release]; [_responsiblePerson release]; [super dealloc]; } - (bool)isEqual: (id)otherObject { OFSOADNSResourceRecord *otherRecord; if (![otherObject isKindOfClass: [OFSOADNSResourceRecord class]]) return false; otherRecord = otherObject; if (otherRecord->_name != _name && ![otherRecord->_name isEqual: _name]) return false; if (otherRecord->_recordClass != _recordClass) return false; if (otherRecord->_recordType != _recordType) return false; if (otherRecord->_primaryNameServer != _primaryNameServer && ![otherRecord->_primaryNameServer isEqual: _primaryNameServer]) return false; if (otherRecord->_responsiblePerson != _responsiblePerson && ![otherRecord->_responsiblePerson isEqual: _responsiblePerson]) return false; if (otherRecord->_serialNumber != _serialNumber) return false; if (otherRecord->_refreshInterval != _refreshInterval) return false; if (otherRecord->_retryInterval != _retryInterval) return false; if (otherRecord->_expirationInterval != _expirationInterval) return false; if (otherRecord->_minTTL != _minTTL) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, [_name hash]); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, [_primaryNameServer hash]); OF_HASH_ADD_HASH(hash, [_responsiblePerson hash]); OF_HASH_ADD(hash, _serialNumber >> 24); OF_HASH_ADD(hash, _serialNumber >> 16); OF_HASH_ADD(hash, _serialNumber >> 8); OF_HASH_ADD(hash, _serialNumber); OF_HASH_ADD(hash, _refreshInterval >> 24); OF_HASH_ADD(hash, _refreshInterval >> 16); OF_HASH_ADD(hash, _refreshInterval >> 8); OF_HASH_ADD(hash, _refreshInterval); OF_HASH_ADD(hash, _retryInterval >> 24); OF_HASH_ADD(hash, _retryInterval >> 16); OF_HASH_ADD(hash, _retryInterval >> 8); OF_HASH_ADD(hash, _retryInterval); OF_HASH_ADD(hash, _expirationInterval >> 24); OF_HASH_ADD(hash, _expirationInterval >> 16); OF_HASH_ADD(hash, _expirationInterval >> 8); OF_HASH_ADD(hash, _expirationInterval); OF_HASH_ADD(hash, _minTTL >> 24); OF_HASH_ADD(hash, _minTTL >> 16); OF_HASH_ADD(hash, _minTTL >> 8); OF_HASH_ADD(hash, _minTTL); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tPrimary Name Server = %@\n" @"\tResponsible Person = %@\n" @"\tSerial Number = %" PRIu32 "\n" @"\tRefresh Interval = %" PRIu32 "\n" @"\tRetry Interval = %" PRIu32 "\n" @"\tExpiration Interval = %" PRIu32 "\n" @"\tMinimum TTL = %" PRIu32 "\n" @"\tTTL = %" PRIu32 "\n" @">", [self className], _name, of_dns_resource_record_class_to_string(_recordClass), _primaryNameServer, _responsiblePerson, _serialNumber, _refreshInterval, _retryInterval, _expirationInterval, _minTTL, _TTL]; } @end @implementation OFTXTDNSResourceRecord @synthesize textData = _textData; - (instancetype)initWithName: (OFString *)name recordClass: (of_dns_resource_record_class_t)recordClass recordType: (of_dns_resource_record_type_t)recordType |
︙ | ︙ |