diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/siproxd/siproxd.inc | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/config/siproxd/siproxd.inc b/config/siproxd/siproxd.inc index 50b6e558..f97025a8 100644 --- a/config/siproxd/siproxd.inc +++ b/config/siproxd/siproxd.inc @@ -31,6 +31,7 @@ if (!function_exists("filter_configure")) { require_once("filter.inc"); } +require_once("pfsense-utils.inc"); require_once("service-utils.inc"); // Check to find out on which pfSense version the package is running @@ -42,6 +43,18 @@ if ($pfs_version == "2.1" || $pfs_version == "2.2") { define('SIPROXD', '/usr/local'); } +function install_package_siproxd() { + siproxd_create_chroot(); + /* remove rc script distributed with the package */ + unlink_if_exists(SIPROXD . '/etc/rc.d/siproxd'); +} + +function deinstall_package_siproxd() { + rmdir_recursive("/var/siproxd"); + unlink_if_exists(SIPROXD . '/etc/siproxd.conf'); + unlink_if_exists(SIPROXD . '/etc/siproxd_passwd.cfg'); +} + function sync_package_siproxd_users() { global $g, $config; conf_mount_rw(); @@ -66,21 +79,21 @@ function siproxd_generate_rules($type) { $siproxd_conf = &$config['installedpackages']['siproxdsettings']['config'][0]; if (!is_service_running('siproxd')) { - log_error("Siproxd is installed but not started. Not installing redirect rules."); + log_error("[siproxd] Package is installed but not started. Not installing firewall rules."); return; } /* proxy is turned off in package settings */ - if ($siproxd_conf['sipenable'] == "0") { - log_error("WARNING: siproxd proxy has not been enabled. Not installing rules."); + if ($siproxd_conf['sipenable'] != "on") { + log_error("[siproxd] WARNING: siproxd proxy has not been enabled. Not installing firewall rules."); return "\n"; } $ifaces = explode(",", $siproxd_conf['if_inbound']); $ifaces = array_map('convert_friendly_interface_to_real_interface_name', $ifaces); - $rtplower = ($siproxd_conf['rtplower'] ? $siproxd_conf['rtplower'] : 7070); - $rtpupper = ($siproxd_conf['rtpupper'] ? $siproxd_conf['rtpupper'] : 7079); - $port = ($siproxd_conf['port'] ? $siproxd_conf['port'] : 5060); + $rtplower = $siproxd_conf['rtplower'] ?: '7070'; + $rtpupper = $siproxd_conf['rtpupper'] ?: '7079'; + $port = $siproxd_conf['port'] ?: '5060'; switch($type) { case 'nat': @@ -108,18 +121,24 @@ function siproxd_generate_rules($type) { return $rules; } -function sync_package_siproxd() { - global $config, $pfs_version; - - conf_mount_rw(); - +function siproxd_create_chroot() { $siproxd_chroot = "/var/siproxd/"; safe_mkdir($siproxd_chroot); @chown($siproxd_chroot, "nobody"); @chgrp($siproxd_chroot, "nobody"); - unlink_if_exists(SIPROXD . '/etc/rc.d/siproxd'); +} - $siproxd_conf = &$config['installedpackages']['siproxdsettings']['config'][0]; +function sync_package_siproxd() { + global $config, $pfs_version; + + conf_mount_rw(); + siproxd_create_chroot(); + + if (is_array($config['installedpackages']['siproxdsettings'])) { + $siproxd_conf = &$config['installedpackages']['siproxdsettings']['config'][0]; + } else { + $siproxd_conf = array(); + } $siproxd_conffile = SIPROXD . '/etc/siproxd.conf'; $siproxd_pwfile = SIPROXD . '/etc/siproxd_passwd.cfg'; @@ -136,9 +155,14 @@ function sync_package_siproxd() { fwrite($fout, "# This file was automatically generated by the pfSense\n"); fwrite($fout, "# package management system.\n\n"); - /* proxy is turned off in package settings */ + /* if proxy is turned off in package settings, stop service, remove rc script and do nothing else */ if ($siproxd_conf['sipenable'] == "0") { fclose($fout); + if (is_service_running('siproxd')) { + stop_service("siproxd"); + sleep(3); + } + unlink_if_exists(SIPROXD . '/etc/rc.d/siproxd.sh'); return; } @@ -147,11 +171,7 @@ function sync_package_siproxd() { } if ($siproxd_conf['if_outbound'] != "") { - if (intval($config['version']) < 6 && $config['interfaces'][$siproxd_conf['if_outbound']]['ipaddr'] == "pppoe") { - fwrite($fout, "if_outbound = ng0\n"); - } else { - fwrite($fout, "if_outbound = " . convert_friendly_interface_to_real_interface_name($siproxd_conf['if_outbound']) . "\n"); - } + fwrite($fout, "if_outbound = " . convert_friendly_interface_to_real_interface_name($siproxd_conf['if_outbound']) . "\n"); } if ($siproxd_conf['port'] != "") { @@ -286,7 +306,7 @@ function sync_package_siproxd() { sleep(3); } /* Only (re)start the service when siproxd is enabled */ - if ($siproxd_conf['sipenable'] != "0") { + if ($siproxd_conf['sipenable'] == "on") { start_service("siproxd"); sleep(3); } |