Project

General

Profile

Feature #13085 » openvpn_nbdd.patch

Phil Wardt, 11/06/2023 06:39 PM

View differences:

src/etc/inc/openvpn.inc
794 794
		if (!empty($settings['nbdd_server1'])) {
795 795
			$conf .= "push \"dhcp-option NBDD {$settings['nbdd_server1']}\"\n";
796 796
		}
797
		if (!empty($settings['nbdd_server2'])) {
798
			$conf .= "push \"dhcp-option NBDD {$settings['nbdd_server2']}\"\n";
799
		}
797 800
	}
798 801

  
799 802
	if ($settings['gwredir']) {
800
-- a/src/usr/local/www/vpn_openvpn_csc.php
803
++ b/src/usr/local/www/vpn_openvpn_csc.php
......
134 134
		}
135 135

  
136 136
		$pconfig['nbdd_server1'] = $a_csc[$id]['nbdd_server1'];
137
		if ($pconfig['nbdd_server1']) {
137
		$pconfig['nbdd_server2'] = $a_csc[$id]['nbdd_server2'];
138

  
139
		if ($pconfig['nbdd_server1'] ||
140
			$pconfig['nbdd_server2']) {
138 141
			$pconfig['nbdd_server_enable'] = true;
139 142
		}
140 143
	}
......
239 242
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1']))) {
240 243
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
241 244
			}
245
			if (!empty($pconfig['nbdd_server2']) && !is_ipaddr(trim($pconfig['nbdd_server2']))) {
246
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #2' must contain a valid IP address");
242 247
			}
248
		}
243 249

  
244 250
		if (!empty($pconfig['netbios_ntype']) &&
245 251
		    !array_key_exists($pconfig['netbios_ntype'], $netbios_nodetypes)) {
......
304 310
				$csc['wins_server2'] = $pconfig['wins_server2'];
305 311
			}
306 312

  
307
			if ($pconfig['dns_server_enable']) {
313
			if ($pconfig['nbdd_server_enable']) {
308 314
				$csc['nbdd_server1'] = $pconfig['nbdd_server1'];
315
				$csc['nbdd_server2'] = $pconfig['nbdd_server2'];
309 316
			}
310 317
		}
311 318

  
......
635 642

  
636 643
	$section->add($group);
637 644

  
645
	$section->addInput(new Form_Checkbox(
646
		'nbdd_server_enable',
647
		'NBDD servers',
648
		'Provide a NetBIOS over TCP/IP Datagram Distribution Servers list to clients',
649
		$pconfig['nbdd_server_enable']
650
	));
651

  
652
	$group = new Form_Group(null);
653

  
654
	$group->add(new Form_Input(
655
		'nbdd_server1',
656
		null,
657
		'text',
658
		$pconfig['nbdd_server1']
659
	))->setHelp('Server 1');
660

  
661
	$group->add(new Form_Input(
662
		'nbdd_server2',
663
		null,
664
		'text',
665
		$pconfig['nbdd_server2']
666
	))->setHelp('Server 2');
667

  
668
	$group->addClass('nbddservers');
669

  
670
	$section->add($group);
671

  
638 672
	$custops = new Form_Textarea(
639 673
		'custom_options',
640 674
		'Advanced',
......
703 737
			hideInput('netbios_scope', false);
704 738
			hideCheckbox('wins_server_enable', false);
705 739
			setWins();
740
			hideCheckbox('nbdd_server_enable', false);
741
			setNbdds();
706 742
		} else {
707 743
			hideInput('netbios_ntype', true);
708 744
			hideInput('netbios_scope', true);
709 745
			hideCheckbox('wins_server_enable', true);
710 746
			hideClass('winsservers', true);
747
			hideCheckbox('nbdd_server_enable', true);
748
			hideClass('nbddservers', true);
711 749
		}
712 750
	}
713 751

  
......
715 753
		hideClass('winsservers', ! $('#wins_server_enable').prop('checked'));
716 754
	}
717 755

  
756
	function setNbdds() {
757
		hideClass('nbddservers', ! $('#nbdd_server_enable').prop('checked'));
758
	}
759

  
718 760
	// ---------- Click checkbox handlers ---------------------------------------------------------
719 761

  
720 762
	 // On clicking DNS Default Domain
......
740 782
	// On clicking the wins_server_enable checkbox
741 783
	$('#wins_server_enable').click(function () {
742 784
		setWins();
785
	});
