IPv6 support
renich opened this issue · comments
Description
Kemal should be able to listen over IPv6.
If i set it up like this:
Kemal.config.host_binding = "::/0"
It should listen on all IPv6 ranges.
Steps to Reproduce
- Create a brand new project
- Setup host_binding to
::/0
- Watch it fail.
Expected behavior: [What you expect to happen]
Kemal should be listening on all IPv6 ranges.
Actual behavior: [What actually happens]
It fails:
[renich@introdesk myapp]$ crystal run src/myapp.cr
Unhandled exception: Hostname lookup for ::/0 failed: No address found (Socket::Addrinfo::Error)
from /usr/share/crystal/src/socket/addrinfo.cr:176:9 in 'initialize:reuse_port'
from /usr/share/crystal/src/socket/tcp_server.cr:34:3 in 'new:reuse_port'
from /usr/share/crystal/src/http/server.cr:211:18 in 'bind_tcp'
from lib/kemal/src/kemal.cr:52:7 in 'run'
from lib/kemal/src/kemal.cr:16:5 in 'run'
from lib/kemal/src/kemal.cr:15:3 in 'run'
from src/myapp.cr:9:1 in '__crystal_main'
from /usr/share/crystal/src/crystal/main.cr:115:5 in 'main_user_code'
from /usr/share/crystal/src/crystal/main.cr:101:7 in 'main'
from /usr/share/crystal/src/crystal/main.cr:127:3 in 'main'
from /lib64/libc.so.6 in '??'
from /lib64/libc.so.6 in '__libc_start_main'
from /home/renich/.cache/crystal/crystal-run-myapp.tmp in '_start'
from ???
Reproduces how often: [What percentage of the time does it reproduce?]
All the time.
Versions
Crystal 1.3.2 (2022-01-18)
LLVM: 13.0.0
Default target: x86_64-redhat-linux-gnu
Running on Fedora 35.
OK, it seems: Kemal.config.host_binding = "::"
works fine. It doesn't accept the mask /0
. I dunno how intuitive that is though.
Working example:
require "kemal"
get "/" do
"Hello, world!"
end
Kemal.config.host_binding = "::"
Kemal.run
I understand the reason your original approach failed is that ::/0
technically isn't a single address, it's an address range. The IP address stack doesn't recognize this.
Yes, correct. I was hoping to be able to listen to an address range probably. thank you for explaining, @straight-shoota. :D