net/haproxy: more safeguarding in template code

This commit is contained in:
Frank Wall
2016-05-18 23:54:22 +02:00
parent f1d95e5609
commit efd9d8455d
@@ -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 %}