hefur icon indicating copy to clipboard operation
hefur copied to clipboard

failed to listen on the port 6969 with ipv6

Open maswan opened this issue 4 years ago • 1 comments

When running hefurd on a new host with -ipv6 I get the error message: "hefur: fatal: failed to listen on the port 6969: Cannot assign requested address". Other processes don't have any problems listening to the port, for example nc -6 -l -p 6969 (when hefurd isn't running).

OS: Ubuntu 20.04, amd64. Hefur as from git today.

maswan avatar Jul 14 '21 12:07 maswan

If invoked as hefurd -ipv6 it will fail because the code invokes inet_pton with AF_INET6 but the default value for the command line option -bind-addr is "0.0.0.0". https://github.com/abique/hefur/blob/5136250a567a290f41507f607d2c590f1a14eb2f/hefur/http-server.cc#L51

According to man pages inet_pton docs the function when in AF_INET6 mode explicitly only handles addresses in IPv6 format, documenting in the BUGS section that dotted octet notation needs to be IPv4-mapped in IPv6 format.

AF_INET6 does not recognize IPv4 addresses. An explicit IPv4-mapped IPv6 address must be supplied in src instead.

A workaround is to specify -bind-addr :: when launching the daemon. As for why/how this behaviour has changed, my guess would be library improvements.

zao avatar Sep 20 '21 11:09 zao