Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
ce244e80
Commit
ce244e80
authored
May 26, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(trafficshaper) work in progress traffic shaper, add initial rule configuration
parent
93a3c51c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
48 deletions
+195
-48
SettingsController.php
...rollers/OPNsense/TrafficShaper/Api/SettingsController.php
+33
-0
dialogPipe.xml
...p/controllers/OPNsense/TrafficShaper/forms/dialogPipe.xml
+20
-4
TrafficShaper.xml
...e/mvc/app/models/OPNsense/TrafficShaper/TrafficShaper.xml
+35
-17
index.volt
src/opnsense/mvc/app/views/OPNsense/TrafficShaper/index.volt
+107
-27
No files found.
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php
View file @
ce244e80
...
...
@@ -189,4 +189,37 @@ class SettingsController extends ApiControllerBase
}
}
/**
* search traffic shaper rules
* @return array
*/
public
function
searchRulesAction
()
{
if
(
$this
->
request
->
isPost
())
{
// fetch query parameters
$itemsPerPage
=
$this
->
request
->
getPost
(
'rowCount'
,
'int'
,
9999
);
$currentPage
=
$this
->
request
->
getPost
(
'current'
,
'int'
,
1
);
$sortBy
=
array
(
"number"
);
$sortDescending
=
false
;
if
(
$this
->
request
->
hasPost
(
'sort'
)
&&
is_array
(
$this
->
request
->
getPost
(
"sort"
)))
{
$sortBy
=
array_keys
(
$this
->
request
->
getPost
(
"sort"
));
if
(
$this
->
request
->
getPost
(
"sort"
)[
$sortBy
[
0
]]
==
"desc"
)
{
$sortDescending
=
true
;
}
}
$searchPhrase
=
$this
->
request
->
getPost
(
'searchPhrase'
,
'string'
,
''
);
// create model and fetch query resuls
$fields
=
array
(
"interface"
,
"proto"
,
"source"
,
"destination"
,
"description"
,
"origin"
);
$mdlShaper
=
new
TrafficShaper
();
$grid
=
new
UIModelGrid
(
$mdlShaper
->
rules
->
rule
);
return
$grid
->
fetch
(
$fields
,
$itemsPerPage
,
$currentPage
,
$sortBy
,
$sortDescending
,
$searchPhrase
);
}
else
{
return
array
();
}
}
}
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/forms/dialogPipe.xml
View file @
ce244e80
...
...
@@ -3,13 +3,29 @@
<id>
pipe.bandwidth
</id>
<label>
bandwidth
</label>
<type>
text
</type>
<help>
test
</help>
<help>
Total bandwidth for this pipe
</help>
</field>
<field>
<id>
pipe.bandwidthMetric
</id>
<label>
Enable traffic management.
</label>
<label>
bandwidth Metric
</label>
<type>
dropdown
</type>
<help>
<![CDATA[test]]>
</help>
</field>
<field>
<id>
pipe.queue
</id>
<label>
queue
</label>
<type>
text
</type>
<help>
test
</help>
</field>
<field>
<id>
pipe.mask
</id>
<label>
mask
</label>
<type>
dropdown
</type>
<help>
<![CDATA[Dynamic queue creation by source or destination address]]>
</help>
</field>
<field>
<id>
pipe.description
</id>
<label>
description
</label>
<type>
text
</type>
</field>
</form>
\ No newline at end of file
src/opnsense/mvc/app/models/OPNsense/TrafficShaper/TrafficShaper.xml
View file @
ce244e80
...
...
@@ -9,13 +9,14 @@
<number
type=
"IntegerField"
>
<MinimumValue>
1
</MinimumValue>
<MaximumValue>
65535
</MaximumValue>
<ValidationMessage></ValidationMessage>
<ValidationMessage>
Pipe number must be between 1...65535
</ValidationMessage>
<Required>
Y
</Required>
</number>
<bandwidth
type=
"IntegerField"
>
<Required>
Y
</Required>
<MinimumValue>
1
</MinimumValue>
<MaximumValue>
899795
</MaximumValue>
<ValidationMessage>
Bandwidth out of range
</ValidationMessage>
</bandwidth>
<bandwidthMetric
type=
"OptionField"
>
<Required>
Y
</Required>
...
...
@@ -29,19 +30,23 @@
</bandwidthMetric>
<queue
type=
"IntegerField"
>
<Required>
N
</Required>
<MinimumValue>
2
</MinimumValue>
<MaximumValue>
100
</MaximumValue>
<ValidationMessage>
queue size should be between 2...100
</ValidationMessage>
</queue>
<
queueMetric
type=
"OptionField"
>
<Required>
N
</Required>
<default>
slots
</default>
<
mask
type=
"OptionField"
>
<Required>
Y
</Required>
<default>
none
</default>
<OptionValues>
<slots>
Slots
</slots>
<bit>
bit/s
</bit>
<Kbit>
Kbit/s
</Kbit>
<Mbit>
Mbit/s
</Mbit>
<none></none>
<source>
source
</source>
<destination>
destination
</destination>
</OptionValues>
</
queueMetric
>
</
mask
>
<origin
type=
"TextField"
>
<Required>
N
</Required>
<mask>
/^([a-z,A-Z,1-9]){0,30}$/
</mask>
<ValidationMessage>
origin should be regular text of max 30 characters
</ValidationMessage>
</origin>
<description
type=
"TextField"
>
<Required>
N
</Required>
...
...
@@ -50,12 +55,10 @@
</pipes>
<rules>
<rule
type=
"ArrayField"
>
<pipe
type=
"IntegerField"
>
<MinimumValue>
1
</MinimumValue>
<MaximumValue>
65535
</MaximumValue>
<ValidationMessage></ValidationMessage>
<interface
type=
"TextField"
>
<Required>
Y
</Required>
</pipe>
<default>
wan
</default>
</interface>
<proto
type=
"OptionField"
>
<Required>
Y
</Required>
<default>
ip
</default>
...
...
@@ -65,13 +68,28 @@
<tcp>
tcp
</tcp>
</OptionValues>
</proto>
<
interfa
ce
type=
"TextField"
>
<
sour
ce
type=
"TextField"
>
<Required>
Y
</Required>
<default>
wan
</default>
</interface>
<default>
any
</default>
</source>
<destination
type=
"TextField"
>
<Required>
Y
</Required>
<default>
any
</default>
</destination>
<target
type=
"IntegerField"
>
<MinimumValue>
1
</MinimumValue>
<MaximumValue>
65535
</MaximumValue>
<ValidationMessage></ValidationMessage>
<Required>
Y
</Required>
</target>
<description
type=
"TextField"
>
<Required>
N
</Required>
</description>
<origin
type=
"TextField"
>
<Required>
N
</Required>
<mask>
/^([a-z,A-Z,1-9]){0,30}$/
</mask>
<ValidationMessage>
origin should be regular text of max 30 characters
</ValidationMessage>
</origin>
</rule>
</rules>
</items>
...
...
src/opnsense/mvc/app/views/OPNsense/TrafficShaper/index.volt
View file @
ce244e80
...
...
@@ -34,6 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
$( document ).ready(function() {
/*************************************************************************************************************
* manage bandwidth pipes
*************************************************************************************************************/
/**
* Render pipe grid using searchPipes api
*/
...
...
@@ -41,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
ajax: true,
selection: true,
multiSelect: true,
rowCount:[7,14,20,-1],
url: '/api/trafficshaper/settings/searchPipes',
formatters: {
"commands": function(column, row)
...
...
@@ -167,38 +172,113 @@ POSSIBILITY OF SUCH DAMAGE.
});
/*************************************************************************************************************
*
*************************************************************************************************************/
/**
* Render rules grid using searchPipes api
*/
var gridRules =$("#grid-rules").bootgrid({
ajax: true,
selection: true,
multiSelect: true,
rowCount:[7,14,20,-1],
url: '/api/trafficshaper/settings/searchRules',
formatters: {
"commands": function(column, row)
{
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.uuid + "\"><span class=\"fa fa-pencil\"></span></button> " +
"<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.uuid + "\"><span class=\"fa fa-trash-o\"></span></button>";
}
}
});
});
</script>
<table id="grid-pipes" class="table table-condensed table-hover table-striped">
<thead>
<tr>
<th data-column-id="number" data-type="number">Number</th>
<th data-column-id="bandwidth" data-type="number">Bandwidth</th>
<th data-column-id="bandwidthMetric" data-type="string">BandwidthMetric</th>
<th data-column-id="description" data-type="string">description</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<button type="button" id="addPipe" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span></button>
<button type="button" id="deletePipes" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
<div class="container-fluid">
<div class="row">
<div class="col-md-12" id="content">
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#pipes">{{ lang._('Pipes') }}</a></li>
<li><a data-toggle="tab" href="#rules">{{ lang._('Rules') }}</a></li>
</ul>
<div class="tab-content">
<div id="pipes" class="tab-pane fade in active">
<!-- tab page "pipes" -->
<table id="grid-pipes" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th data-column-id="origin" data-type="string">Origin</th>
<th data-column-id="number" data-type="number">Number</th>
<th data-column-id="bandwidth" data-type="number">Bandwidth</th>
<th data-column-id="bandwidthMetric" data-type="string">BandwidthMetric</th>
<th data-column-id="mask" data-type="string">mask</th>
<th data-column-id="description" data-type="string">description</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<button type="button" id="addPipe" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span></button>
<button type="button" id="deletePipes" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
</div>
<div id="rules" class="tab-pane fade in">
<!-- tab page "rules" -->
<table id="grid-rules" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th data-column-id="origin" data-type="string">Origin</th>
<th data-column-id="interface" data-type="string">Interface</th>
<th data-column-id="proto" data-type="string">Protocol</th>
<th data-column-id="source" data-type="string">Source</th>
<th data-column-id="destination" data-type="string">Destination</th>
<th data-column-id="description" data-type="string">Description</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">ID</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<button type="button" id="addRule" class="btn btn-xs btn-default"><span class="fa fa-pencil"></span></button>
<button type="button" id="deleteRules" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
{# include dialogs #}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment