Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #451: Adds support for round-robin records to Cloudflare. #454

Merged
merged 3 commits into from
Sep 27, 2023

Conversation

fdcastel
Copy link
Contributor

Fixes #451.

Cloudflare configuration now accepts a Cloudflare identifier in hostname allowing inadyn to update a round-robin dns hostname (a hostname with multiple ip address).

Sample:

provider [email protected] {
   username = "THE_DOMAIN"
   password = "THE_TOKEN"
   hostname = "a2a279c0aa5f48ab964a6ccc4258f020"
   ttl = 60
   proxied = false
}

Changes in source code:

  • expands get_id to json_extract: can extract any property from json (not just id).
  • if hostname looks like a cloudflare id (32 chars and only hex digits) query the dns_records endpoint directly by id.

Related: https://developers.cloudflare.com/dns/manage-dns-records/how-to/round-robin-dns

@troglobit
Copy link
Owner

This is a very prominent provider in Inadyn. You have to add both documentation (man page) and at least one example config for me to consider this for inclusion.

Also, please describe how you have tested this to ensure you have not introduced any regressions to the common use case.

@fdcastel
Copy link
Contributor Author

fdcastel commented Sep 26, 2023

This is a very prominent provider in Inadyn. You have to add both documentation (man page) and at least one example config for me to consider this for inclusion.

Understood. Doing...

Also, please describe how you have tested this to ensure you have not introduced any regressions to the common use case.

Sure!

  • I created a round-robin entry in my Cloudflare domain containing 2 ip addresses.

  • I made 3 different .conf files for inadyn:

    1. Containing hostname = "host.domain.com" (the current way)
    2. Containing hostname = "cloudflare-id-from-first-entry"
    3. Containing hostname = "cloudflare-id-from-second-entry"
  • Ran everything with

    ./src/inadyn -n -1 -f ./rr-1.conf -l debug --force 2> ./log/log1.txt
    ./src/inadyn -n -1 -f ./rr-2.conf -l debug --force 2> ./log/log2.txt
    ./src/inadyn -n -1 -f ./rr-3.conf -l debug --force 2> ./log/log3.txt
  • The first and second command updated the first dns entry.

  • The third command updated the second dns entry.

I fully understand your concern. But, as you can see in the code, the only real change occurs when hostname is made of 32 hex chars.

All other cases are exactly the same without this PR (apart from get_id function name and some minor textual changes in log output).

@fdcastel
Copy link
Contributor Author

Also: I just changed one of my company routers to use a custom build containing this PR. 🐶 🥫

@troglobit
Copy link
Owner

Thank you so much, this will help a lot when/if any issues creep up or users have questions! The code looks very clean and the added man-page update is also clear, awesome!

Just one small final thing, could you add the URL you mentioned above to the code as a comment? Anything helps when going back in time and it's better to have references close at hand rather than having to dig through old closed PRs.

@troglobit
Copy link
Owner

Looks great, thank you for taking the time to help improve the Cloudflare support! ♥️

@fdcastel
Copy link
Contributor Author

Thank you so much, this will help a lot when/if any issues creep up or users have questions!

Sure! Also, I'm willing to help with anything I can. I'm not planning to go anywhere 😉.

Just one small final thing, could you add the URL you mentioned above to the code as a comment? Anything helps when going back in time and it's better to have references close at hand rather than having to dig through old closed PRs.

Done!

Also, I took the liberty to add some links to Cloudflare API documentation for each http request the plugin does.

@fdcastel
Copy link
Contributor Author

A minor: #451 called for CloudFlare and No-IP support.

I implemented only the first one. Due to a recent change in our plans around here we have decided to use only Cloudflare for everything.

@troglobit
Copy link
Owner

A minor: #451 called for CloudFlare and No-IP support.

I implemented only the first one. Due to a recent change in our plans around here we have decided to use only Cloudflare for everything.

That's fine seeing as you're the original reporter 😃👍

@troglobit troglobit merged commit b670b31 into troglobit:master Sep 27, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for round-robin records (one hostname, multiple IP addresses)
2 participants