786

  
787
	// On clicking the nbdd_server_enable checkbox
788
	$('#nbdd_server_enable').click(function () {
789
		setNbdds();
743 790
	});
744 791

  
745 792
	// ---------- On initial page load ------------------------------------------------------------
746
-- a/src/usr/local/www/vpn_openvpn_server.php
793
++ b/src/usr/local/www/vpn_openvpn_server.php
......
241 241
		}
242 242

  
243 243
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
244
		if ($pconfig['nbdd_server1']) {
244
		$pconfig['nbdd_server2'] = $a_server[$id]['nbdd_server2'];
245

  
246
		if ($pconfig['nbdd_server1'] ||
247
			$pconfig['nbdd_server2']) {
245 248
			$pconfig['nbdd_server_enable'] = true;
246 249
		}
247 250

  
......
553 556
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
554 557
			}
555 558
		}
559

  
556 560
		if ($pconfig['nbdd_server_enable']) {
557 561
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1']))) {
558 562
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
559 563
			}
564
			if (!empty($pconfig['nbdd_server2']) && !is_ipaddr(trim($pconfig['nbdd_server2']))) {
565
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #2' must contain a valid IP address");
560 566
			}
567
		}
561 568

  
562 569
		if (!empty($pconfig['netbios_ntype']) &&
563 570
		    !array_key_exists($pconfig['netbios_ntype'], $netbios_nodetypes)) {
......
821 828
				$server['wins_server2'] = $pconfig['wins_server2'];
822 829
			}
823 830

  
824
			if ($pconfig['dns_server_enable']) {
831
			if ($pconfig['nbdd_server_enable']) {
825 832
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
833
				$server['nbdd_server2'] = $pconfig['nbdd_server2'];
826 834
			}
827 835
		}
828 836

  
......
1689 1697
		$pconfig['wins_server2']
1690 1698
	));
1691 1699

  
1700
	$section->addInput(new Form_Checkbox(
1701
		'nbdd_server_enable',
1702
		'NBDD servers',
1703
		'Provide a NetBIOS over TCP/IP Datagram Distribution Servers list to clients',
1704
		$pconfig['nbdd_server_enable']
1705
	));
1706

  
1707
	$group = new Form_Group(null);
1708

  
1709
	$group->add(new Form_Input(
1710
		'nbdd_server1',
1711
		null,
1712
		'text',
1713
		$pconfig['nbdd_server1']
1714
	))->setHelp('Server 1');
1715

  
1716
	$group->add(new Form_Input(
1717
		'nbdd_server2',
1718
		null,
1719
		'text',
1720
		$pconfig['nbdd_server2']
1721
	))->setHelp('Server 2');
1722

  
1723
	$group->addClass('nbddservers');
1724

  
1725
	$section->add($group);
1726

  
1692 1727
	$form->add($section);
1693 1728

  
1694 1729
	$section = new Form_Section('Advanced Configuration');
......
2144 2179
		hideInput('wins_server2', hide);
2145 2180
	}
2146 2181

  
2182
	function nbdd_server_change() {
2183
		hideClass('nbddservers', ! $('#nbdd_server_enable').prop('checked') || ! $('#netbios_enable').prop('checked'));
2184
	}
2147 2185

  
2148 2186
	function ntp_server_change() {
2149 2187
		var hide  = ! $('#ntp_server_enable').prop('checked')
......
2159 2197
		hideInput('netbios_scope', hide);
2160 2198
		hideCheckbox('wins_server_enable', hide);
2161 2199
		wins_server_change();
2200
		hideCheckbox('nbdd_server_enable', hide);
2201
		nbdd_server_change();
2162 2202
	}
2163 2203

  
2164 2204
	function tuntap_change() {
......
2289 2329
		wins_server_change();
2290 2330
	});
2291 2331

  
2332
	// NBDD server
2333
	$('#nbdd_server_enable').click(function () {
2334
		nbdd_server_change();
2335
	});
2336

  
2292 2337
	 // DNS server port
2293 2338
	$('#dns_server_enable').click(function () {
2294 2339
		dns_server_change();
......
2425 2470
	dns_domain_change();
2426 2471
	dns_server_change();
2427 2472
	wins_server_change();
2473
	nbdd_server_change
2428 2474
	ntp_server_change();
2429 2475
	netbios_change();
2430 2476
	tuntap_change();
(2-2/2)