DNSCrypt / dnscrypt-proxy

dnscrypt-proxy 2 - A flexible DNS proxy, with support for encrypted DNS protocols.
https://dnscrypt.info
ISC License
11.31k stars 1.01k forks source link

Split config files #63

Closed thuantran closed 6 years ago

thuantran commented 6 years ago

Hi Frank,

Just updated my installer script for asuswrt-merlin users with rc, and it's working great. I'm considering parsing toml from linux shell, the normal variable and array are fine but it's too much of a hassle with tables and you keep adding more lol.

So I wonder if it would be better if you split your configuration file into multiple files for these tables by purpose or whatever make sense to you. That would make it easier on me and on my users to migrate settings between version.

Best regards, Thuan

jedisct1 commented 6 years ago

Reading TOML (or even JSON or any structured format) from shell scripts sounds fragile.

Tools such as tomlq and rq are great for that purpose, but requiring them is probably overkill if they aren't already present in a minimal Linux distribution.

Having everything in a single file is convenient. If you add a static definition, you can easily copy/paste the name to the resolver_names above; all is in the same place.

I'm not sure that splitting it into multiple files would make parsing in shell easier. Nested values such as the weekly schedules will still be as tricky to parse.

If you parse the file line by line, you can spot the different sections with something like

egrep '^\s*\[[^.]+\]'
thuantran commented 6 years ago

I agree. That's why I only want to parse and migrate the values for global settings. Having other "advanced settings" in their respective files then I simply can keep these files between installation for my users, dodging the parsing issue with more complicated data types out of the way and only tackling them as necessary :).

Tallefer commented 6 years ago

A bit off-topic, but since this is also a matter of splitting config and I wasn't sure if this is worth of opening another issue, but I think it is worth mentioning before release: @jedisct1 Would you consider renaming config files for distribution with names like default_dnscrypt-proxy.toml or just _dnscrypt-proxy.toml? Same for forwarding-rules.txt and blacklist.txt. And then recreating entries missing from "main" configs on launch? Reason being — if the list of entries will keep changing in the future, it will make automatic updating via downloading and unpacking too dangerous if not impossible. And manual updating is dangerous too — you are tempted to choose "Overwrite? Yes to all" every time you are doing the update when there are default configs included. Optional behavior: if you are more for the "strict" approach, that is — to just stop the program from execution if config is corrupted (not sure if this is possible to verify now though), then maybe to add a command like -reconstruct to rewrite user config from default one. Or maybe even hardcode all the entries into the binary to prevent defaults from being corrupted?

jedisct1 commented 6 years ago

@Tallefer Oh indeed, yes, that's a very good idea.

Gonna rename the example files right away.