From c7d03899f5fa48aa3c4b1ec006090a4a36f29aa3 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 1 Jun 2016 13:21:01 +0200 Subject: [PATCH] firewall pages, normalize interface selection, using the new interface plugins --- src/www/firewall_nat_1to1_edit.php | 59 ++++---------------------- src/www/firewall_nat_edit.php | 66 ++++------------------------- src/www/firewall_nat_npt_edit.php | 37 +---------------- src/www/firewall_nat_out_edit.php | 38 +---------------- src/www/firewall_rules_edit.php | 67 ++++-------------------------- 5 files changed, 26 insertions(+), 241 deletions(-) diff --git a/src/www/firewall_nat_1to1_edit.php b/src/www/firewall_nat_1to1_edit.php index b92f88c98..94aee1dd4 100644 --- a/src/www/firewall_nat_1to1_edit.php +++ b/src/www/firewall_nat_1to1_edit.php @@ -37,60 +37,15 @@ require_once("pfsense-utils.inc"); function formNetworks() { $networks = array(); $networks["any"] = gettext("any"); - $networks["pptp"] = gettext("PPTP clients"); - $networks["pppoe"] = gettext("PPPoE clients"); - $networks["l2tp"] = gettext("L2TP clients"); - foreach (get_configured_interface_with_descr() as $ifent => $ifdesc) { - $networks[$ifent] = htmlspecialchars($ifdesc) . " " . gettext("net"); - $networks[$ifent."ip"] = htmlspecialchars($ifdesc). " ". gettext("address"); + foreach (legacy_config_get_interfaces(array("enable" => true)) as $ifent => $ifdetail) { + $networks[$ifent] = htmlspecialchars($ifdetail['descr']) . " " . gettext("net"); + if (!isset($ifdetail['virtual'])) { + $networks[$ifent."ip"] = htmlspecialchars($ifdetail['descr']). " ". gettext("address"); + } } return $networks; } -/** - * build array with interface options for this form - */ -function formInterfaces() { - global $config; - $interfaces = array(); - foreach ( get_configured_interface_with_descr(false, true) as $if => $ifdesc) { - $interfaces[$if] = $ifdesc; - } - - if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") { - $interfaces['l2tp'] = "L2TP VPN"; - } - - if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") { - $interfaces['pptp'] = "PPTP VPN"; - } - - if (is_pppoe_server_enabled()) { - $interfaces['pppoe'] = "PPPoE VPN"; - } - - /* add ipsec interfaces */ - if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { - $interfaces["enc0"] = "IPsec"; - } - - /* add openvpn/tun interfaces */ - if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) { - $interfaces['openvpn'] = 'OpenVPN'; - } - return $interfaces; -} - -/** - * obscured by clouds, is_specialnet uses this.. so let's hide it in here. - * let's kill this another day. - */ -$specialsrcdst = explode(" ", "any pptp pppoe l2tp openvpn"); -$ifdisp = get_configured_interface_with_descr(); -foreach ($ifdisp as $kif => $kdescr) { - $specialsrcdst[] = "{$kif}"; - $specialsrcdst[] = "{$kif}ip"; -} if (!isset($config['nat']['onetoone'])) { $config['nat']['onetoone'] = array(); @@ -306,9 +261,9 @@ include("head.inc");
diff --git a/src/www/firewall_nat_edit.php b/src/www/firewall_nat_edit.php index e94f2fc6c..01cc47111 100644 --- a/src/www/firewall_nat_edit.php +++ b/src/www/firewall_nat_edit.php @@ -32,73 +32,21 @@ require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("filter.inc"); -/** - * build array with interface options for this form - */ -function formInterfaces() { - global $config; - $interfaces = array(); - foreach ( get_configured_interface_with_descr(false, true) as $if => $ifdesc) { - $interfaces[$if] = $ifdesc; - } - - if (!empty($config['ifgroups']['ifgroupentry']) && is_array($config['ifgroups']['ifgroupentry'])) { - foreach ($config['ifgroups']['ifgroupentry'] as $ifgrp) { - $interfaces[$ifgrp['ifname']] = $ifgrp['descr']; - } - } - - if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") { - $interfaces['l2tp'] = "L2TP VPN"; - } - - if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") { - $interfaces['pptp'] = "PPTP VPN"; - } - - if (is_pppoe_server_enabled()) { - $interfaces['pppoe'] = "PPPoE VPN"; - } - - /* add ipsec interfaces */ - if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { - $interfaces["enc0"] = "IPsec"; - } - - /* add openvpn/tun interfaces */ - if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) { - $interfaces['openvpn'] = 'OpenVPN'; - } - return $interfaces; -} - /** * fetch list of selectable networks to use in form */ function formNetworks() { $networks = array(); $networks["any"] = gettext("any"); - $networks["pptp"] = gettext("PPTP clients"); - $networks["pppoe"] = gettext("PPPoE clients"); - $networks["l2tp"] = gettext("L2TP clients"); - foreach (get_configured_interface_with_descr() as $ifent => $ifdesc) { - $networks[$ifent] = htmlspecialchars($ifdesc) . " " . gettext("net"); - $networks[$ifent."ip"] = htmlspecialchars($ifdesc). " ". gettext("address"); + foreach (legacy_config_get_interfaces(array("enable" => true)) as $ifent => $ifdetail) { + $networks[$ifent] = htmlspecialchars($ifdetail['descr']) . " " . gettext("net"); + if (!isset($ifdetail['virtual'])) { + $networks[$ifent."ip"] = htmlspecialchars($ifdetail['descr']). " ". gettext("address"); + } } return $networks; } -/** - * obscured by clouds, is_specialnet uses this.. so let's hide it in here. - * let's kill this another day. - */ -$specialsrcdst = explode(" ", "any (self) pptp pppoe l2tp openvpn"); -$ifdisp = get_configured_interface_with_descr(); -foreach ($ifdisp as $kif => $kdescr) { - $specialsrcdst[] = "{$kif}"; - $specialsrcdst[] = "{$kif}ip"; -} - // init config and get reference if (!isset($config['nat']['rule']) || !is_array($config['nat']['rule'])) { @@ -590,9 +538,9 @@ $( document ).ready(function() {
diff --git a/src/www/firewall_nat_npt_edit.php b/src/www/firewall_nat_npt_edit.php index 4b6499e9b..8aea2ade7 100644 --- a/src/www/firewall_nat_npt_edit.php +++ b/src/www/firewall_nat_npt_edit.php @@ -31,39 +31,6 @@ require_once("guiconfig.inc"); require_once("interfaces.inc"); require_once("pfsense-utils.inc"); -/** - * build array with interface options for this form - */ -function formInterfaces() { - global $config; - $interfaces = array(); - foreach ( get_configured_interface_with_descr(false, true) as $if => $ifdesc) { - $interfaces[$if] = $ifdesc; - } - - if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") { - $interfaces['l2tp'] = "L2TP VPN"; - } - - if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") { - $interfaces['pptp'] = "PPTP VPN"; - } - - if (is_pppoe_server_enabled()) { - $interfaces['pppoe'] = "PPPoE VPN"; - } - - /* add ipsec interfaces */ - if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { - $interfaces["enc0"] = "IPsec"; - } - - /* add openvpn/tun interfaces */ - if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) { - $interfaces['openvpn'] = 'OpenVPN'; - } - return $interfaces; -} if (!isset($config['nat']['npt'])) { $config['nat']['npt'] = array(); @@ -198,9 +165,9 @@ include("head.inc");
diff --git a/src/www/firewall_nat_out_edit.php b/src/www/firewall_nat_out_edit.php index 28fb4911b..8d4a102cc 100644 --- a/src/www/firewall_nat_out_edit.php +++ b/src/www/firewall_nat_out_edit.php @@ -32,40 +32,6 @@ require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("filter.inc"); -/** - * build array with interface options for this form - */ -function formInterfaces() { - global $config; - $interfaces = array(); - foreach (legacy_config_get_interfaces() as $if => $ifdata) { - $interfaces[$if] = $ifdata['descr']; - } - - if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") { - $interfaces['l2tp'] = "L2TP VPN"; - } - - if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") { - $interfaces['pptp'] = "PPTP VPN"; - } - - if (is_pppoe_server_enabled()) { - $interfaces['pppoe'] = "PPPoE VPN"; - } - - /* add ipsec interfaces */ - if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { - $interfaces["enc0"] = "IPsec"; - } - - /* add openvpn/tun interfaces */ - if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) { - $interfaces['openvpn'] = 'OpenVPN'; - } - return $interfaces; -} - /** * return option array for valid translation networks */ @@ -452,9 +418,9 @@ include("head.inc");
diff --git a/src/www/firewall_rules_edit.php b/src/www/firewall_rules_edit.php index 0b4cf19ee..2cd7f9c40 100644 --- a/src/www/firewall_rules_edit.php +++ b/src/www/firewall_rules_edit.php @@ -43,45 +43,6 @@ if ($ostypes == null) { $ostypes = array(); } -/** - * build array with interface options for this form - */ -function formInterfaces() { - global $config; - $interfaces = array(); - foreach ( get_configured_interface_with_descr(false, true) as $if => $ifdesc) { - $interfaces[$if] = $ifdesc; - } - - if (!empty($config['ifgroups']['ifgroupentry']) && is_array($config['ifgroups']['ifgroupentry'])) { - foreach ($config['ifgroups']['ifgroupentry'] as $ifgrp) { - $interfaces[$ifgrp['ifname']] = $ifgrp['descr']; - } - } - - if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == "server") { - $interfaces['l2tp'] = "L2TP VPN"; - } - - if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == "server") { - $interfaces['pptp'] = "PPTP VPN"; - } - - if (is_pppoe_server_enabled()) { - $interfaces['pppoe'] = "PPPoE VPN"; - } - - /* add ipsec interfaces */ - if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { - $interfaces["enc0"] = "IPsec"; - } - - /* add openvpn/tun interfaces */ - if (isset($config['openvpn']['openvpn-server']) || isset($config['openvpn']['openvpn-client'])) { - $interfaces['openvpn'] = 'OpenVPN'; - } - return $interfaces; -} /** * fetch list of selectable networks to use in form @@ -89,12 +50,11 @@ function formInterfaces() { function formNetworks() { $networks = array(); $networks["any"] = gettext("any"); - $networks["pptp"] = gettext("PPTP clients"); - $networks["pppoe"] = gettext("PPPoE clients"); - $networks["l2tp"] = gettext("L2TP clients"); - foreach (get_configured_interface_with_descr() as $ifent => $ifdesc) { - $networks[$ifent] = htmlspecialchars($ifdesc) . " " . gettext("net"); - $networks[$ifent."ip"] = htmlspecialchars($ifdesc). " ". gettext("address"); + foreach (legacy_config_get_interfaces(array("enable" => true)) as $ifent => $ifdetail) { + $networks[$ifent] = htmlspecialchars($ifdetail['descr']) . " " . gettext("net"); + if (!isset($ifdetail['virtual'])) { + $networks[$ifent."ip"] = htmlspecialchars($ifdetail['descr']). " ". gettext("address"); + } } return $networks; } @@ -124,18 +84,6 @@ function is_posnumericint($arg) { } - -/** - * obscured by clouds, is_specialnet uses this.. so let's hide it in here. - * let's kill this another day. - */ -$specialsrcdst = explode(" ", "any (self) pptp pppoe l2tp openvpn"); -$ifdisp = get_configured_interface_with_descr(); -foreach ($ifdisp as $kif => $kdescr) { - $specialsrcdst[] = "{$kif}"; - $specialsrcdst[] = "{$kif}ip"; -} - if (!isset($config['filter']['rule'])) { $config['filter']['rule'] = array(); } @@ -775,7 +723,8 @@ include("head.inc");