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
11c82822
Commit
11c82822
authored
Feb 21, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: shrink stop further and start fixing openvpn
(cherry picked from commit
3600c6a3
)
parent
a6253b14
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
51 deletions
+37
-51
services.inc
src/etc/inc/services.inc
+18
-15
fbegin.inc
src/www/fbegin.inc
+1
-9
status_openvpn.php
src/www/status_openvpn.php
+3
-3
status_services.php
src/www/status_services.php
+15
-24
No files found.
src/etc/inc/services.inc
View file @
11c82822
...
@@ -2682,7 +2682,7 @@ function services_get()
...
@@ -2682,7 +2682,7 @@ function services_get()
$pconfig
[
'id'
]
=
$id
;
$pconfig
[
'id'
]
=
$id
;
$pconfig
[
'vpnid'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'vpnid'
]
=
$setting
[
'vpnid'
];
$pconfig
[
'description'
]
=
gettext
(
"OpenVPN"
)
.
" "
.
$mode
.
": "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'description'
]
=
gettext
(
"OpenVPN"
)
.
" "
.
$mode
.
": "
.
htmlspecialchars
(
$setting
[
'description'
]);
$pconfig
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
s
[
'vpnid'
]
}
.pid"
;
$pconfig
[
'pidfile'
]
=
"/var/run/openvpn_
{
$mode
}{
$setting
[
'vpnid'
]
}
.pid"
;
$services
[]
=
$pconfig
;
$services
[]
=
$pconfig
;
}
}
}
}
...
@@ -2757,18 +2757,7 @@ function services_get()
...
@@ -2757,18 +2757,7 @@ function services_get()
return
$services
;
return
$services
;
}
}
function
find_service_by_openvpn_vpnid
(
$vpnid
)
function
find_service_by_name
(
$names
,
$filter
=
array
())
{
$services
=
services_get
();
foreach
(
$services
as
$service
)
{
if
((
$service
[
"name"
]
==
"openvpn"
)
&&
isset
(
$service
[
"vpnid"
])
&&
(
$service
[
"vpnid"
]
==
$vpnid
))
{
return
$service
;
}
}
return
array
();
}
function
find_service_by_name
(
$names
)
{
{
if
(
!
is_array
(
$names
))
{
if
(
!
is_array
(
$names
))
{
$names
=
array
(
$names
);
$names
=
array
(
$names
);
...
@@ -2778,11 +2767,25 @@ function find_service_by_name($names)
...
@@ -2778,11 +2767,25 @@ function find_service_by_name($names)
foreach
(
$services
as
$service
)
{
foreach
(
$services
as
$service
)
{
foreach
(
$names
as
$name
)
{
foreach
(
$names
as
$name
)
{
if
(
$service
[
'name'
]
==
$name
)
{
if
(
$service
[
'name'
]
!=
$name
)
{
continue
;
}
if
(
!
count
(
$filter
))
{
/* force match if filter wasn't set (standard behaviour) */
$filter
[
'name'
]
=
$name
;
}
foreach
(
$filter
as
$key
=>
$value
)
{
if
(
isset
(
$service
[
$key
])
&&
$service
[
$key
]
==
$value
)
{
/*
* First match wins, $names is only used
* to probe similar services that exclude
* each other.
*/
return
$service
;
return
$service
;
}
}
}
}
}
}
}
return
array
();
return
array
();
}
}
...
...
src/www/fbegin.inc
View file @
11c82822
...
@@ -183,15 +183,7 @@ if($need_alert_display == true) {
...
@@ -183,15 +183,7 @@ if($need_alert_display == true) {
<li
class=
"btn-group-container"
>
<li
class=
"btn-group-container"
>
<?php
<?php
if
(
isset
(
$service_hook
))
{
if
(
isset
(
$service_hook
))
{
$ssvc
=
array
();
switch
(
$service_hook
)
{
case
'openvpn'
:
$ssvc
=
find_service_by_openvpn_vpnid
(
$vpnid
);
break
;
default
:
$ssvc
=
find_service_by_name
(
$service_hook
);
$ssvc
=
find_service_by_name
(
$service_hook
);
break
;
}
if
(
!
empty
(
$ssvc
))
{
if
(
!
empty
(
$ssvc
))
{
echo
get_service_status_icon
(
$ssvc
,
false
);
echo
get_service_status_icon
(
$ssvc
,
false
);
echo
get_service_control_links
(
$ssvc
,
false
);
echo
get_service_control_links
(
$ssvc
,
false
);
...
...
src/www/status_openvpn.php
View file @
11c82822
...
@@ -175,7 +175,7 @@ $( document ).ready(function() {
...
@@ -175,7 +175,7 @@ $( document ).ready(function() {
endforeach
;
?>
endforeach
;
?>
<tr>
<tr>
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<?php
$ssvc
=
find_service_by_
openvpn_vpnid
(
$server
[
'vpnid'
]
);
?>
<?php
$ssvc
=
find_service_by_
name
(
'openvpn'
,
array
(
'vpnid'
=>
$server
[
'vpnid'
])
);
?>
<?=
get_service_status_icon
(
$ssvc
,
true
,
true
);
?>
<?=
get_service_status_icon
(
$ssvc
,
true
,
true
);
?>
<?=
get_service_control_links
(
$ssvc
,
true
);
?>
<?=
get_service_control_links
(
$ssvc
,
true
);
?>
</td>
</td>
...
@@ -254,7 +254,7 @@ $( document ).ready(function() {
...
@@ -254,7 +254,7 @@ $( document ).ready(function() {
<td>
<?=
$sk_server
[
'status'
];
?>
</td>
<td>
<?=
$sk_server
[
'status'
];
?>
</td>
<td>
<td>
<div>
<div>
<?php
$ssvc
=
find_service_by_
openvpn_vpnid
(
$sk_server
[
'vpnid'
]
);
?>
<?php
$ssvc
=
find_service_by_
name
(
'openvpn'
,
array
(
'vpnid'
=>
$sk_server
[
'vpnid'
])
);
?>
<?=
get_service_status_icon
(
$ssvc
,
false
,
true
);
?>
<?=
get_service_status_icon
(
$ssvc
,
false
,
true
);
?>
<?=
get_service_control_links
(
$ssvc
,
true
);
?>
<?=
get_service_control_links
(
$ssvc
,
true
);
?>
</div>
</div>
...
@@ -294,7 +294,7 @@ $( document ).ready(function() {
...
@@ -294,7 +294,7 @@ $( document ).ready(function() {
<td>
<?=
$client
[
'status'
];
?>
</td>
<td>
<?=
$client
[
'status'
];
?>
</td>
<td>
<td>
<div>
<div>
<?php
$ssvc
=
find_service_by_
openvpn_vpnid
(
$client
[
'vpnid'
]
);
?>
<?php
$ssvc
=
find_service_by_
name
(
'openvpn'
,
array
(
'vpnid'
=>
$client
[
'vpnid'
])
);
?>
<?=
get_service_status_icon
(
$ssvc
,
false
,
true
);
?>
<?=
get_service_status_icon
(
$ssvc
,
false
,
true
);
?>
<?=
get_service_control_links
(
$ssvc
,
true
);
?>
<?=
get_service_control_links
(
$ssvc
,
true
);
?>
</div>
</div>
...
...
src/www/status_services.php
View file @
11c82822
...
@@ -118,17 +118,8 @@ function service_control_stop($name, $extras)
...
@@ -118,17 +118,8 @@ function service_control_stop($name, $extras)
{
{
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
switch
(
$name
)
{
/* XXX openvpn is handled special at the moment */
case
'igmpproxy'
:
if
(
$name
==
'openvpn'
)
{
killbyname
(
"igmpproxy"
);
return
$msg
;
case
'miniupnpd'
:
upnp_action
(
'stop'
);
return
$msg
;
case
'sshd'
:
killbyname
(
"sshd"
);
return
$msg
;
case
'openvpn'
:
$vpnmode
=
htmlspecialchars
(
$extras
[
'vpnmode'
]);
$vpnmode
=
htmlspecialchars
(
$extras
[
'vpnmode'
]);
if
((
$vpnmode
==
"server"
)
or
(
$vpnmode
==
"client"
))
{
if
((
$vpnmode
==
"server"
)
or
(
$vpnmode
==
"client"
))
{
$id
=
htmlspecialchars
(
$extras
[
'id'
]);
$id
=
htmlspecialchars
(
$extras
[
'id'
]);
...
@@ -136,11 +127,10 @@ function service_control_stop($name, $extras)
...
@@ -136,11 +127,10 @@ function service_control_stop($name, $extras)
killbypid
(
$pidfile
);
killbypid
(
$pidfile
);
}
}
return
$msg
;
return
$msg
;
case
'relayd'
:
/* XXX extra argument is extra tricky */
killbyname
(
'relayd'
);
}
elseif
(
$name
==
'miniupnpd'
)
{
upnp_action
(
'stop'
);
return
$msg
;
return
$msg
;
default
:
break
;
}
}
$service
=
find_service_by_name
(
$name
);
$service
=
find_service_by_name
(
$name
);
...
@@ -163,7 +153,8 @@ function service_control_stop($name, $extras)
...
@@ -163,7 +153,8 @@ function service_control_stop($name, $extras)
}
elseif
(
isset
(
$service
[
'pidfile'
]))
{
}
elseif
(
isset
(
$service
[
'pidfile'
]))
{
killbypid
(
$service
[
'pidfile'
]);
killbypid
(
$service
[
'pidfile'
]);
}
else
{
}
else
{
$msg
=
sprintf
(
gettext
(
"Could not stop service `%s'"
),
htmlspecialchars
(
$name
));
/* last resort, but not very elegant */
killbyname
(
$service
[
'name'
]);
}
}
return
$msg
;
return
$msg
;
...
...
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