Skip to content

Commit

Permalink
Adds in the ability to set rcvbuf and sndbuf parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Jan 5, 2015
1 parent 7c1cd80 commit 04871ee
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -372,6 +380,8 @@
$persist_tun = false,
$server_poll_timeout = undef,
$ping_timer_rem = false,
$sndbuf = undef,
$rcvbuf = undef,
) {

include openvpn
Expand Down
18 changes: 18 additions & 0 deletions spec/defines/openvpn_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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').
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions templates/server.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down

0 comments on commit 04871ee

Please sign in to comment.