favonia / cloudflare-ddns

🌟 A small, feature-rich, and robust Cloudflare DDNS updater
Apache License 2.0
747 stars 32 forks source link

Support alternative Cloudflare API token file format #714

Open naanlizard opened 5 months ago

naanlizard commented 5 months ago

Small issue here, other services (letsencrypt and stuff using it) tend to use cloudflare's API key in the form of

# Cloudflare API token used by Certbot
dns_cloudflare_api_token = 0123456789abcdef0123456789abcdef01234567

https://certbot-dns-cloudflare.readthedocs.io/en/stable/

would it be possible to add support for that formatting so I don't need as many files kicking around?

Originally posted by @naanlizard in https://github.com/favonia/cloudflare-ddns/issues/668#issuecomment-2002118821

favonia commented 5 months ago

@naanlizard Thank you. I will have to think about this due to the additional complexity, and this feature might have lower priority on my list (sorry). On the other hand, I wonder if your true concern is the burden to maintain consistency across multiple configuration files, which I deeply sympathize! If so, I think tools like conf might help.

favonia commented 1 month ago

@naanlizard I wonder if you have tried the tool I suggested?

In the meanwhile, I might have come up with a good solution. I wonder if you are okay with writing a regular expression to identify the token? You will need to write a regular expression and the first submatch named token will be used as the API token. For example, the regular expression to use the whole file is

^(?<token>.*)$

Design question: the first config name that comes to my mind is ridiculously long: CF_API_TOKEN_FILE_CONTENT_REGEX

favonia commented 3 weeks ago

@naanlizard Hi, I have been trying various experiments and wonder how you feel about the design. BTW, I think the idea "first submatched named token" is overkill. It should just be "first numbered capture group". So the regular expression to match the whole file is just

^(.*)$

and it should probably be CF_API_TOKEN_REGEX for the whole file.

naanlizard commented 3 weeks ago

I'm sorry to be so quiet here - for the moment I can't play with this, but in a few weeks I'll be redoing one of my sites and can go in depth then!