Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin_helper: Allow TLS to use keep-alive socket option #3308

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/fluent/plugin_helper/socket_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def socket_option_validate!(protocol, resolve_name: nil, linger_timeout: nil, re
end
end
if send_keepalive_packet
if protocol != :tcp
raise ArgumentError, "BUG: send_keepalive_packet is available for tcp"
if protocol != :tcp && protocol != :tls
raise ArgumentError, "BUG: send_keepalive_packet is available for tcp/tls"
end
end
end
Expand Down
10 changes: 8 additions & 2 deletions test/plugin_helper/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,13 @@ class Dummy < Fluent::Plugin::TestBase
assert_raise(ArgumentError.new("BUG: backlog is available for tcp/tls")) do
@d.__send__(m, :myserver, PORT, proto: proto, backlog: 500){|x| x }
end
assert_raise(ArgumentError.new("BUG: send_keepalive_packet is available for tcp")) do
end

data(
'server_create udp' => [:server_create, :udp],
)
test 'raise error if tcp/tls send_keepalive_packet option is specified for udp' do |(m, proto)|
assert_raise(ArgumentError.new("BUG: send_keepalive_packet is available for tcp/tls")) do
@d.__send__(m, :myserver, PORT, proto: proto, send_keepalive_packet: true){|x| x }
end
end
Expand Down Expand Up @@ -1300,7 +1306,7 @@ def assert_certificate(cert, expected_extensions)

test 'can accept all keyword arguments valid for tcp/tls server' do
assert_nothing_raised do
@d.server_create_tls(:s, PORT, bind: '127.0.0.1', shared: false, resolve_name: true, linger_timeout: 10, backlog: 500, tls_options: @tls_options) do |data, conn|
@d.server_create_tls(:s, PORT, bind: '127.0.0.1', shared: false, resolve_name: true, linger_timeout: 10, backlog: 500, tls_options: @tls_options, send_keepalive_packet: true) do |data, conn|
# ...
end
end
Expand Down