mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 00:54:41 +00:00
Traffic shaper, add enabled flag to rules, closes https://github.com/opnsense/core/issues/2426
This commit is contained in:
parent
3c73da4d46
commit
26ee607a31
@ -247,7 +247,8 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
return $this->searchBase(
|
||||
"rules.rule",
|
||||
array("interface", "proto", "source_not","source", "destination_not", "destination", "description", "origin", "sequence", "target"),
|
||||
array("enabled", "interface", "proto", "source_not","source", "destination_not",
|
||||
"destination", "description", "origin", "sequence", "target"),
|
||||
"sequence"
|
||||
);
|
||||
}
|
||||
@ -304,4 +305,17 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
return $this->delBase("rules.rule", $uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle rule defined by uuid (enable/disable)
|
||||
* @param $uuid user defined rule internal id
|
||||
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
|
||||
* @return array save result
|
||||
* @throws \Phalcon\Validation\Exception when field validations fail
|
||||
* @throws \ReflectionException when not bound to model
|
||||
*/
|
||||
public function toggleRuleAction($uuid, $enabled = null)
|
||||
{
|
||||
return $this->toggleBase("rules.rule", $uuid, $enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>rule.enabled</id>
|
||||
<label>enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>enable this rule</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>rule.sequence</id>
|
||||
<label>sequence</label>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<model>
|
||||
<mount>//OPNsense/TrafficShaper</mount>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.2</version>
|
||||
<description>
|
||||
OPNsense traffic shaper
|
||||
</description>
|
||||
@ -193,6 +193,10 @@
|
||||
</queues>
|
||||
<rules>
|
||||
<rule type="ArrayField">
|
||||
<enabled type="BooleanField">
|
||||
<default>1</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<sequence type="IntegerField">
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>1000000</MaximumValue>
|
||||
|
||||
@ -65,6 +65,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
set:'/api/trafficshaper/settings/setRule/',
|
||||
add:'/api/trafficshaper/settings/addRule/',
|
||||
del:'/api/trafficshaper/settings/delRule/',
|
||||
toggle:'/api/trafficshaper/settings/toggleRule/',
|
||||
options: {
|
||||
converters: {
|
||||
notprefixable: {
|
||||
@ -225,7 +226,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
<table id="grid-rules" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogRule">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="sequence" data-type="number">{{ lang._('#') }}</th>
|
||||
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
|
||||
<th data-column-id="sequence" data-width="6em" data-type="number">{{ lang._('#') }}</th>
|
||||
<th data-column-id="origin" data-type="string" data-visible="false">{{ lang._('Origin') }}</th>
|
||||
<th data-column-id="interface" data-type="string">{{ lang._('Interface') }}</th>
|
||||
<th data-column-id="proto" data-type="string">{{ lang._('Protocol') }}</th>
|
||||
|
||||
@ -169,7 +169,7 @@ add 60000 return via any
|
||||
{% if helpers.exists('OPNsense.TrafficShaper.rules.rule') %}
|
||||
{% for rule in helpers.toList('OPNsense.TrafficShaper.rules.rule', 'sequence', 'int') %}
|
||||
{% if helpers.getUUIDtag(rule.target) in ['pipe','queue'] %}
|
||||
{% if physical_interface(rule.interface) %}
|
||||
{% if physical_interface(rule.interface) and rule.enabled|default('0') == '1' %}
|
||||
{% if helpers.getUUID(rule.target).enabled|default('0') == '1' %}
|
||||
{% if helpers.getUUIDtag(rule.target) == 'pipe' or
|
||||
helpers.getUUID(helpers.getUUID(rule.target).pipe).enabled|default('0') == '1'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user