0xERR0R / blocky

Fast and lightweight DNS proxy as ad-blocker for local network with many features
https://0xERR0R.github.io/blocky/
Apache License 2.0
4.65k stars 205 forks source link

[Feature Request] Automatically reload config #462

Open adamsewell opened 2 years ago

adamsewell commented 2 years ago

A feature I'd love to have is the ability for blocky to automatically reload it's configuration from time to time or a configurable time period. For example, if I add another client, I'd like to have blocky pick that up rather than restart the docker instance.

0xERR0R commented 2 years ago

Similar to #7 . There are some challenges:

If reload is triggered by user (by restarting the application manually), the problem can be fixed immediately, but if reload happens automatically it can lead in a total crash. Since DNS is a critical part of the network infrastructure, there must be a safety net.

Please read my concerns in the linked issue. Maybe you have some ideas how to solve them?

adamsewell commented 2 years ago

I swear I searched for this before I posted haha.

So in my opinion, some sort of validation would be needed here. Something similar to the nginx -t option. If blocky detects that there is a error in the configuration, it would continue to run the existing config in memory but if it passes validation then it would reload.

Edit: I'm not familiar with Go, but I did a quick search and it looks like the go-yaml library has a built-in validation function. Does the YAML library you use have a function like that? If so, that's where I'd start. Make sure it's a valid config.

0xERR0R commented 2 years ago

It validates if YAML has correct syntax and if some custom types (like upstreams) have correct format. It would probably also make sense only reload a part of configuration attributes (for example, changing of listening port must require restart, but defining a new blocking list not).

adamsewell commented 2 years ago

I would be good with that. The most common use case for me would be to add new entries in clientGroupsBlock and blackLists/whiteLists or modify existing entries.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

kwitsch commented 1 year ago

While implementing #375 the whole config loading is done through koanf. Auto loading could be reevaluated as followup as koanf provides a watch functionality.

ViViDboarder commented 1 year ago

Even without watching, reloading on SIGHUP would be useful and provide some mitigation on config loading failure as the signal sender could be expected to be watching. It would be similar to a full restart but, ideally, without (or will less) downtime.