WEBRick::HTTPServer creates ipv6only socket for host `::`
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 327
- Forks
- 112
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
The IPv6 host :: is kind of analogous to the IPv4 address 0.0.0.0, however it should usually (depending on the OS) listen for traffic coming from IPv4 and IPv6 addresses, unless specified differently by the OS.
However, i have observed that across different linux distros i have tried (manjaro, arch, debian), WEBRick will open its socket in ipv6-only mode.
I assume that the reason is this line as using the Socket.tcp_server_sockets function manually leads to the same result.
However, e.g. using the TCPServer from the socket stdlib opens a socker that's not in ipv6-only mode.
Sample code i have used:
require 'webrick'
server = WEBrick::HTTPServer.new Port: 8080, Host: '::', DocumentRoot: '~/'
trap 'INT' do
server.shutdown
end
server.start
I have tested this with webrick 1.7.0 on ruby 3.1.1 and on ruby 2.6.3, both yielding the same result.
I have observed the mode using ss -tlne, where the local address is shown as [::]:8080, which indicates ipv6-only mode in ss, while it should be *:8080 in non-ipv6-only mode.
It also says v6only:1 in the process description, while it should say v6only:0.
Also here's the sample code using TCPServer that correctly opens the socket:
require 'socket'
server = TCPServer.new('::', 8080)
loop do
client = server_socket.accept
client.puts 'hello'
client.close
end
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at lib/webrick/utils.rb line 60 and reproduce the issue with the WEBrick::HTTPServer sample using Host: '::'. Compare its socket behavior with TCPServer.new('::', 8080), checking ss -tlne for v6only and dual-stack listening. Done means WEBrick's IPv6 wildcard host behaves as expected for IPv4 and IPv6 traffic across the affected Linux systems.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100