mirror of
https://github.com/opnsense/plugins.git
synced 2026-02-03 20:40:37 -05:00
net/frr: Fix STATIC template interface issue, use isEmpty() in validation (#5019)
* net/frr: Fix STATIC template interface issue, use isEmpty() in validation * Properly safeguard optional parameters
This commit is contained in:
parent
68505ed357
commit
355309551b
2 changed files with 15 additions and 4 deletions
|
|
@ -48,7 +48,7 @@ class STATICd extends BaseModel
|
|||
continue;
|
||||
}
|
||||
$key = $route->__reference;
|
||||
if (!empty((string)$route->network) && !empty((string)$route->gateway)) {
|
||||
if (!$route->network->isEmpty() && !$route->gateway->isEmpty()) {
|
||||
$net_proto = str_contains($route->network, ':') ? 'inet6' : 'inet';
|
||||
$gw_proto = str_contains($route->gateway, ':') ? 'inet6' : 'inet';
|
||||
if ($net_proto != $gw_proto) {
|
||||
|
|
@ -57,10 +57,10 @@ class STATICd extends BaseModel
|
|||
);
|
||||
}
|
||||
}
|
||||
if (empty((string)$route->gateway) && empty((string)$route->interfacename)) {
|
||||
if ($route->gateway->isEmpty() && $route->interfacename->isEmpty()) {
|
||||
$messages->appendMessage(
|
||||
new Message(
|
||||
gettext("When no interface is provided, at least a gateway must be offered"),
|
||||
gettext("Either an interface or a gateway is required."),
|
||||
$key . ".gateway"
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,18 @@
|
|||
{% if not helpers.empty('OPNsense.quagga.static.enabled') %}
|
||||
{% for route in helpers.toList('OPNsense.quagga.static.routes.route') %}
|
||||
{% if route.enabled == '1' %}
|
||||
{% if ':' in route.network %}ipv6{% else %}ip{% endif %} route {{ route.network }} {{ route.gateway|default('')}} {{ helpers.physical_interface(route.interfacename) }}
|
||||
{%- if ':' in route.network %}
|
||||
ipv6
|
||||
{%- else %}
|
||||
ip
|
||||
{%- endif %}
|
||||
route {{ route.network }}
|
||||
{%- if route.gateway %}
|
||||
{{ route.gateway}}
|
||||
{%- endif %}
|
||||
{%- if route.interfacename %}
|
||||
{{ helpers.physical_interface(route.interfacename) }}
|
||||
{%- endif +%}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue