Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#99 コメント 7 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/webrick のほかの issue

ruby/webrick の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。