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
3b34f51f
Commit
3b34f51f
authored
Nov 21, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugins: add firewall reload button, inline service_name_compare()
parent
b30940b5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
19 deletions
+59
-19
firewall.inc
src/etc/inc/plugins.inc.d/firewall.inc
+49
-0
services.inc
src/etc/inc/services.inc
+8
-10
service.inc
src/etc/inc/xmlrpc/service.inc
+2
-3
status_services.php
src/www/status_services.php
+0
-5
services_status.widget.php
src/www/widgets/widgets/services_status.widget.php
+0
-1
No files found.
src/etc/inc/plugins.inc.d/firewall.inc
0 → 100644
View file @
3b34f51f
<?php
/*
Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
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.
*/
function
firewall_services
()
{
global
$config
;
$services
=
array
();
if
(
!
isset
(
$config
[
'system'
][
'disablefilter'
]))
{
$services
[]
=
array
(
'description'
=>
gettext
(
'Packet Filter'
),
'configd'
=>
array
(
'restart'
=>
array
(
'filter reload'
),
'start'
=>
array
(
'filter reload'
),
'stop'
=>
array
(
'filter reload'
),
),
'nocheck'
=>
true
,
'name'
=>
'pf'
,
);
}
return
$services
;
}
src/etc/inc/services.inc
View file @
3b34f51f
...
...
@@ -1961,6 +1961,10 @@ function services_get()
}
}
uasort
(
$services
,
function
(
$a
,
$b
)
{
return
strcasecmp
(
$a
[
'name'
],
$b
[
'name'
]);
});
return
$services
;
}
...
...
@@ -1997,20 +2001,14 @@ function find_service_by_name($names, $filter = array())
return
array
();
}
function
service_name_compare
(
$a
,
$b
)
{
if
(
strtolower
(
$a
[
'name'
])
==
strtolower
(
$b
[
'name'
]))
{
return
0
;
}
return
(
strtolower
(
$a
[
'name'
])
<
strtolower
(
$b
[
'name'
]))
?
-
1
:
1
;
}
function
get_service_status
(
$service
)
{
if
(
!
empty
(
$service
[
'nocheck'
]))
{
return
true
;
}
if
(
isset
(
$service
[
'pidfile'
]))
{
return
isvalidpid
(
$service
[
'pidfile'
]);
}
elseif
(
!
empty
(
$service
[
'nocheck'
]))
{
return
true
;
}
return
is_process_running
(
$service
[
'name'
]);
...
...
src/etc/inc/xmlrpc/service.inc
View file @
3b34f51f
...
...
@@ -53,12 +53,11 @@ function xmlrpc_publishable_service()
function
list_services_xmlrpc
()
{
$services
=
services_get
();
if
(
count
(
$services
)
>
0
)
{
uasort
(
$services
,
"service_name_compare"
);
}
foreach
(
$services
as
&
$service
)
{
$service
[
'status'
]
=
get_service_status
(
$service
);
}
return
$services
;
}
...
...
src/www/status_services.php
View file @
3b34f51f
...
...
@@ -56,14 +56,9 @@ if (!empty($_POST['service'])) {
$services
=
services_get
();
if
(
count
(
$services
)
>
0
)
{
uasort
(
$services
,
"service_name_compare"
);
}
include
(
"head.inc"
);
?>
<body>
<?php
include
(
"fbegin.inc"
);
?>
...
...
src/www/widgets/widgets/services_status.widget.php
View file @
3b34f51f
...
...
@@ -79,7 +79,6 @@ if (isset($_POST['servicestatusfilter'])) {
<?php
$skipservices
=
explode
(
","
,
$config
[
'widgets'
][
'servicestatusfilter'
]);
if
(
count
(
$services
)
>
0
)
:
uasort
(
$services
,
"service_name_compare"
);
foreach
(
$services
as
$service
)
:
if
(
!
$service
[
'name'
]
||
in_array
(
$service
[
'name'
],
$skipservices
))
{
continue
;
...
...
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