diff options
author | pierrepomes <pierre.pomes@interface-tech.com> | 2009-12-10 17:34:17 -0500 |
---|---|---|
committer | pierrepomes <pierre.pomes@interface-tech.com> | 2009-12-10 17:34:30 -0500 |
commit | 67b0902fe1979b904b2f56a61d59309d971138da (patch) | |
tree | 5ac4d19f309ed3846b502a3361364d7a95c3cdf8 /etc/inc | |
parent | 942fdd555964d4854e38f8508ffe6acc190b94f4 (diff) | |
download | pfsense-67b0902fe1979b904b2f56a61d59309d971138da.zip pfsense-67b0902fe1979b904b2f56a61d59309d971138da.tar.gz |
Add IP alias and 'any' support to OpenVPN. Feedback #69
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/openvpn.inc | 28 | ||||
-rw-r--r-- | etc/inc/util.inc | 19 |
2 files changed, 36 insertions, 11 deletions
diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index 9de908c..ad5fa87 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -299,18 +299,22 @@ function openvpn_reconfigure($mode,& $settings) { $cipher = $settings['crypto']; $interface = $settings['interface']; - if (!$interface) - $interface = 'WAN'; + $ipaddr = $settings['ipaddr']; - /* For a carp interface, the name is well known:vip1, vip2, ...*/ - if (!strncmp($interface, "vip", 3)) { - $iface=$interface; + // If a specific ip address (VIP) is requested, use it. + // Otherwise, if a specific interface is requested, use it + // If "any" interface was selected, local directive will be ommited. + if (!empty($ipaddr)) { + $iface_ip=$ipaddr; } else { - $iface=convert_friendly_interface_to_real_interface_name($interface); + if ((!empty($interface)) && (strcmp($interface, "any"))) { + $iface=convert_friendly_interface_to_real_interface_name($interface); + + // Get ip address for the requested interface + $lines = explode(' ', trim(shell_exec("ifconfig {$iface} | grep inet | grep -v inet6"))); + $iface_ip = $lines[1]; + } } - - $lines = explode(' ', trim(shell_exec("ifconfig {$iface} | grep inet | grep -v inet6"))); - $iface_ip = $lines[1]; $conf = "dev {$devname}\n"; $conf .= "dev-type tun\n"; @@ -327,10 +331,12 @@ function openvpn_reconfigure($mode,& $settings) { $conf .= "cipher {$cipher}\n"; $conf .= "up /etc/rc.filter_configure\n"; $conf .= "down /etc/rc.filter_configure\n"; - $conf .= "local {$iface_ip}\n"; - // server specific settings + if (!empty($iface_ip)) { + $conf .= "local {$iface_ip}\n"; + } + // server specific settings if ($mode == 'server') { list($ip, $mask) = explode('/', $settings['tunnel_network']); diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 4f084ee..b32daa3 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -361,6 +361,25 @@ function get_configured_carp_interface_list() { return $iflist; } +/* return the configured IP aliases list */ +function get_configured_ip_aliases_list() { + global $config; + + $alias_list=array(); + + if(is_array($config['virtualip']['vip'])) { + $viparr = &$config['virtualip']['vip']; + foreach ($viparr as $vip) { + if ($vip['mode']=="ipalias") { + $alias_list[$vip['subnet']] = $vip['interface']; + } + } + } + + return $alias_list; +} + + /* return the configured interfaces list. */ function get_configured_interface_list($only_opt = false, $withdisabled = false) { global $config; |