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 11, 2015
1 parent 353cd6b commit 4c86224
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 0 deletions.
10 changes: 10 additions & 0 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@
# [*down*]
# String, Script which we want to run when openvpn client is disconneting
#
# [*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 @@ -157,6 +165,8 @@
$setenv_safe = {},
$up = '',
$down = '',
$sndbuf = undef,
$rcvbuf = undef,
) {

if $pam {
Expand Down
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
12 changes: 12 additions & 0 deletions spec/defines/openvpn_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,16 @@
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^cipher\s+BF-CBC$/)}
end

context "setting all of the parameters" do
let(:params) { {
'server' => 'test_server',
'sndbuf' => 393216,
'rcvbuf' => 393215,
} }

it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^sndbuf\s+393216$/)}
it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^rcvbuf\s+393215$/)}

end

end
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' => '[email protected]',
'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/client.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ cipher <%= @cipher %>
mute-replay-warnings
<% end -%>
ns-cert-type server
<% if @sndbuf -%>
sndbuf <%= @sndbuf %>
<% end -%>
<% if @rcvbuf -%>
rcvbuf <%= @rcvbuf %>
<% end -%>
verb <%= @verb %>
mute <%= @mute %>
<% if @pam || @authuserpass -%>
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 4c86224

Please sign in to comment.