Permalink
Browse files

sane defaults in templates now

  • Loading branch information...
1 parent f8a8ae3 commit c91664fecdc9eabb03a23165d8cd2501ffb36bda @voipscout committed May 10, 2012
Showing with 10 additions and 9 deletions.
  1. +6 −6 lib/server.haml
  2. +4 −3 lib/vpnmaker/config_generator.rb
View
@@ -9,22 +9,22 @@ server #{base_ip[:net]} #{base_ip[:mask]}
tls-server
comp-lzo
cipher AES-256-CBC
-crl-verify /etc/openvpn/crl.pem
-\
-- if subnets
+crl-verify #{crl_path}/crl.pem
+
+- unless subnets.empty?
\# subnets.each do
- subnets.each do |net|
route #{net[:net]} #{net[:mask]}
push route #{net[:net]} #{net[:mask]}
-\
-- if bridgednets
+
+- unless bridgednets.empty?
\# bridgednets.each do
- bridgednets.each do |net|
push route #{net[:net]} #{net[:mask]}
\
push "redirect-gateway"
client-to-client
-\
+
user #{user}
group #{group}
- if type == :default
@@ -32,7 +32,8 @@ def server_conf
separator = '-----BEGIN CERTIFICATE-----'
cert = File.read(@dirname + "/server.crt").split(separator).last.insert(0, separator)
{
- :gen_host => Socket.gethostname
+ :gen_host => Socket.gethostname,
+ :crl_path => @mgr.tracker.path
}.merge(@mgr.config[:server]).merge(@runtime_cfg).merge(:key => File.read(@dirname + "/server.key"),
:cert => cert,
:crl => File.read(@dirname + "/crl.pem"))
@@ -41,8 +42,8 @@ def server_conf
def server
haml_vars = server_conf.dup
haml_vars[:base_ip] = ((a = IPAddr.new haml_vars[:base_ip]); {:net => a.to_s, :mask => a.subnet_mask.to_s})
- haml_vars[:bridgednets] = haml_vars[:bridgednets].map {|net| a = (IPAddr.new net); {:net => a.to_s, :mask => a.subnet_mask.to_s}}
- haml_vars[:subnets] = haml_vars[:subnets].map {|net| a = (IPAddr.new net); {:net => a.to_s, :mask => a.subnet_mask.to_s}}
+ haml_vars[:bridgednets] ? (haml_vars[:bridgednets] = haml_vars[:bridgednets].map {|net| a = (IPAddr.new net); {:net => a.to_s, :mask => a.subnet_mask.to_s}}) : (haml_vars[:bridgednets] = Hash.new)
+ haml_vars[:subnets] ? (haml_vars[:subnets] = haml_vars[:subnets].map {|net| a = (IPAddr.new net); {:net => a.to_s, :mask => a.subnet_mask.to_s}}) : (haml_vars[:subnets] = Hash.new)
template = File.read(@mgr.tracker.path + \
"/" + @mgr.config[:site][:template_dir] + \
"/" + 'server.haml')

0 comments on commit c91664f

Please sign in to comment.