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
1e6406e0
Commit
1e6406e0
authored
Aug 08, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ids) refactor for
https://github.com/opnsense/core/pull/1124
parent
93872326
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
57 deletions
+12
-57
SettingsController.php
...c/app/controllers/OPNsense/IDS/Api/SettingsController.php
+12
-57
No files found.
src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php
View file @
1e6406e0
...
@@ -29,10 +29,9 @@
...
@@ -29,10 +29,9 @@
namespace
OPNsense\IDS\Api
;
namespace
OPNsense\IDS\Api
;
use
\Phalcon\Filter
;
use
\Phalcon\Filter
;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Base\Api
MutableModel
ControllerBase
;
use
\OPNsense\Base\Filters\QueryFilter
;
use
\OPNsense\Base\Filters\QueryFilter
;
use
\OPNsense\Core\Backend
;
use
\OPNsense\Core\Backend
;
use
\OPNsense\IDS\IDS
;
use
\OPNsense\Core\Config
;
use
\OPNsense\Core\Config
;
use
\OPNsense\Base\UIModelGrid
;
use
\OPNsense\Base\UIModelGrid
;
...
@@ -40,24 +39,23 @@ use \OPNsense\Base\UIModelGrid;
...
@@ -40,24 +39,23 @@ use \OPNsense\Base\UIModelGrid;
* Class SettingsController Handles settings related API actions for the IDS module
* Class SettingsController Handles settings related API actions for the IDS module
* @package OPNsense\IDS
* @package OPNsense\IDS
*/
*/
class
SettingsController
extends
ApiControllerBase
class
SettingsController
extends
Api
MutableModel
ControllerBase
{
{
/**
static
protected
$internalModelName
=
'ids'
;
* @var null|IDS IDS model to share across some methods (see getModel)
static
protected
$internalModelClass
=
'\OPNsense\IDS\IDS'
;
*/
private
$idsModel
=
null
;
/**
/**
* get ids model
* @return array plain model settings (non repeating items)
* @return null|IDS
*/
*/
p
ublic
function
getModel
()
p
rotected
function
getModelNodes
()
{
{
if
(
$this
->
idsModel
==
null
)
{
$settingsNodes
=
array
(
'general'
);
$this
->
idsModel
=
new
IDS
();
$result
=
array
();
$mdlIDS
=
$this
->
getModel
();
foreach
(
$settingsNodes
as
$key
)
{
$result
[
$key
]
=
$mdlIDS
->
$key
->
getNodes
();
}
}
return
$result
;
return
$this
->
idsModel
;
}
}
/**
/**
...
@@ -464,49 +462,6 @@ class SettingsController extends ApiControllerBase
...
@@ -464,49 +462,6 @@ class SettingsController extends ApiControllerBase
return
$result
;
return
$result
;
}
}
/**
* retrieve IDS settings
* @return array IDS settings
*/
public
function
getAction
()
{
// define list of configurable settings
$settingsNodes
=
array
(
'general'
);
$result
=
array
();
if
(
$this
->
request
->
isGet
())
{
$mdlIDS
=
$this
->
getModel
();
$result
[
'ids'
]
=
array
();
foreach
(
$settingsNodes
as
$key
)
{
$result
[
'ids'
][
$key
]
=
$mdlIDS
->
$key
->
getNodes
();
}
}
return
$result
;
}
/**
* update IDS settings
* @return array status
*/
public
function
setAction
()
{
$result
=
array
(
"result"
=>
"failed"
);
if
(
$this
->
request
->
isPost
())
{
// load model and update with provided data
$mdlIDS
=
$this
->
getModel
();
$mdlIDS
->
setNodes
(
$this
->
request
->
getPost
(
"ids"
));
$validations
=
$mdlIDS
->
validate
(
null
,
"ids."
);
if
(
count
(
$validations
))
{
$result
[
'validations'
]
=
$validations
;
}
else
{
$mdlIDS
->
serializeToConfig
();
Config
::
getInstance
()
->
save
();
$result
[
"result"
]
=
"saved"
;
}
}
return
$result
;
}
/**
/**
* search user defined rules
* search user defined rules
* @return array list of found user rules
* @return array list of found user rules
...
...
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