Overview
Comment: | OFDNSResolver: Add support for parsing SRV records |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
462cb8a1087c2d69bb26d01d9df499a5 |
User & Date: | js on 2018-08-04 15:27:47 |
Other Links: | manifest | tags |
Context
2018-08-04
| ||
15:35 | Use OF_HAVE_IPV6 instead of HAVE_IPV6 check-in: e36455441d user: js tags: trunk | |
15:27 | OFDNSResolver: Add support for parsing SRV records check-in: 462cb8a108 user: js tags: trunk | |
14:37 | OFDNSResolver: Add support for parsing RP records check-in: b5d9bd2fd0 user: js tags: trunk | |
Changes
Modified src/OFDNSResolver.m from [ad00966ce8] to [9a40ea3367].
︙ | ︙ | |||
450 451 452 453 454 455 456 457 458 459 460 461 462 463 | address = parseAAAAData(&buffer[i]); return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: address TTL: TTL] autorelease]; } else return [[[OFDNSResourceRecord alloc] initWithName: name recordClass: recordClass recordType: recordType TTL: TTL] autorelease]; } | > > > > > > > > > > > > > > > > > > > > > > > > > > | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | address = parseAAAAData(&buffer[i]); return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: address TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_SRV && recordClass == OF_DNS_RESOURCE_RECORD_CLASS_IN) { uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) @throw [OFInvalidServerReplyException exception]; priority = (buffer[i] << 8) | buffer[i + 1]; weight = (buffer[i + 2] << 8) | buffer[i + 3]; port = (buffer[i + 4] << 8) | buffer[i + 5]; j = i + 6; target = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @throw [OFInvalidServerReplyException exception]; return [[[OFSRVDNSResourceRecord alloc] initWithName: name priority: priority weight: weight target: target port: port TTL: TTL] autorelease]; } else return [[[OFDNSResourceRecord alloc] initWithName: name recordClass: recordClass recordType: recordType TTL: TTL] autorelease]; } |
︙ | ︙ |
Modified src/OFDNSResourceRecord.h from [4a7e8d41a3] to [0fc50e0aa4].
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | OF_DNS_RESOURCE_RECORD_TYPE_MX = 15, /*! TXT */ OF_DNS_RESOURCE_RECORD_TYPE_TXT = 16, /*! RP */ OF_DNS_RESOURCE_RECORD_TYPE_RP = 17, /*! AAAA */ OF_DNS_RESOURCE_RECORD_TYPE_AAAA = 28, /*! All types. Only for queries. */ OF_DNS_RESOURCE_RECORD_TYPE_ALL = 255, } of_dns_resource_record_type_t; /*! * @class OFDNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * | > > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | OF_DNS_RESOURCE_RECORD_TYPE_MX = 15, /*! TXT */ OF_DNS_RESOURCE_RECORD_TYPE_TXT = 16, /*! RP */ OF_DNS_RESOURCE_RECORD_TYPE_RP = 17, /*! AAAA */ OF_DNS_RESOURCE_RECORD_TYPE_AAAA = 28, /*! SRV */ OF_DNS_RESOURCE_RECORD_TYPE_SRV = 33, /*! All types. Only for queries. */ OF_DNS_RESOURCE_RECORD_TYPE_ALL = 255, } of_dns_resource_record_type_t; /*! * @class OFDNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * |
︙ | ︙ | |||
504 505 506 507 508 509 510 511 512 513 514 515 516 517 | 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 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | 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 OFSRVDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an SRV DNS resource record. */ @interface OFSRVDNSResourceRecord: OFDNSResourceRecord { uint16_t _priority, _weight; OFString *_target; uint16_t _port; } /*! * @brief The priority of the resource record. */ @property (readonly, nonatomic) uint16_t priority; /*! * @brief The weight of the resource record. */ @property (readonly, nonatomic) uint16_t weight; /*! * @brief The target of the resource record. */ @property (readonly, nonatomic) OFString *target; /*! * @brief The port on the target of the resource record. */ @property (readonly, nonatomic) uint16_t port; - (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 OFSRVDNSResourceRecord with the * specified name, class, preference, mail exchange and time to live. * * @param name The name for the resource record * @param priority The priority for the resource record * @param weight The weight for the resource record * @param target The target for the resource record * @param port The port on the target for the resource record * @param TTL The time to live for the resource record * @return An initialized OFSRVDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name priority: (uint16_t)priority weight: (uint16_t)weight target: (OFString *)target port: (uint16_t)port 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 [08e49ac22a] to [b6b9a8e515].
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | return @"MX"; case OF_DNS_RESOURCE_RECORD_TYPE_TXT: return @"TXT"; case OF_DNS_RESOURCE_RECORD_TYPE_RP: return @"RP"; case OF_DNS_RESOURCE_RECORD_TYPE_AAAA: return @"AAAA"; case OF_DNS_RESOURCE_RECORD_TYPE_ALL: return @"all"; default: return [OFString stringWithFormat: @"%u", recordType]; } } | > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | return @"MX"; case OF_DNS_RESOURCE_RECORD_TYPE_TXT: return @"TXT"; case OF_DNS_RESOURCE_RECORD_TYPE_RP: return @"RP"; case OF_DNS_RESOURCE_RECORD_TYPE_AAAA: return @"AAAA"; case OF_DNS_RESOURCE_RECORD_TYPE_SRV: return @"SRV"; case OF_DNS_RESOURCE_RECORD_TYPE_ALL: return @"all"; default: return [OFString stringWithFormat: @"%u", recordType]; } } |
︙ | ︙ | |||
110 111 112 113 114 115 116 117 118 119 120 121 122 123 | recordType = OF_DNS_RESOURCE_RECORD_TYPE_MX; else if ([string isEqual: @"TXT"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_TXT; else if ([string isEqual: @"RP"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_RP; else if ([string isEqual: @"AAAA"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_AAAA; else @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); return recordType; } | > > | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | recordType = OF_DNS_RESOURCE_RECORD_TYPE_MX; else if ([string isEqual: @"TXT"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_TXT; else if ([string isEqual: @"RP"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_RP; else if ([string isEqual: @"AAAA"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_AAAA; else if ([string isEqual: @"SRV"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_SRV; else @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); return recordType; } |
︙ | ︙ | |||
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | [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 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 | [self className], _name, of_dns_resource_record_class_to_string(_recordClass), _primaryNameServer, _responsiblePerson, _serialNumber, _refreshInterval, _retryInterval, _expirationInterval, _minTTL, _TTL]; } @end @implementation OFSRVDNSResourceRecord @synthesize priority = _priority, weight = _weight, target = _target; @synthesize port = _port; - (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 priority: (uint16_t)priority weight: (uint16_t)weight target: (OFString *)target port: (uint16_t)port TTL: (uint32_t)TTL { self = [super initWithName: name recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN recordType: OF_DNS_RESOURCE_RECORD_TYPE_SRV TTL: TTL]; @try { _priority = priority; _weight = weight; _target = [target copy]; _port = port; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [_target release]; [super dealloc]; } - (bool)isEqual: (id)otherObject { OFSRVDNSResourceRecord *otherRecord; if (![otherObject isKindOfClass: [OFSRVDNSResourceRecord 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->_priority != _priority) return false; if (otherRecord->_weight != _weight) return false; if (otherRecord->_target != _target && ![otherRecord->_target isEqual: _target]) return false; if (otherRecord->_port != _port) 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, _priority >> 8); OF_HASH_ADD(hash, _priority); OF_HASH_ADD(hash, _weight >> 8); OF_HASH_ADD(hash, _weight); OF_HASH_ADD_HASH(hash, [_target hash]); OF_HASH_ADD(hash, _port >> 8); OF_HASH_ADD(hash, _port); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tPriority = %" PRIu16 "\n" @"\tWeight = %" PRIu16 "\n" @"\tTarget = %@\n" @"\tPort = %" PRIu16 "\n" @"\tTTL = %" PRIu32 "\n" @">", [self className], _name, _priority, _weight, _target, _port, _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 |
︙ | ︙ |