diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-07-23 12:28:28 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-07-23 12:28:28 +0000 |
commit | a81cff99ba78683895def31f9687b5ca659ed845 (patch) | |
tree | 9e8e57abdf0e6c5fb9aebda7fdc9ae8428ea0f14 /etc/inc/util.inc | |
parent | 0bc8c0b058c3cfa1e2a604c8175888b4c9fcad4e (diff) | |
download | pfsense-a81cff99ba78683895def31f9687b5ca659ed845.zip pfsense-a81cff99ba78683895def31f9687b5ca659ed845.tar.gz |
* Cleanup the mess that is reflection. Basically refactor the reflection code into its own function and cleanup some code.
* Remove alias_expand_{host,net} and fix the alias_expand_value to confirm to the new alias neting 'standards'
* Use trhoughout the code the new macros and do not expand all of them again(basically speed improvement)
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r-- | etc/inc/util.inc | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 9914bdc..84204e4 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -651,26 +651,31 @@ function is_alias($name) { function alias_expand_value($name) { global $aliastable, $config; + $newaddress = ""; - $firstentry = true; if($config['aliases']['alias']) foreach($config['aliases']['alias'] as $alias) { if($alias['name'] == $name) { if($alias['type'] == "openvpn") { - $vpn_address_split = split(" ", $alias['address']); - foreach($vpn_address_split as $vpnsplit) { - foreach($config['openvpn']['user'] as $openvpn) { - if($openvpn['name'] == $vpnsplit) { - if($firstentry == false) - $newaddress .= " "; - $newaddress .= $openvpn['ip']; - $firstentry = false; + $openvpncfg = array(); + foreach ($config['openvpn']['user'] as $openvpn) + /* XXX: Check if we have the right ip? */ + $openvpncfg[$openvpn['name']] = $openvpn['ip']; + $vpn_addresses = filter_generate_nested_alias($alias['address']); + $vpn_lines = split("\n", $vpn_addresses); + foreach ($vpn_lines as $vpn_line) { + $vpn_address_split = split(" ", $vpn_line); + foreach($vpn_address_split as $vpnsplit) { + if(isset($openvpncfg[$vpnsplit])) { + $newaddress .= " "; + $newaddress .= $openvpn[$vpnsplit]; + break; } } } - } else { - $newaddress = $alias['address']; - } + } else + $newaddress = filter_generate_nested_alias($alias['address']); + break; } } return $newaddress; @@ -689,36 +694,6 @@ function alias_expand($name) { return null; } -/* expand a host alias, if necessary */ -function alias_expand_host($name) { - global $aliastable; - - if (isset($aliastable[$name])) { - $ip_arr = explode(" ", $aliastable[$name]); - foreach($ip_arr as $ip) { - if (!is_ipaddr($ip)) - return null; - } - return $aliastable[$name]; - } else if (is_ipaddr($name)) - return $name; - else - return null; -} - -/* expand a network alias, if necessary */ -function alias_expand_net($name) { - - global $aliastable; - - if (isset($aliastable[$name]) && is_subnet($aliastable[$name])) - return $aliastable[$name]; - else if (is_subnet($name)) - return $name; - else - return null; -} - /* find out whether two subnets overlap */ function check_subnets_overlap($subnet1, $bits1, $subnet2, $bits2) { @@ -1028,4 +1003,4 @@ function isAjax() { } -?>
\ No newline at end of file +?> |