diff --git a/manifests/server.pp b/manifests/server.pp index ae346933..55c20959 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -273,6 +273,14 @@ # Boolean. Do not start clocking timeouts until a remote peer connects. # Default: false # +# [*sndbuf*] +# Integer, Set the TCP/UDP socket send buffer size. +# Default: undef +# +# [*rcvbuf*] +# Integer, Set the TCP/UDP socket receive buffer size. +# Default: undef +# # === Examples # # openvpn::client { @@ -372,6 +380,8 @@ $persist_tun = false, $server_poll_timeout = undef, $ping_timer_rem = false, + $sndbuf = undef, + $rcvbuf = undef, ) { include openvpn diff --git a/spec/defines/openvpn_server_spec.rb b/spec/defines/openvpn_server_spec.rb index d1b6f38e..39ec1299 100644 --- a/spec/defines/openvpn_server_spec.rb +++ b/spec/defines/openvpn_server_spec.rb @@ -192,6 +192,8 @@ it { should_not contain_file('/etc/openvpn/test_server.conf').with_content(/^server-poll-timeout/) } it { should_not contain_file('/etc/openvpn/test_server.conf').with_content(/^ping-timer-rem/) } + it { should_not contain_file('/etc/openvpn/test_server.conf').with_content(/^sndbuf/) } + it { should_not contain_file('/etc/openvpn/test_server.conf').with_content(/^rcvbuf/) } # OpenVPN easy-rsa CA it { should contain_openvpn__ca('test_server'). @@ -243,6 +245,22 @@ it { should_not contain_openvpn__ca('test_server') } end + context "when altering send and receive buffers" do + let(:params) { { + 'country' => 'CO', + 'province' => 'ST', + 'city' => 'Some City', + 'organization' => 'example.org', + 'email' => 'testemail@example.org', + 'sndbuf' => 393216, + 'rcvbuf' => 393215, + } } + + it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^sndbuf\s+393216$/) } + it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^rcvbuf\s+393215$/) } + end + + context "when RedHat based machine" do let(:params) { { 'country' => 'CO', diff --git a/templates/server.erb b/templates/server.erb index ea0a0026..2ec6134d 100644 --- a/templates/server.erb +++ b/templates/server.erb @@ -63,6 +63,12 @@ push "<%= item %>" <% @route.each do |item| -%> route <%= item %> <% end -%> +<% if @sndbuf -%> +sndbuf <%= @sndbuf %> +<% end -%> +<% if @rcvbuf -%> +rcvbuf <%= @rcvbuf %> +<% end -%> <% if @keepalive != '' -%> keepalive <%= @keepalive %> <% end -%>