Eliminate the "this_device" test from the resync check in rc.openvpn.

It is not necessary to check, as the only times a gateway event should trigger the VPN to restart are when the current and new devices differ.
This also allows us to simplify the code a bit and eliminate some single-use variables.
See the discussion at 4aefcf9151
This commit is contained in:
jim-p 2015-03-25 10:40:00 -04:00
parent 4aefcf9151
commit a3cecbc375

View File

@ -49,15 +49,10 @@ function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) {
$mode_id = $mode . $ovpn_settings['vpnid'];
$fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface";
if (file_exists($fpath)) {
$current_device = file_get_contents($fpath);
$current_device = trim($current_device, " \t\n");
$new_device = get_failover_interface($ovpn_settings['interface']);
if (isset($config['interfaces'][$interface])) {
$this_device = $config['interfaces'][$interface]['if'];
/* If the "current", "new", and "this" device are ALL the same, no resync should be necessary. */
if (($current_device == $new_device) && ($current_device == $this_device))
$resync_needed = false;
}
/* Compare the interface currently used by the VPN with the interface that should be used.
If the VPN should stay on the same interface, do not resync */
if (trim(file_get_contents($fpath), " \t\n") == get_failover_interface($ovpn_settings['interface'])) {
$resync_needed = false;
}
}
}