net/ftp-proxy: proper probe for enabled services; closes #52

This commit is contained in:
Franco Fichtner 2016-11-13 15:54:18 +01:00
parent 7d7ed2706f
commit e9c691ff11

View file

@ -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;
}