sTywin / dyndns53

Implementation of dyndns2 dynamic DNS protocol for AWS Lambda, API Gateway, and Route 53
MIT License
66 stars 25 forks source link

Don't error when updating the zone apex #2

Closed mroch closed 8 years ago

mroch commented 8 years ago

The zone apex (aka root domain) has multiple record sets: A, NS and SOA at least.

For example:

{
    "ResourceRecordSets": [
        {
            "ResourceRecords": [
                {
                    "Value": "192.168.1.1"
                }
            ],
            "Type": "A",
            "Name": "example.com.",
            "TTL": 60
        },
        {
            "ResourceRecords": [
                {
                    "Value": "ns-331.awsdns-41.com."
                },
                {
                    "Value": "ns-1749.awsdns-26.co.uk."
                },
                {
                    "Value": "ns-683.awsdns-21.net."
                },
                {
                    "Value": "ns-1322.awsdns-37.org."
                }
            ],
            "Type": "NS",
            "Name": "example.com.",
            "TTL": 172800
        },
        {
            "ResourceRecords": [
                {
                    "Value": "ns-331.awsdns-41.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"
                }
            ],
            "Type": "SOA",
            "Name": "example.com.",
            "TTL": 900
        }
    ]
}

It was querying two record sets and assuming both were A records, which I don't think is possible. The Route 53 UI errors if I try to create two A records with the same name, at least. So, not sure what the intention was there.

Instead, this queries one record, and errors if it isn't an A record. Since the query starts at A records, it'll find the one and only A record if it exists.

sTywin commented 8 years ago

Thanks, that's definitely cleaner :)