From c6fbdd45fc4f1c2f5da804d735e1855bc6afdd27 Mon Sep 17 00:00:00 2001 From: theq86 Date: Tue, 23 Jan 2018 19:43:11 +0100 Subject: [PATCH] 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. --- .../etc/inc/plugins.inc.d/dyndns/phpDynDNS.inc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dns/dyndns/src/etc/inc/plugins.inc.d/dyndns/phpDynDNS.inc b/dns/dyndns/src/etc/inc/plugins.inc.d/dyndns/phpDynDNS.inc index b92fc6647..e4839f8a5 100644 --- a/dns/dyndns/src/etc/inc/plugins.inc.d/dyndns/phpDynDNS.inc +++ b/dns/dyndns/src/etc/inc/plugins.inc.d/dyndns/phpDynDNS.inc @@ -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=""; }