diff options
author | Renato Botelho <renato@netgate.com> | 2017-01-04 11:07:30 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-01-04 11:07:43 -0200 |
commit | 32771b5a8d0cfc592bb851e171b68062a2b285d5 (patch) | |
tree | 58b5935ea4696870b9ef18d4cd7ea3e20e31265f /src/etc | |
parent | 3a92e10c9c94f506041c00b632de31b13abad90d (diff) | |
download | pfsense-32771b5a8d0cfc592bb851e171b68062a2b285d5.zip pfsense-32771b5a8d0cfc592bb851e171b68062a2b285d5.tar.gz |
Rework openvpn_vpnid_next() and remove duplicated code
Diffstat (limited to 'src/etc')
-rw-r--r-- | src/etc/inc/openvpn.inc | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/src/etc/inc/openvpn.inc b/src/etc/inc/openvpn.inc index 3ca9498..59a08b2 100644 --- a/src/etc/inc/openvpn.inc +++ b/src/etc/inc/openvpn.inc @@ -347,37 +347,29 @@ function openvpn_vpnid_next() { function openvpn_port_used($prot, $interface, $port, $curvpnid = 0) { global $config; + $ovpn_settings = array(); if (is_array($config['openvpn']['openvpn-server'])) { - foreach ($config['openvpn']['openvpn-server'] as & $settings) { - if (isset($settings['disable'])) { - continue; - } - - if ($curvpnid != 0 && $curvpnid == $settings['vpnid']) { - continue; - } - - if ($port == $settings['local_port'] && $prot == $settings['protocol'] && - ($interface == $settings['interface'] || $interface == "any" || $settings['interface'] == "any")) { - return $settings['vpnid']; - } - } + $ovpn_settings = $config['openvpn']['openvpn-server']; } - if (is_array($config['openvpn']['openvpn-client'])) { - foreach ($config['openvpn']['openvpn-client'] as & $settings) { - if (isset($settings['disable'])) { - continue; - } + $ovpn_settings = array_merge($ovpn_settings, + $config['openvpn']['openvpn-client']); + } - if ($curvpnid != 0 && $curvpnid == $settings['vpnid']) { - continue; - } + foreach ($ovpn_settings as $settings) { + if (isset($settings['disable'])) { + continue; + } - if ($port == $settings['local_port'] && $prot == $settings['protocol'] && - ($interface == $settings['interface'] || $interface == "any" || $settings['interface'] == "any")) { - return $settings['vpnid']; - } + if ($curvpnid != 0 && $curvpnid == $settings['vpnid']) { + continue; + } + + if ($port == $settings['local_port'] && + $prot == $settings['protocol'] && + ($interface == $settings['interface'] || + $interface == "any" || $settings['interface'] == "any")) { + return $settings['vpnid']; } } |