Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

WEBRick::HTTPServer creates ipv6only socket for host `::`

未关闭
#99 7 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby

调研方向

从 lib/webrick/utils.rb 第 60 行开始,使用 Host: '::' 的 WEBrick::HTTPServer 示例重现该问题。将其套接字行为与 TCPServer.new('::', 8080) 进行比较,并检查 ss -tlne 中的 v6only 和双栈监听情况。在受影响的 Linux 系统上,WEBrick 的 IPv6 通配主机对 IPv4 和 IPv6 流量的行为符合预期,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Ruby
星标
327
派生
113
平均合并
4 小时 2 分钟
30 天内合并 PR
1

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/webrick 的其他 Issue

查看 ruby/webrick 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。