favonia / cloudflare-ddns

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

Notification of IP changes and errors #532

Closed obstrux closed 2 months ago

obstrux commented 1 year ago

Ex. Email

favonia commented 1 year ago

@alipay404 Thanks for the feedback. You can set up Healthchecks and put the ping URL into HEALTHCHECKS. This way, you can receive emails (or SMS messages, etc.) when there's an error. If you are looking for something else, please let me know. 🙂

obstrux commented 1 year ago

@alipay404 Thanks for the feedback. You can set up Healthchecks and put the ping URL into HEALTHCHECKS. This way, you can receive emails (or SMS messages, etc.) when there's an error. If you are looking for something else, please let me know. 🙂

Thanks

obstrux commented 1 year ago

@alipay404 Thanks for the feedback. You can set up Healthchecks and put the ping URL into HEALTHCHECKS. This way, you can receive emails (or SMS messages, etc.) when there's an error. If you are looking for something else, please let me know. 🙂

How do I get an IP change

favonia commented 1 year ago

@alipay404 The current design does not notify you of IP changes because that's not an "error." (It's working as expected.) Let me re-open this issue because you seem to be requesting a new feature.

favonia commented 1 year ago

@alipay404 Hi, because you are asking for a new feature, I wonder if you could possibly provide more details. In particular, when do you want to receive notifications and what should be the messages? If you have seen this feature in another product, I can take a look. tl;dr: I need more details.

favonia commented 1 year ago

@alipay404 I checked GoDNS and they only mentioned "IP changes". Do you also want to get notifications when something's wrong (e.g., when the updater fails to get the public IP)? Also, do you have a preference between webhooks (you specify the URL and the content) and something like shoutrrr (which might increase the image size but offers direct support of many services)? It is not difficult to implement any of these but I want to implement something that addresses your need (if I choose to implement it after checking the technical detail). 😀

@bartclone if you are willing, any input will be helpful to move this issue forward. Thanks!

bartclone commented 1 year ago

@bartclone if you are willing, any input will be helpful to move this issue forward. Thanks!

Sure. A IP change could have effects, that an user wants to be notified of. So, yes, an interface to a [notification API service] like shoutrr, or Apprise / its API would be nice.

favonia commented 1 year ago

A IP change could have effects, that an user wants to be notified of.

@bartclone Thanks for the feedback. Do you want to get notifications when something went wrong (e.g., not being able to get the IP)?

PS: I would like to check how large the images would be after linking shoutrrr.

bartclone commented 1 year ago

A IP change could have effects, that an user wants to be notified of.

@bartclone Thanks for the feedback. Do you want to get notifications when something went wrong (e.g., not being able to get the IP)?

PS: I would like to check how large the images would be after linking shoutrrr.

Maybe introduce a debug level 1-6, to control which messages are sent out? Like

favonia commented 1 year ago

@bartclone Thanks for the suggestion. The internal logging system already has levels. However, the logs are only optimized for the terminal view and are imperfect for notifications. (E.g., some messages are intentionally split into multiple lines, but they should be sent as one message to, say, Discord, and the Healthchecks pinning uses a different format.) To have the best UI/UX, I believe one would have to manually adjust messages for different targets. I also want a clean configuration interface where every option should ideally have a reasonable meaning independent of other options. I'm worried that it is not immediately clear whether the log level should also affect the messages sent to Healthchecks and the terminal (and maybe replace the option QUIET). I'm hoping to avoid non-trivial interactions between options.

Anyways, to confirm, I believe you don't expect to receive notifications other than (1) IP changes and (2) all kinds of "errors". Is that correct? It might take me a while to go through all the errors the updater is reporting right now, but technically I don't think supporting this is difficult other than the size bloat due to the shoutrrr library. (I also welcome PRs but usually I implemented something before someone did it.)

favonia commented 1 year ago

@bartclone Sorry for the slow progress. Do you think you will ever need to notify multiple targets?

favonia commented 1 year ago

@alipay404 @bartclone I played with shoutrrr a bit and the resulting image (4.x MiB) is a bit larger than I hoped for, but I could be convinced otherwise. I wonder if you are already using a popular notification system, for example, gotify, ntfy, or online services that support notification redirection, such as novu, courier, magicbell, or something like that? It's much easier to support a single service.

bartclone commented 1 year ago

Sorry for the late reply, holidays kicked in ;). I myself use PushOver, but then again: so many choices, therefor I proposed the broader solution (lots of services to choose). These days harddiskspace is cheap - although 4Mb is ofcourse large when for example used in IoT/edge.

favonia commented 1 year ago

@bartclone I admit that it's more like an intellectual exercise for me to create the smallest but maintainable DDNS updater with all the features I like. This project was my way of learning Go. I'd like to think through the alternatives---last time I managed to save some bits and improve usability by handcrafting my own parser.

In any case, I suppose you don't need the updater to notify multiple places. Is that correct?

favonia commented 1 year ago

@bartclone I think I'm about to give up finding alternative designs. There are two things to decide and one major difficulty to worry about. The two things are:

  1. The environment variable should be SHOUTRRR, right?
  2. The exact messages to send out---in particular, should the tool send out IP changed to X from Y instead of just IP changed to X? Is the additional information useful? The tricky part of implementing this is that the original DNS records could be a mess and I'd like to know whether it's worthwhile to come up with a good description for each case.

The major difficulty is that this feature would take me a while (if I want to add all the test cases and whatnot).

bartclone commented 1 year ago

Or maybe just use the ability to a use the API of Apprise. I took a quick look but Shoutrrr does not seem to provide that? Apprise also provides a built-in Configuration Manager ...

Using an external service like Apprise (or maybe Shoutrrr?) would limit your codebase. Ofcourse still needed to define how to call the service, for example running in a another container. That would require URL, API (key for the service), etc etc

On loglevels, see https://sematext.com/blog/logging-levels/ It's always a question what severity/level (and to what extend) a specific event has :). Let's find out.

favonia commented 1 year ago

@bartclone Thank you!

  1. I feel running another server instead of including a library might be a bit too much for the end user. :sweat_smile: I'll think about it, though.
  2. No, I'm not talking about logging levels. I am talking about the actual messages to be sent. There's already a logging system for outputting messages. However, it is not optimal to recycle logging (recording what the updater is doing) for notifications (telling users about something they may have to act on soon). There are important things that should not be notifications (e.g., whether QUIET mode is used). Logging and notification serve different purposes and messages should be tailored. The question here is whether the old IP should be mentioned.
favonia commented 11 months ago

Unfortunately it is difficult for me to spend enough time on this issue in this semester. PRs are welcome. It is not inherently hard to integrate shoutrrr, just lots of testing and checking. I will leave this issue open at least for now. Sorry about this.

favonia commented 9 months ago

Update: for people who want to track my (slow) progress, you can subscribe to #632. Otherwise, I will just close this issue when I feel the feature is ready for broader audience. :grin:

favonia commented 2 months ago

@obstrux @bartclone Progress report: I have implemented experimental support of shoutrrr but right now it has bugs: strangely, messages cannot be sent to pushover. If you feel adventurous, you could use SHOUTRRR=<shoutrrr url> with the Docker tag edge. It is still NOT working and I am debugging it.

favonia commented 2 months ago

Update: the bug was fixed! However, only the failure to detect IP addresses or update DNS records is currently notified. I'm working on other errors:

favonia commented 2 months ago

This is done now, pending updates on documentation.

favonia commented 2 months ago

:tada: The new feature was released with 1.12.0. Please try it out!