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
817fbb60
Commit
817fbb60
authored
Mar 24, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(netflow) work in progress api and ui components
parent
8c35f297
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
283 additions
and
0 deletions
+283
-0
NetflowController.php
...ontrollers/OPNsense/Diagnostics/Api/NetflowController.php
+86
-0
NetflowController.php
...pp/controllers/OPNsense/Diagnostics/NetflowController.php
+45
-0
netflow_capture.xml
...ontrollers/OPNsense/Diagnostics/forms/netflow_capture.xml
+25
-0
Netflow.php
src/opnsense/mvc/app/models/OPNsense/Diagnostics/Netflow.php
+39
-0
Netflow.xml
src/opnsense/mvc/app/models/OPNsense/Diagnostics/Netflow.xml
+31
-0
netflow.volt
src/opnsense/mvc/app/views/OPNsense/Diagnostics/netflow.volt
+57
-0
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetflowController.php
0 → 100644
View file @
817fbb60
<?php
/**
* Copyright (C) 2016 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace
OPNsense\Diagnostics\Api
;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Diagnostics\Netflow
;
use
\OPNsense\Core\Config
;
/**
* Class NetflowController
* @package OPNsense\Netflow
*/
class
NetflowController
extends
ApiControllerBase
{
/**
* retrieve Netflow settings
* @return array
*/
public
function
getconfigAction
()
{
$result
=
array
();
if
(
$this
->
request
->
isGet
())
{
$mdlNetflow
=
new
Netflow
();
$result
[
'netflow'
]
=
$mdlNetflow
->
getNodes
();
}
return
$result
;
}
/**
* update netflow configuration fields
* @return array
* @throws \Phalcon\Validation\Exception
*/
public
function
setconfigAction
()
{
$result
=
array
(
"result"
=>
"failed"
);
if
(
$this
->
request
->
hasPost
(
"netflow"
))
{
// load model and update with provided data
$mdlNetflow
=
new
Netflow
();
$mdlNetflow
->
setNodes
(
$this
->
request
->
getPost
(
"netflow"
));
// perform validation
$validations
=
$mdlNetflow
->
validate
();
if
(
count
(
$validations
))
{
$result
[
'validations'
]
=
array
();
foreach
(
$validations
as
$valkey
=>
$validation
)
{
$result
[
'validations'
][
'netflow.'
.
$valkey
]
=
$validation
;
}
}
else
{
// serialize model to config and save
$mdlNetflow
->
serializeToConfig
();
Config
::
getInstance
()
->
save
();
$result
[
"result"
]
=
"saved"
;
}
}
return
$result
;
}
}
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/NetflowController.php
0 → 100644
View file @
817fbb60
<?php
/**
* Copyright (C) 2016 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace
OPNsense\Diagnostics
;
use
OPNsense\Base\IndexController
;
/**
* Class NetflowController
* @package OPNsense\Diagnostics
*/
class
NetflowController
extends
IndexController
{
public
function
indexAction
()
{
$this
->
view
->
title
=
"Netflow"
;
$this
->
view
->
pick
(
'OPNsense/Diagnostics/netflow'
);
$this
->
view
->
captureForm
=
$this
->
getForm
(
"netflow_capture"
);
}
}
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/forms/netflow_capture.xml
0 → 100644
View file @
817fbb60
<form>
<field>
<id>
netflow.capture.interfaces
</id>
<label>
Interfaces
</label>
<type>
select_multiple
</type>
<style>
tokenize
</style>
<help>
<![CDATA[Select interface(s) to enable netflow on.]]>
</help>
<hint>
Type or select interface.
</hint>
</field>
<field>
<id>
netflow.capture.version
</id>
<label>
Version
</label>
<type>
dropdown
</type>
<help>
<![CDATA[Select netflow version to use.]]>
</help>
</field>
<field>
<id>
netflow.capture.targets
</id>
<label>
Destinations
</label>
<type>
select_multiple
</type>
<style>
tokenize
</style>
<help>
<![CDATA[Select destinations to send netflow data to (ip address:port, eg 192.168.0.1:2550).]]>
</help>
<hint>
Type or select destinations.
</hint>
<allownew>
true
</allownew>
</field>
</form>
\ No newline at end of file
src/opnsense/mvc/app/models/OPNsense/Diagnostics/Netflow.php
0 → 100644
View file @
817fbb60
<?php
/**
* Copyright (C) 2016 Deciso B.V.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace
OPNsense\Diagnostics
;
use
OPNsense\Base\BaseModel
;
/**
* Class Netflow
* @package OPNsense\Netflow
*/
class
Netflow
extends
BaseModel
{
}
src/opnsense/mvc/app/models/OPNsense/Diagnostics/Netflow.xml
0 → 100644
View file @
817fbb60
<model>
<mount>
//OPNsense/Netflow
</mount>
<description>
OPNsense Netflow
</description>
<items>
<capture>
<interfaces
type=
"InterfaceField"
>
<Required>
N
</Required>
<default></default>
<multiple>
Y
</multiple>
<filters>
<enable>
/^(?!0).*$/
</enable>
</filters>
</interfaces>
<version
type=
"OptionField"
>
<Required>
Y
</Required>
<default>
5
</default>
<OptionValues>
<v5>
v5
</v5>
<v9>
v9
</v9>
</OptionValues>
</version>
<targets
type=
"CSVListField"
>
<Required>
N
</Required>
<mask>
/^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(6553[0-5]|655[0-2][0-9]|65[0-4](\d){2}|6[0-4](\d){3}|[1-5](\d){4}|[1-9](\d){0,3})([,]){0,1})*/u
</mask>
<ValidationMessage>
Please enter valid targets (e.g. 192.168.0.1:2055)
</ValidationMessage>
</targets>
</capture>
</items>
</model>
src/opnsense/mvc/app/views/OPNsense/Diagnostics/netflow.volt
0 → 100644
View file @
817fbb60
{#
OPNsense® is Copyright © 2016 by Deciso B.V.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
#}
<script type="text/javascript">
$( document ).ready(function() {
var data_get_map = {'frm_CaptureSettings':"/api/diagnostics/netflow/getconfig"};
mapDataToFormUI(data_get_map).done(function(data){
// place actions to run after load, for example update form styles.
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
// link save button to API set action
$("#btn_save_capture").click(function(){
saveFormToEndpoint(url="/api/diagnostics/netflow/setconfig",formid='frm_CaptureSettings',callback_ok=function(){
});
});
});
</script>
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#capture">{{ lang._('Capture') }}</a></li>
</ul>
<div class="tab-content content-box tab-content">
<div id="capture" class="tab-pane fade in active">
<!-- tab page capture -->
{{ partial("layout_partials/base_form",['fields':captureForm,'id':'frm_CaptureSettings', 'apply_btn_id':'btn_save_capture'])}}
</div>
</div>
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