Project

General

Profile

« Previous | Next » 

Revision efe0fec5

Added by Renato Botelho almost 5 years ago

Combine nested conditionals into a single one

View differences:

src/etc/inc/ipsec.inc
1733 1733
			$subnet_ip = gen_subnetv4($interfaceip, $subnet_bits);
1734 1734
			/* if the remote gateway is in the local subnet, then don't add a route */
1735 1735
			if (is_ipaddrv4($sourcehost) &&
1736
			    !ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) {
1737
				if (is_ipaddrv4($gatewayip) && !$duplicates) {
1738
					// log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}");
1739
					route_add_or_change("-host {$sourcehost} {$gatewayip}");
1740
				}
1736
			    !ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}") &&
1737
			    is_ipaddrv4($gatewayip) && !$duplicates) {
1738
				// log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}");
1739
				route_add_or_change("-host {$sourcehost} {$gatewayip}");
1741 1740
			}
1742 1741
		}
1743 1742
	} else if ($family == 'inet6') {
......
1748 1747
			$subnet_ip = gen_subnetv6($interfaceip, $subnet_bits);
1749 1748
			/* if the remote gateway is in the local subnet, then don't add a route */
1750 1749
			if (is_ipaddrv6($sourcehost) &&
1751
			    !ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}")) {
1752
				if (is_ipaddrv6($gatewayip) && !$duplicates) {
1753
					// log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}");
1754
					route_add_or_change("-inet6 -host {$sourcehost} {$gatewayip}");
1755
				}
1750
			    !ip_in_subnet($sourcehost, "{$subnet_ip}/{$subnet_bits}") &&
1751
			    is_ipaddrv6($gatewayip) && !$duplicates) {
1752
				// log_error("IPSEC interface is not WAN but {$ifacesuse}, adding static route for VPN endpoint {$rgip} via {$gatewayip}");
1753
				route_add_or_change("-inet6 -host {$sourcehost} {$gatewayip}");
1756 1754
			}
1757 1755
		}
1758 1756
	}

Also available in: Unified diff