haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.09k stars 661 forks source link

hjson configuration #2124

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello, I would like to ask whether it would be possible and useful to add support for hjson configuration files. For those who are not familiar with hjson it is a json like format but it also allows comments. Plugin like aliases could benefit from this if someone wants to take notes why is something done the way it is. Hjson has it's own Node.js library it can be found at https://www.npmjs.com/package/hjson. So I guess it should not be very difficult to implement. And it can even replace typical json. Do you think it would be useful? Thank you in advance.

Best regards, PSSGCSim

msimerson commented 7 years ago

I think it'd be useful. hjson is certainly nicer to manually edit than json. We're fairly cautious when introducing dependencies. Maybe add hjson to haraka-config as an optional dependency and a config.ini file that lets one specify the JSON library to use:

[json]
; reader=node
; reader=hjson

Then you create haraka-config/readers/hjson.js and when config.ini.json.reader=hjson, it would use that reader instead.

Aside: for the aliases plugin, on my TODO list is writing a web UI to manage the aliases, with a postmaster@[example.com] authentication mechanism so that users can create aliases within their domains. That would keep humans from mucking in that file.

ghost commented 7 years ago

I have issued a PR ready to be checked, does not support the JSON override yet https://github.com/haraka/haraka-config/pull/30