lmammino / godaddy-dns

A Node.js script to programmatically update GoDaddy DNS records
https://lmammino.github.io/godaddy-dns/
MIT License
78 stars 21 forks source link

Got an error when using "@" #7

Closed nstuyvesant closed 8 years ago

nstuyvesant commented 8 years ago

Here's the relevant line from my JSON: "records": [{"type": "A", "name": "@", "ttl": 600}]

$ godaddy-dns [Sat May 21 2016 13:40:35 GMT-0400 (EDT)] Failed request to GoDaddy Api Another record with the same attributes already exists

When I changed "@" to "foo", it created the A record with no problem.

Also noticed that if I change the IP of "foo" on GoDaddy's website to something bogus then re-rerun godaddy-dns, it does not update the IP address and there is no error message.

lmammino commented 8 years ago

Hey @nstuyvesant , thanks for submitting this issue.

I honestly never tried to use the '@' notation. I assumed it to just work, but maybe there's some protection mechanism from GoDaddy or they simply use something else to reference to the main domain (maybe just an empty string?). I need to investigate more on this side.

For what regards your second point, It's probably the IP cache kicking in and avoiding to send the request to GoDaddy. So just to make this a little bit cleaner (the documentation maybe goes too short on this part), let me explain what happens exactly behind the scenes:

When you use the command the first time, it detects the public IP of your machine and it stores that into a temp file (you can see the default location of this file by using the --help option). The next time you invoke the command it compares your current public IP with your cached one. If it is the same, it assumes there's no need to update the DNS, so the request to GoDaddy API isn't triggered at all. At this stage, if you want to force a request anyway, you can either delete the cache file or use the --ipfile option to specify a different cache file.

I should probably change something here to allow the refresh mechanism and the IP cache to be more understandable and easy to use.

I have three options in mind:

At this stage I am more inclined to implement the third option, but feel free to let me know your thoughts on this!