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

Adds in the ability to set rcvbuf and sndbuf parameters. #116

Merged
merged 1 commit into from
Jan 11, 2015
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' => '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/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