kernelkit / infix

Linux :yellow_heart: NETCONF = Infix
https://kernelkit.org
GNU General Public License v2.0
52 stars 12 forks source link

nghttp2-asio: resolve numeric IPv6 server address #771

Open sgsx3 opened 2 weeks ago

sgsx3 commented 2 weeks ago

The boost library refuses to resolve a numeric IPv6 host (::1) because its resolver flags are set to 'address_configured' by default. This patch simply runs an additional query in such a case with flags set to 'numeric_host'.

See https://www.boost.org/doc/libs/1_83_0/doc/html/boost_asio/reference/ip__resolver_base.html for more info.

Fixes #751

Description

Checklist

Tick relevant boxes, this PR is-a or has-a:

sgsx3 commented 2 weeks ago

Second attempt, hope the formal stuff is fine now.

Haven't tested this on x86 because I think it's a generic issue. The boost library calls getaddrinfo(3), if AI_NUMERICHOST is not set in hints.ai_flags, then lookup is performed based on nsswitch.conf(5) and hosts(5).

127.0.0.1 works for me but then I would need to change /etc/nginx/restconf.app. When I add ::1 ip6-localhost to /etc/hosts ::1 still doesn't resolve. If I use ip6-localhost it binds to 127.0.0.1, though.

troglobit commented 2 weeks ago

Minor comment on the formals, we update the ChangeLog on all user-facing fixes. In this case it would be great if you could add, to the ### Fixes section of the next release, something like:

- Fix #751: RESTCONF agent crashes on NanoPi R2S when system has no IPv6 address 
  (other than loopback), possibly affects other platforms as well

Btw, it's perfectly OK to force-push to branches connected to a PR, or push follow-up commits. You don't need to create a new PR. Thanks for hanging in there! :smiley:

mattiaswal commented 2 weeks ago

If IPv4 works, but not IPv6, i feel the proper fix is to change rousette to listen on IPv4 (127.0.0.1) for now and change nginx as you describe. IPv6 seems buggy somewhere (boost? nghttp2-asio?)

Thanks for the clarification about the bug! Broken IPv6 resolver (most likely in boost) I can live with.

troglobit commented 2 weeks ago

If IPv4 works, but not IPv6, i feel the proper fix is to change rousette to listen on IPv4 (127.0.0.1) for now and change nginx as you describe. IPv6 seems buggy somewhere (boost? nghttp2-asio?)

Agreed.