From 47124fa2dae53898a2448f350d44ac3c8d18e2fb Mon Sep 17 00:00:00 2001 From: Seth Mos Date: Mon, 2 Jun 2008 18:10:10 +0000 Subject: Replace silly vpns list logic Add subnet checking for robustness --- etc/inc/filter.inc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'etc/inc/filter.inc') diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 9133329..c2018aa 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -441,18 +441,18 @@ function filter_generate_aliases() { return $aliases; } +/* returns space seperated list of vpn subnets */ function get_vpns_list() { global $config; /* build list of vpns */ $vpns = ""; - $isfirst = true; + $vpns_arr = array(); /* ipsec */ if ($config['ipsec']['tunnel']) { foreach ($config['ipsec']['tunnel'] as $tunnel) { - if ($isfirst == false) - $vpns .= " "; - $vpns .= $tunnel['remote-subnet']; - $isfirst = false; + if(is_subnet($tunnel['remote-subnet'])) { + $vpns_arr[] = $tunnel['remote-subnet']; + } } } /* openvpn */ @@ -460,20 +460,20 @@ function get_vpns_list() { $conf =& $config['installedpackages']["openvpn$type"]['config']; if (!is_array($conf)) continue; foreach ($conf as $tunnel) { - if ($isfirst == false) - $vpns .= " "; - $vpns .= $tunnel['remote_network']; - $isfirst = false; + if(is_subnet($tunnel['remote-subnet'])) { + $vpns_arr[] = $tunnel['remote_network']; + } } } /* pppoe */ if ($config['pppoe']['remoteip']) { - if ($isfirst == false) - $vpns .= " "; - $vpns .= $config['pppoe']['remoteip'] ."/". $config['pppoe']['pppoe_subnet']; - $isfirst = false; + if(is_subnet($tunnel['remote-subnet'])) { + $vpns_arr[] = $config['pppoe']['remoteip'] ."/". $config['pppoe']['pppoe_subnet']; + } + } + if(!empty($vpns_arr)) { + $vpns = implode(" ", $vpns_arr); } - $vpns .= " "; return $vpns; } @@ -3449,4 +3449,4 @@ function return_vpn_subnet($adr) { } -?> \ No newline at end of file +?> -- cgit v1.1