Added check for RR type

Now, if the RR for a hostname has both IPv4 and IPv6 addresses, the correct RR is chosen by the current RR type.
This commit is contained in:
theq86 2018-01-23 19:43:11 +01:00 committed by Franco Fichtner
parent 38e1924209
commit c6fbdd45fc

View file

@ -653,8 +653,21 @@ class updatedns
/* Get IP for your hostname in Route 53 */
if (false !== ($a_result = SearchRecords($records['ResourceRecordSets'], "$hostname"))) {
$OldTTL=$a_result[0][TTL];
$OldIP=$a_result[0][ResourceRecords][0];
/**
* if hostname for ipv4 and ipv6 is the same, a_result contains more than 1 item
* we need to get the item that corresponds to the record type
*/
$oldTTLResult = null;
$oldIPResult = null;
foreach ($a_result as $resultItem) {
if ($RecordType === $resultItem['Type']) {
$oldTTLResult = $resultItem[TTL];
$oldIPResult = $resultItem[ResourceRecords][0];
}
}
$OldTTL=$oldTTLResult;
$OldIP=$oldIPResult;
} else {
$OldIP="";
}