From efd9d8455de7275966004ad7535575a39c7d892f Mon Sep 17 00:00:00 2001 From: Frank Wall Date: Wed, 18 May 2016 23:54:22 +0200 Subject: [PATCH] net/haproxy: more safeguarding in template code --- .../templates/OPNsense/HAProxy/haproxy.conf | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf index 51b6f4a12..f287f9779 100644 --- a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf +++ b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf @@ -482,7 +482,7 @@ global {% do logging.append(OPNsense.HAProxy.general.logging.facility) %} {% do logging.append(OPNsense.HAProxy.general.logging.level) if OPNsense.HAProxy.general.logging.level|default("") != "" %} log {{logging|join(' ')}} -{% if OPNsense.HAProxy.luas.lua is defined %} +{% if helpers.exists('OPNsense.HAProxy.luas.lua') %} # lua scripts {% for lua in helpers.toList('OPNsense.HAProxy.luas.lua') %} {% if lua.enabled == '1' %} @@ -497,25 +497,27 @@ global {# DEFAULTS #} {# ############################### #} +{% if helpers.exists('OPNsense.HAProxy.general.defaults') %} defaults log global -{% if OPNsense.HAProxy.general.defaults.redispatch|default("") != "" %} +{% if OPNsense.HAProxy.general.defaults.redispatch|default("") != "" %} option redispatch {{OPNsense.HAProxy.general.defaults.redispatch|replace("x", "")}} -{% endif %} -{% if OPNsense.HAProxy.general.defaults.maxConnections|default("") != "" %} +{% endif %} +{% if OPNsense.HAProxy.general.defaults.maxConnections|default("") != "" %} maxconn {{OPNsense.HAProxy.general.defaults.maxConnections}} -{% endif %} -{% if OPNsense.HAProxy.general.defaults.timeoutClient|default("") != "" %} +{% endif %} +{% if OPNsense.HAProxy.general.defaults.timeoutClient|default("") != "" %} timeout client {{OPNsense.HAProxy.general.defaults.timeoutClient}} -{% endif %} -{% if OPNsense.HAProxy.general.defaults.timeoutConnect|default("") != "" %} +{% endif %} +{% if OPNsense.HAProxy.general.defaults.timeoutConnect|default("") != "" %} timeout connect {{OPNsense.HAProxy.general.defaults.timeoutConnect}} -{% endif %} -{% if OPNsense.HAProxy.general.defaults.timeoutServer|default("") != "" %} +{% endif %} +{% if OPNsense.HAProxy.general.defaults.timeoutServer|default("") != "" %} timeout server {{OPNsense.HAProxy.general.defaults.timeoutServer}} -{% endif %} -{% if OPNsense.HAProxy.general.defaults.retries|default("") != "" %} +{% endif %} +{% if OPNsense.HAProxy.general.defaults.retries|default("") != "" %} retries {{OPNsense.HAProxy.general.defaults.retries}} +{% endif %} {% endif %} {# ############################### #} @@ -766,7 +768,7 @@ backend {{backend.name}} {# STATISTICS #} {# ############################### #} -{% if OPNsense.HAProxy.general.stats.enabled|default("") == "1" %} +{% if helpers.exists('OPNsense.HAProxy.general.stats') and OPNsense.HAProxy.general.stats.enabled|default("") == "1" %} {# # enable local stats #} listen local_statistics bind 127.0.0.1:{{OPNsense.HAProxy.general.stats.port}} @@ -802,4 +804,3 @@ listen remote_statistics # statistics are DISABLED {% endif %} -