WEBRick::HTTPServer creates ipv6only socket for host `::`
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- ruby
- 领域
- backend, networking
调研方向
从 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
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/webrick 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 45/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
simp/pupmod-simp-simp#395 ·
-
难度 2/5 1-3 小时 新手友好度 80/100
simp/pupmod-simp-rsyslog#219 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
simp/pupmod-simp-pupmod#256 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
simp/pupmod-simp-sudo#150 ·
-
难度 1/5 1 小时以内 新手友好度 90/100