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
3600c6a3
Commit
3600c6a3
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
parent
de888244
Changes
4
Hide 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 @
3600c6a3
...
@@ -2675,7 +2675,7 @@ function services_get()
...
@@ -2675,7 +2675,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
;
}
}
}
}
...
@@ -2750,18 +2750,7 @@ function services_get()
...
@@ -2750,18 +2750,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
);
...
@@ -2771,8 +2760,22 @@ function find_service_by_name($names)
...
@@ -2771,8 +2760,22 @@ 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
)
{
return
$service
;
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
;
}
}
}
}
}
}
}
...
...
src/www/fbegin.inc
View file @
3600c6a3
...
@@ -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
();
$ssvc
=
find_service_by_name
(
$service_hook
);
switch
(
$service_hook
)
{
case
'openvpn'
:
$ssvc
=
find_service_by_openvpn_vpnid
(
$vpnid
);
break
;
default
:
$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 @
3600c6a3
...
@@ -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 @
3600c6a3
...
@@ -118,29 +118,19 @@ function service_control_stop($name, $extras)
...
@@ -118,29 +118,19 @@ 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"
);
$vpnmode
=
htmlspecialchars
(
$extras
[
'vpnmode'
]);
return
$msg
;
if
((
$vpnmode
==
"server"
)
or
(
$vpnmode
==
"client"
))
{
case
'miniupnpd'
:
$id
=
htmlspecialchars
(
$extras
[
'id'
]);
upnp_action
(
'stop'
);
$pidfile
=
"/var/run/openvpn_
{
$vpnmode
}{
$id
}
.pid"
;
return
$msg
;
killbypid
(
$pidfile
);
case
'sshd'
:
}
killbyname
(
"sshd"
);
return
$msg
;
return
$msg
;
/* XXX extra argument is extra tricky */
case
'openvpn'
:
}
elseif
(
$name
==
'miniupnpd'
)
{
$vpnmode
=
htmlspecialchars
(
$extras
[
'vpnmode'
]);
upnp_action
(
'stop'
);
if
((
$vpnmode
==
"server"
)
or
(
$vpnmode
==
"client"
))
{
return
$msg
;
$id
=
htmlspecialchars
(
$extras
[
'id'
]);
$pidfile
=
"/var/run/openvpn_
{
$vpnmode
}{
$id
}
.pid"
;
killbypid
(
$pidfile
);
}
return
$msg
;
case
'relayd'
:
killbyname
(
'relayd'
);
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