summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-01-29 15:30:35 -0200
committerRenato Botelho <garga@FreeBSD.org>2013-01-29 15:30:35 -0200
commit49b76122af0846474f65eaf73e0e879e24fb554c (patch)
treefbbe81e53b550d12c485d1071a99e87f54aa1dac /etc
parentd12ae2414c7e3bfd239699309ff571c716d070c9 (diff)
downloadpfsense-49b76122af0846474f65eaf73e0e879e24fb554c.zip
pfsense-49b76122af0846474f65eaf73e0e879e24fb554c.tar.gz
Permit openvpn to use same port on different interfaces. It should fix #814
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/openvpn.inc40
1 files changed, 29 insertions, 11 deletions
diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc
index 45a3ab4..0f3febc 100644
--- a/etc/inc/openvpn.inc
+++ b/etc/inc/openvpn.inc
@@ -137,28 +137,46 @@ function openvpn_vpnid_next() {
return $vpnid;
}
-function openvpn_port_used($prot, $port) {
+function openvpn_port_used($prot, $interface, $port, $curvpnid = 0) {
global $config;
- if (is_array($config['openvpn']['openvpn-server']))
- foreach ($config['openvpn']['openvpn-server'] as & $settings)
- if ($port == $settings['local_port'] &&
- $prot == $settings['protocol'] && !isset($settings['disable']))
+ 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'];
+ }
+ }
- if (is_array($config['openvpn']['openvpn-client']))
- foreach ($config['openvpn']['openvpn-client'] as & $settings)
- if ($port == $settings['local_port'] &&
- $prot == $settings['protocol'] && !isset($settings['disable']))
+ if (is_array($config['openvpn']['openvpn-client'])) {
+ foreach ($config['openvpn']['openvpn-client'] 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'];
+ }
+ }
return 0;
}
-function openvpn_port_next($prot) {
+function openvpn_port_next($prot, $interface = "wan") {
$port = 1194;
- while(openvpn_port_used($prot, $port))
+ while(openvpn_port_used($prot, $interface, $port))
+ $port++;
+ while(openvpn_port_used($prot, "any", $port))
$port++;
return $port;
OpenPOWER on IntegriCloud