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

AAAA / ipv6 support #15

Closed anotherZero closed 4 years ago

anotherZero commented 7 years ago

I am thinking about implementing AAAA / ipv6 support for this package but I'm not sure how best to go about it.

After research I'm finding that the current URL used for getting IP address is returning ipv4 only. (seems to be a current limitation with https://api.ipify.org. Supposedly fixed, but seems to be not functioning now)

Some thoughts to get the ball rolling --

Assertions

Specific Questions

lmammino commented 7 years ago

Hello @anotherZero, Thanks for the idea and for the elaborate proposal.

At a first glance I am not sure if I want to go for a "smart" approach or for a configuration oriented one (user needs to explicitly define the protocol he wants to use and that will determine the execution flow of the application).

If we use this approach we can easily add the SMART option later on and use some technique to determine wether an IPv6 or an IPv4 is available and which one has higher priority in case they are both available.

So if we go in this direction, the new config file might become something like this:

{
  "apiKey": "",
  "secret": "",
  "domain": "example.com",
  "records": [{"protocol": "ipv6|ipv4|smart", "name": "mysubdomain", "ttl": 600}]
}

Notice that I am replacing the key type with protocol, which could have ipv6, ipv4 or smart as possible values.

As an alternative, we could keep the type key and detect the protocol from the value:

This is probably better for backward compatibility.

Anyway I think this still requires a bit of thinking and maybe some experimentation in order to be able to come up with a good solution.

Do you have any plan to start playing with it?

anotherZero commented 7 years ago

I like the idea of a smart option. Don't forget about other possible records that one might want to continue managing such as CNAME or MX (which might better lend itself to keeping the type key.

I am interested in working on this but I have to admit that I haven't worked with bluebird or es6 much so there's a bit of a learning curve. It might be a bit before I could produce anything.

lmammino commented 7 years ago

Regarding CNAME records, I don't think this utility can really be useful (as previously discussed here).

For MX records, it is a very similar situation. With MX records you won't be specifying IP addresses as values but other domain names (which may refer either A, AAAA or CNAME records).

An example here (from this page):

Host/Domain Address/Mail Server/MX Entries/Value Priority
@ mx.zoho.eu. 10
@ mx2.zoho.eu. 20
@ mx3.zoho.eu. 50

As far as I am aware you can't specify IP addresses in the Mail Server column.

With this in mind would you prefer to go with a type approach or with the protocol one?

Personally, at the moment, I am more inclined towards the type one.

anotherZero commented 7 years ago

I realize that there is a more limited usefulness for other types of records, but I am currently using this utility to set about a dozen records when deploying a new server.

I use saltstack to write out a config.json and run godaddy-dns once. It's kind of nice to have all of the dns entry calls bundled into a single package as opposed to having the ip related ones done by this package, and the cname/mx done somewhere else.

That being said, I agree that type is the correct parameter to use :)

lmammino commented 7 years ago

That's an interesting use case I haven't thought before.

I have to assume that for non-ip based records you just set the data option directly in the config value.

Something like the following config:

{
  "apiKey": "",
  "secret": "",
  "domain": "example.com",
  "records": [
    {
       "type": "CNAME",
       "name": "mysubdomain",
       "ttl": 600,
       "data": "anotherdomain.com"
     }
  ]
}

I wonder if that's something we should explicitly mention in the documentation.

Also, I am curious to have an example of config from your current use case.

anotherZero commented 7 years ago

I can provide an example config like the one I'm using for this use case. In this case, I'm just filling in the ip addresses as well because ipv6 isn't supported yet and I'm generating the config.json anyway.

{
  "apiKey": "",
  "secret": "",
  "domain": "mydomain.com",
  "records": [
    { "type": "A", "name": "sub1", "ttl": 43200, "data": "171.95.182.198" },
    { "type": "A", "name": "smelt.sub1", "ttl": 43200, "data": "171.95.182.198" },
    { "type": "AAAA", "name": "sub1", "ttl": 43200, "data": "2001:4860:4860::8888" },
    { "type": "AAAA", "name": "smelt.sub1", "ttl": 43200, "data": "2001:4860:4860::8888" },
    { "type": "CNAME", "name": "mail.sub1", "ttl": 172800, "data": "mail.otherdomain.com" },
    { "type": "MX", "name": "sub1", "ttl": 172800, "priority": 10, "data": "mail.sub1.mydomain.com" },
    { "type": "MX", "name": "smelt.sub1", "ttl": 172800, "priority": 10, "data": "smelt.sub1.mydomain.com" }
  ]
}
lmammino commented 7 years ago

Thanks a million @anotherZero! This is very helpful for me to figure out other use cases and possible improvements.

atkulp commented 5 years ago

Was any progress made on AAAA records? I'd be happy to help contribute but I don't want to repeat any work.

anotherZero commented 4 years ago

I think this has been implemented. Closing
thanks @lmammino