Skip to content

Commit

Permalink
Merge pull request #3308 from jiping-s/allow-keepalive-tls
Browse files Browse the repository at this point in the history
plugin_helper: Allow TLS to use keep-alive socket option
  • Loading branch information
ashie committed Mar 31, 2021
2 parents d19b706 + 59f2116 commit 2081bf2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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

0 comments on commit 2081bf2

Please sign in to comment.