Hello, I'm trying out hledger (considering migrating from GnuCash) and found lack of IPv6 support in hledger-web's server to be an issue.
It's possible that the changes are minima, but I understand that everything is work :-). Just opening to document it.
Cheers and thank you.
Further information:
> uname -oprb
FreeBSD 13.0-CURRENT amd64 5b8f656016fa216bb99a3853141b8d4d9eb9b6de
> hledger-web --version
hledger-web 1.16.1
> hledger-web --serve --host '::1' --port 8080
hledger-web: --host requires an IP address, not "::1" (use -h to see usage)
Thanks for the report.
I'll try to solve this issue.
The error itself comes from the function checkWebOpts, where the value of the host option is checked against ".0123456789".
This is basically a whitelist for allowed characters, but it does not prevent hosts like 999.999.999.999, which will crash when Network.Socket.getAddrInfo uses it.
Adding : to the whitelist allows ::1 as host, but browser access won't work, as IPv6 addresses need to be surrounded by brackets like http://[::1]/.
Calling hledger-web with the modified whitelist like this:
hledger-web --host ::1 --base-url=http://[::1]:5000
gives a simple workaround, but still launches the wrong URL in the browser.
Basically, to solve this issue, I'd try the following steps:
: or checking the address with other means)As a first step, I'll just add : to the whitelist and check for that to change the base-url, but it might be sane to use something that completely validates the IP address.
I'll open a PR as soon as I've made progress.
Most helpful comment
Thanks for the report.