mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
net/ftp-proxy: proper probe for enabled services; closes #52
This commit is contained in:
parent
7d7ed2706f
commit
e9c691ff11
1 changed files with 38 additions and 17 deletions
|
|
@ -26,34 +26,55 @@
|
|||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function ftpproxy_firewall($fw)
|
||||
function ftpproxy_enabled()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset($config['OPNsense']['ftpproxies']) && is_array($config['OPNsense']['ftpproxies'])) {
|
||||
$fw->registerAnchor("ftp-proxy/*", "nat");
|
||||
$fw->registerAnchor("ftp-proxy/*", "rdr");
|
||||
$fw->registerAnchor("ftp-proxy/*", "fw");
|
||||
if (isset($config['OPNsense']['ftpproxies']['ftpproxy'][0])) {
|
||||
foreach ($config['OPNsense']['ftpproxies']['ftpproxy'] as $ftpproxy) {
|
||||
if (isset($ftpproxy['enabled']) && $ftpproxy['enabled']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* we should always make arrays for these, too many potential bugs: */
|
||||
if (isset($config['OPNsense']['ftpproxies']['ftpproxy']['enabled']) &&
|
||||
$config['OPNsense']['ftpproxies']['ftpproxy']['enabled']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function ftpproxy_firewall($fw)
|
||||
{
|
||||
if (!ftpproxy_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fw->registerAnchor('ftp-proxy/*', 'nat');
|
||||
$fw->registerAnchor('ftp-proxy/*', 'rdr');
|
||||
$fw->registerAnchor('ftp-proxy/*', 'fw');
|
||||
}
|
||||
|
||||
function ftpproxy_services()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$services = array();
|
||||
|
||||
if (isset($config['OPNsense']['ftpproxies']) && is_array($config['OPNsense']['ftpproxies'])) {
|
||||
$services[] = array(
|
||||
'description' => gettext('FTP Proxy Server'),
|
||||
'configd' => array(
|
||||
'restart' => array('ftpproxy restart'),
|
||||
'start' => array('ftpproxy start'),
|
||||
'stop' => array('ftpproxy stop'),
|
||||
),
|
||||
'name' => 'ftp-proxy',
|
||||
);
|
||||
if (!ftpproxy_enabled()) {
|
||||
return $services;
|
||||
}
|
||||
|
||||
$services[] = array(
|
||||
'description' => gettext('FTP Proxy Server'),
|
||||
'configd' => array(
|
||||
'restart' => array('ftpproxy restart'),
|
||||
'start' => array('ftpproxy start'),
|
||||
'stop' => array('ftpproxy stop'),
|
||||
),
|
||||
'name' => 'ftp-proxy',
|
||||
);
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue