Project

General

Profile

Feature #12522 » openvpn.inc-v1.0.patch

Phil Wardt, 09/05/2023 08:31 PM

View differences:

src/etc/inc/openvpn.inc
757 757

  
758 758
	if ($settings['netbios_enable']) {
759 759

  
760
		if (!empty($settings['dhcp_nbttype']) && ($settings['dhcp_nbttype'] != 0)) {
761
			$conf .= "push \"dhcp-option NBT {$settings['dhcp_nbttype']}\"\n";
760
		if (!empty($settings['netbios_ntype']) && ($settings['netbios_ntype'] != 0)) {
761
			$conf .= "push \"dhcp-option NBT {$settings['netbios_ntype']}\"\n";
762 762
		}
763
		if (!empty($settings['dhcp_nbtscope'])) {
764
			$conf .= "push \"dhcp-option NBS {$settings['dhcp_nbtscope']}\"\n";
763
		if (!empty($settings['netbios_scope'])) {
764
			$conf .= "push \"dhcp-option NBS {$settings['netbios_scope']}\"\n";
765 765
		}
766 766

  
767 767
		if (!empty($settings['wins_server1'])) {
......
774 774
		if (!empty($settings['nbdd_server1'])) {
775 775
			$conf .= "push \"dhcp-option NBDD {$settings['nbdd_server1']}\"\n";
776 776
		}
777
		if (!empty($settings['nbdd_server2'])) {
778
			$conf .= "push \"dhcp-option NBDD {$settings['nbdd_server2']}\"\n";
777 779
		}
780
	}
778 781

  
779 782
	if ($settings['gwredir']) {
780 783
		$conf .= "push \"redirect-gateway def1\"\n";
......
1687 1690
	filter_configure();
1688 1691
}
1689 1692

  
1693
// set client specific overrides
1690 1694
function openvpn_resync_csc($settings) {
1691 1695
	global $g, $openvpn_tls_server_modes;
1692 1696
	if (isset($settings['disable'])) {
......
1710 1714
		$conf .= "push-reset\n";
1711 1715
	}
1712 1716

  
1717
	if ($settings['topology_override']) {
1718
		$conf .= "push \"topology {$settings['topology']}\"\n";
1719
	}
1720

  
1713 1721
	if ($settings['remove_route']) {
1714 1722
		$conf .= "push-remove route\n";
1715 1723
	}
1716 1724

  
1725
	if ($settings['remove_iroute']) {
1726
		$conf .= "push-remove iroute\n";
1727
	}
1728

  
1729
	if ($settings['remove_dnsdomain']) {
1730
		$conf .= "push-remove \"dhcp-option DOMAIN\"\n";
1731
	}
1732

  
1733
	if ($settings['remove_dnsservers']) {
1734
		$conf .= "push-remove \"dhcp-option DNS\"\n";
1735
	}
1736

  
1737
	if ($settings['remove_ntpservers']) {
1738
		$conf .= "push-remove \"dhcp-option NTP\"\n";
1739
	}
1740

  
1741
	if ($settings['remove_netbios_ntype']) {
1742
		$conf .= "push-remove \"dhcp-option NBT\"\n";
1743
	}
1744

  
1745
	if ($settings['remove_netbios_scope']) {
1746
		$conf .= "push-remove \"dhcp-option NBS\"\n";
1747
	}
1748

  
1749
	if ($settings['remove_wins']) {
1750
		$conf .= "push-remove \"dhcp-option WINS\"\n";
1751
	}
1752

  
1717 1753
	if ($settings['local_network']) {
1718 1754
		$conf .= openvpn_gen_routes($settings['local_network'], "ipv4", true);
1719 1755
	}
......
1730 1766
		$conf .= openvpn_gen_routes($settings['remote_networkv6'], "ipv6", false, true);
1731 1767
	}
1732 1768

  
1769
	// push the ipv4 gateway if specified
1770
	if (!empty($settings['gateway']) && is_ipaddrv4($settings['gateway'])) {
1771
		$conf .= "push \"route-gateway {$settings['gateway']}\"\n";
1772
	}
1773

  
1774
	/* Currently route-ipv6-gateway is not supported by openvpn
1775
	if (!empty($settings['gateway']) && is_ipaddrv4($settings['gateway'])) {
1776
		$conf .= "push \"route-ipv6-gateway {$settings['gateway']}\"\n";
1777
	}
1778
	*/
1779

  
1780
	// Ping override options
1781
	if ($settings['ping_push']) {
1782
		$conf .= "push \"ping {$settings['ping_seconds']}\"\n";
1783
	}
1784

  
1785
	if ($settings['ping_action_push']) {
1786
		$action = str_replace("_", "-", $settings['ping_action']);
1787
		$conf .= "push \"{$action} " .
1788
			"{$settings['ping_action_seconds']}\"\n";
1789
	}
1790

  
1791
	// create client specific dhcp options and gateway redirection
1733 1792
	openvpn_add_dhcpopts($settings, $conf);
1734 1793

  
1794
	// custom options are added after all client overrides, and before the tunnel options
1735 1795
	openvpn_add_custom($settings, $conf);
1796

  
1736 1797
	/* Loop through servers, find which ones can use this CSC */
1737 1798
	foreach (config_get_path('openvpn/openvpn-server', []) as $serversettings) {
1738 1799
		if (isset($serversettings['disable'])) {
(7-7/9)