Project

General

Profile

Download (45 KB) Statistics
| Branch: | Tag: | Revision:
1 d799787e Matthew Grooms
<?php 
2
/*
3
	vpn_openvpn_server.php
4
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	All rights reserved. 
7
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
	
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
	
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
	
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
##|+PRIV
31
##|*IDENT=page-openvpn-server
32
##|*NAME=OpenVPN: Server page
33
##|*DESCR=Allow access to the 'OpenVPN: Server' page.
34
##|*MATCH=vpn_openvpn_server.php*
35
##|-PRIV
36
37
require("guiconfig.inc");
38 d84bd468 Ermal Lu?i
require_once("openvpn.inc");
39 d799787e Matthew Grooms
40
$pgtitle = array("OpenVPN", "Server");
41
42
if (!is_array($config['openvpn']['openvpn-server']))
43
	$config['openvpn']['openvpn-server'] = array();
44
45
$a_server = &$config['openvpn']['openvpn-server'];
46
47
$id = $_GET['id'];
48
if (isset($_POST['id']))
49
	$id = $_POST['id'];
50
51
$act = $_GET['act'];
52
if (isset($_POST['act']))
53
	$act = $_POST['act'];
54
55
if ($_GET['act'] == "del") {
56
57
	if (!$a_server[$id]) {
58
		pfSenseHeader("vpn_openvpn_server.php");
59
		exit;
60
	}
61
62 dc408939 Matthew Grooms
	openvpn_delete('server', $a_server[$id]);
63 d799787e Matthew Grooms
	unset($a_server[$id]);
64
	write_config();
65
	$savemsg = gettext("Server successfully deleted")."<br/>";
66
}
67
68 f432e364 Matthew Grooms
if($_GET['act']=="new"){
69 3c11bd3c Matthew Grooms
	$pconfig['autokey_enable'] = "yes";
70
	$pconfig['tlsauth_enable'] = "yes";
71
	$pconfig['autotls_enable'] = "yes";
72 fe787fc7 Matthew Grooms
	$pconfig['dh_length'] = 1024;
73 f432e364 Matthew Grooms
	$pconfig['interface'] = "wan";
74 8cd0a3fa jim-p
	$pconfig['local_port'] = openvpn_port_next('UDP');
75 f432e364 Matthew Grooms
	$pconfig['pool_enable'] = "yes";
76
}
77
78 d799787e Matthew Grooms
if($_GET['act']=="edit"){
79
80
	if (isset($id) && $a_server[$id]) {
81
82 870318b9 Ermal Lu?i
		$pconfig['disable'] = isset($a_server[$id]['disable']);
83 3c11bd3c Matthew Grooms
		$pconfig['mode'] = $a_server[$id]['mode'];
84 d799787e Matthew Grooms
		$pconfig['protocol'] = $a_server[$id]['protocol'];
85 e8a58de4 Ermal Lu?i
		$pconfig['authmode'] = $a_server[$id]['authmode'];
86 d799787e Matthew Grooms
		$pconfig['interface'] = $a_server[$id]['interface'];
87 67b0902f pierrepomes
		if (!empty($a_server[$id]['ipaddr'])) {
88
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_server[$id]['ipaddr'];
89
		}
90 d799787e Matthew Grooms
		$pconfig['local_port'] = $a_server[$id]['local_port'];
91
		$pconfig['description'] = $a_server[$id]['description'];
92 a9a613dd Scott Ullrich
		$pconfig['custom_options'] = $a_server[$id]['custom_options'];
93 d799787e Matthew Grooms
94 3c11bd3c Matthew Grooms
		if ($pconfig['mode'] != "p2p_shared_key") {
95
			if ($a_server[$id]['tls']) {
96
				$pconfig['tlsauth_enable'] = "yes";
97
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
98
			}
99 fe787fc7 Matthew Grooms
			$pconfig['caref'] = $a_server[$id]['caref'];
100
			$pconfig['certref'] = $a_server[$id]['certref'];
101
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
102 3c11bd3c Matthew Grooms
		} else
103
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
104 d799787e Matthew Grooms
		$pconfig['crypto'] = $a_server[$id]['crypto'];
105
106
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
107
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
108
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
109
		$pconfig['local_network'] = $a_server[$id]['local_network'];
110
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
111
		$pconfig['compression'] = $a_server[$id]['compression'];
112 1cb0b40a Matthew Grooms
		$pconfig['passtos'] = $a_server[$id]['passtos'];
113 d799787e Matthew Grooms
		$pconfig['client2client'] = $a_server[$id]['client2client'];
114
115 65ff8497 jim-p
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
116 d799787e Matthew Grooms
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
117
118
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
119
		if ($pconfig['dns_domain'])
120
			$pconfig['dns_domain_enable'] = true;
121
122
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
123
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
124
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
125
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
126
		if ($pconfig['dns_server1'] ||
127
			$pconfig['dns_server2'] ||
128
			$pconfig['dns_server3'] ||
129
			$pconfig['dns_server4'])
130
			$pconfig['dns_server_enable'] = true;
131
132
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
133
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
134
		if ($pconfig['ntp_server1'] ||
135
			$pconfig['ntp_server2'])
136
			$pconfig['ntp_server_enable'] = true;
137
138
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
139
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
140
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
141
142
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
143
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
144
		if ($pconfig['wins_server1'] ||
145
			$pconfig['wins_server2'])
146
			$pconfig['wins_server_enable'] = true;
147
148
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
149
		if ($pconfig['nbdd_server1'])
150
			$pconfig['nbdd_server_enable'] = true;
151 3c11bd3c Matthew Grooms
152
		// just in case the modes switch
153
		$pconfig['autokey_enable'] = "yes";
154
		$pconfig['autotls_enable'] = "yes";
155 d799787e Matthew Grooms
	}
156
}
157
158
if ($_POST) {
159
160
	unset($input_errors);
161
	$pconfig = $_POST;
162
163 f432e364 Matthew Grooms
	if (isset($id) && $a_server[$id])
164
		$vpnid = $a_server[$id]['vpnid'];
165
	else
166
		$vpnid = 0;
167
168 98c0c87a jim-p
	if ($pconfig['mode'] != "p2p_shared_key")
169 3c11bd3c Matthew Grooms
		$tls_mode = true;
170
	else
171
		$tls_mode = false;
172
173 54b9de56 Ermal Lu?i
	if (!empty($pconfig['authmode'])) {
174
		foreach ($pconfig['authmode'] as $pauthmode) {
175 b48a82c9 Ermal Lu?i
			if ($pauthmode != "Local Database" && $pconfig['mode'] == "server_tls_user") 
176 54b9de56 Ermal Lu?i
				$input_errors[] = "Only 'Local authentication database'  is allowed with " . $openvpn_server_modes[$pconfig['mode']];
177
		}
178
	}
179
180 d799787e Matthew Grooms
	/* input validation */
181
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
182
		$input_errors[] = $result;
183
184
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
185
		$input_errors[] = $result;
186
187
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
188
		$input_errors[] = $result;
189
190
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
191
		$input_errors[] = $result;
192
193 5accf130 jim-p
	$portused = openvpn_port_used($pconfig['protocol'], $pconfig['local_port']);
194
	if (($portused != $vpnid) && ($portused != 0))
195 f432e364 Matthew Grooms
		$input_errors[] = "The specified 'Local port' is in use. Please select another value";
196
197 89e6e210 jim-p
	if ($pconfig['autokey_enable'])
198
		$pconfig['shared_key'] = openvpn_create_key();
199
200 3c11bd3c Matthew Grooms
	if (!$tls_mode && !$pconfig['autokey_enable'])
201 d799787e Matthew Grooms
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
202
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
203 3c11bd3c Matthew Grooms
			$input_errors[] = "The field 'Shared Key' does not appear to be valid";
204
205
	if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
206
		if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
207
			!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
208
			$input_errors[] = "The field 'TLS Authentication Key' does not appear to be valid";
209 d799787e Matthew Grooms
210
	if ($pconfig['dns_server_enable']) {
211
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
212
			$input_errors[] = "The field 'DNS Server #1' must contain a valid IP address";
213
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
214
			$input_errors[] = "The field 'DNS Server #2' must contain a valid IP address";
215
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
216
			$input_errors[] = "The field 'DNS Server #3' must contain a valid IP address";
217
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
218
			$input_errors[] = "The field 'DNS Server #4' must contain a valid IP address";
219
	}
220
221
	if ($pconfig['ntp_server_enable']) {
222
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
223
			$input_errors[] = "The field 'NTP Server #1' must contain a valid IP address";
224
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
225
			$input_errors[] = "The field 'NTP Server #2' must contain a valid IP address";
226
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
227
			$input_errors[] = "The field 'NTP Server #3' must contain a valid IP address";
228
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
229
			$input_errors[] = "The field 'NTP Server #4' must contain a valid IP address";
230
	}
231
232
	if ($pconfig['netbios_enable']) {
233
		if ($pconfig['wins_server_enable']) {
234
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
235
				$input_errors[] = "The field 'WINS Server #1' must contain a valid IP address";
236
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
237
				$input_errors[] = "The field 'WINS Server #2' must contain a valid IP address";
238
		}
239
		if ($pconfig['nbdd_server_enable'])
240
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
241
				$input_errors[] = "The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address";
242
	}
243
244
	if ($pconfig['maxclients'] && !is_numeric($pconfig['maxclients']))
245
		$input_errors[] = "The field 'Concurrent connections' must be numeric.";
246
247 21c776dd jim-p
	/* If we are not in shared key mode, then we need the CA/Cert. */
248
	if ($pconfig['mode'] != "p2p_shared_key") {
249 872d9195 Matthew Grooms
		$reqdfields = explode(" ", "caref certref");
250
		$reqdfieldsn = explode(",", "Certificate Authority,Certificate");;
251 21c776dd jim-p
	} elseif (!$pconfig['autokey_enable']) {
252
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
253
		$reqdfields = array('shared_key');
254
		$reqdfieldsn = array('Shared key');
255 d799787e Matthew Grooms
	}
256
257 872d9195 Matthew Grooms
	$reqdfields[] = 'tunnel_network';
258
	$reqdfieldsn[] = 'Tunnel network';
259
260 d799787e Matthew Grooms
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
261
	
262
	if (!$input_errors) {
263
264
		$server = array();
265
266 f432e364 Matthew Grooms
		if ($vpnid)
267
			$server['vpnid'] = $vpnid;
268 e28120e5 Matthew Grooms
		else
269 d799787e Matthew Grooms
			$server['vpnid'] = openvpn_vpnid_next();
270
271 870318b9 Ermal Lu?i
		if ($_POST['disable'] == "yes")
272
			$server['disable'] = true;
273 3c11bd3c Matthew Grooms
		$server['mode'] = $pconfig['mode'];
274 8a47c190 Ermal Lu?i
		if (!empty($pconfig['authmode']))
275
			$server['authmode'] = implode(",", $pconfig['authmode']);
276 d799787e Matthew Grooms
		$server['protocol'] = $pconfig['protocol'];
277 67b0902f pierrepomes
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
278 d799787e Matthew Grooms
		$server['local_port'] = $pconfig['local_port'];
279
		$server['description'] = $pconfig['description'];
280 a9a613dd Scott Ullrich
		$server['custom_options'] = $pconfig['custom_options'];
281 d799787e Matthew Grooms
282 3c11bd3c Matthew Grooms
		if ($tls_mode) {
283
			if ($pconfig['tlsauth_enable']) {
284
				if ($pconfig['autotls_enable'])
285
					$pconfig['tls'] = openvpn_create_key();
286
				$server['tls'] = base64_encode($pconfig['tls']);
287
			}
288 fe787fc7 Matthew Grooms
			$server['caref'] = $pconfig['caref'];
289
			$server['certref'] = $pconfig['certref'];
290
			$server['dh_length'] = $pconfig['dh_length'];
291 3c11bd3c Matthew Grooms
		} else {
292
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
293 d799787e Matthew Grooms
		}
294
		$server['crypto'] = $pconfig['crypto'];
295
296
		$server['tunnel_network'] = $pconfig['tunnel_network'];
297
		$server['remote_network'] = $pconfig['remote_network'];
298
		$server['gwredir'] = $pconfig['gwredir'];
299
		$server['local_network'] = $pconfig['local_network'];
300
		$server['maxclients'] = $pconfig['maxclients'];
301
		$server['compression'] = $pconfig['compression'];
302 1cb0b40a Matthew Grooms
		$server['passtos'] = $pconfig['passtos'];
303 d799787e Matthew Grooms
		$server['client2client'] = $pconfig['client2client'];
304
305 65ff8497 jim-p
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
306 d799787e Matthew Grooms
		$server['pool_enable'] = $pconfig['pool_enable'];
307
308
		if ($pconfig['dns_domain_enable'])
309
			$server['dns_domain'] = $pconfig['dns_domain'];
310
311
		if ($pconfig['dns_server_enable']) {
312
			$server['dns_server1'] = $pconfig['dns_server1'];
313
			$server['dns_server2'] = $pconfig['dns_server2'];
314
			$server['dns_server3'] = $pconfig['dns_server3'];
315
			$server['dns_server4'] = $pconfig['dns_server4'];
316
		}
317
318
		if ($pconfig['ntp_server_enable']) {
319
			$server['ntp_server1'] = $pconfig['ntp_server1'];
320
			$server['ntp_server2'] = $pconfig['ntp_server2'];
321
		}
322
323
		$server['netbios_enable'] = $pconfig['netbios_enable'];
324
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
325
		$server['netbios_scope'] = $pconfig['netbios_scope'];
326
327
		if ($pconfig['netbios_enable']) {
328
329
			if ($pconfig['wins_server_enable']) {
330
				$server['wins_server1'] = $pconfig['wins_server1'];
331
				$server['wins_server2'] = $pconfig['wins_server2'];
332
			}
333
334
			if ($pconfig['dns_server_enable'])
335
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
336
		}
337
	
338
		if (isset($id) && $a_server[$id])
339
			$a_server[$id] = $server;
340
		else
341
			$a_server[] = $server;
342
343 dc408939 Matthew Grooms
		openvpn_resync('server', $server);
344 d799787e Matthew Grooms
		write_config();
345
		
346
		header("Location: vpn_openvpn_server.php");
347
		exit;
348
	}
349 8a47c190 Ermal Lu?i
	if (!empty($pconfig['authmode']))
350
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
351 d799787e Matthew Grooms
}
352
353
include("head.inc");
354
355
?>
356
357
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
358
<?php include("fbegin.inc"); ?>
359
<script language="JavaScript">
360
<!--
361
362 3c11bd3c Matthew Grooms
function mode_change() {
363
	index = document.iform.mode.selectedIndex;
364
	value = document.iform.mode.options[index].value;
365 d799787e Matthew Grooms
	switch(value) {
366 3c11bd3c Matthew Grooms
		case "p2p_tls":
367
		case "server_tls":
368
		case "server_user":
369
		case "server_tls_user":
370
			document.getElementById("tls").style.display="";
371
			document.getElementById("tls_ca").style.display="";
372
			document.getElementById("tls_cert").style.display="";
373 fe787fc7 Matthew Grooms
			document.getElementById("tls_dh").style.display="";
374 d799787e Matthew Grooms
			document.getElementById("psk").style.display="none";
375
			break;
376 3c11bd3c Matthew Grooms
		case "p2p_shared_key":
377
			document.getElementById("tls").style.display="none";
378
			document.getElementById("tls_ca").style.display="none";
379
			document.getElementById("tls_cert").style.display="none";
380 fe787fc7 Matthew Grooms
			document.getElementById("tls_dh").style.display="none";
381 d799787e Matthew Grooms
			document.getElementById("psk").style.display="";
382
			break;
383
	}
384 3c11bd3c Matthew Grooms
	switch(value) {
385
		case "p2p_shared_key":
386
			document.getElementById("client_opts").style.display="none";
387
			document.getElementById("remote_opts").style.display="";
388 b008c1eb jim-p
			document.getElementById("local_opts").style.display="none";
389
			document.getElementById("authmodetr").style.display="none";
390
			break;
391
		case "p2p_tls":
392
			document.getElementById("client_opts").style.display="none";
393
			document.getElementById("remote_opts").style.display="";
394
			document.getElementById("local_opts").style.display="";
395 e8a58de4 Ermal Lu?i
			document.getElementById("authmodetr").style.display="none";
396 3c11bd3c Matthew Grooms
			break;
397 e8a58de4 Ermal Lu?i
		case "server_user":
398
                case "server_tls_user":
399
			document.getElementById("authmodetr").style.display="";
400 54b9de56 Ermal Lu?i
			document.getElementById("client_opts").style.display="";
401
			document.getElementById("remote_opts").style.display="none";
402 b008c1eb jim-p
			document.getElementById("local_opts").style.display="";
403 54b9de56 Ermal Lu?i
			break;
404
		case "server_tls":
405
			document.getElementById("authmodetr").style.display="none";
406 3c11bd3c Matthew Grooms
		default:
407
			document.getElementById("client_opts").style.display="";
408
			document.getElementById("remote_opts").style.display="none";
409 b008c1eb jim-p
			document.getElementById("local_opts").style.display="";
410 3c11bd3c Matthew Grooms
			break;
411
	}
412
}
413
414
function autokey_change() {
415
416
	if (document.iform.autokey_enable.checked)
417
		document.getElementById("autokey_opts").style.display="none";
418
	else
419
		document.getElementById("autokey_opts").style.display="";
420
}
421
422
function tlsauth_change() {
423
424
<?php if (!$pconfig['tls']): ?>
425
	if (document.iform.tlsauth_enable.checked)
426
		document.getElementById("tlsauth_opts").style.display="";
427
	else
428
		document.getElementById("tlsauth_opts").style.display="none";
429
<?php endif; ?>
430
431
	autotls_change();
432
}
433
434
function autotls_change() {
435
436
<?php if (!$pconfig['tls']): ?>
437
	autocheck = document.iform.autotls_enable.checked;
438
<?php else: ?>
439
	autocheck = false;
440
<?php endif; ?>
441
442
	if (document.iform.tlsauth_enable.checked && !autocheck)
443
		document.getElementById("autotls_opts").style.display="";
444
	else
445
		document.getElementById("autotls_opts").style.display="none";
446 d799787e Matthew Grooms
}
447
448
function gwredir_change() {
449
450
	if (document.iform.gwredir.checked)
451
		document.getElementById("local_opts").style.display="none";
452
	else
453
		document.getElementById("local_opts").style.display="";
454
}
455
456
function dns_domain_change() {
457
458
	if (document.iform.dns_domain_enable.checked)
459
		document.getElementById("dns_domain_data").style.display="";
460
	else
461
		document.getElementById("dns_domain_data").style.display="none";
462
}
463
464
function dns_server_change() {
465
466
	if (document.iform.dns_server_enable.checked)
467
		document.getElementById("dns_server_data").style.display="";
468
	else
469
		document.getElementById("dns_server_data").style.display="none";
470
}
471
472
function wins_server_change() {
473
474
	if (document.iform.wins_server_enable.checked)
475
		document.getElementById("wins_server_data").style.display="";
476
	else
477
		document.getElementById("wins_server_data").style.display="none";
478
}
479
480
function ntp_server_change() {
481
482
	if (document.iform.ntp_server_enable.checked)
483
		document.getElementById("ntp_server_data").style.display="";
484
	else
485
		document.getElementById("ntp_server_data").style.display="none";
486
}
487
488
function netbios_change() {
489
490
	if (document.iform.netbios_enable.checked) {
491
		document.getElementById("netbios_data").style.display="";
492
		document.getElementById("wins_opts").style.display="";
493
	} else {
494
		document.getElementById("netbios_data").style.display="none";
495
		document.getElementById("wins_opts").style.display="none";
496
	}
497
}
498
499
//-->
500
</script>
501
<?php
502
	if ($input_errors)
503
		print_input_errors($input_errors);
504
	if ($savemsg)
505
		print_info_box($savemsg);
506
?>
507
<table width="100%" border="0" cellpadding="0" cellspacing="0">
508 5a3b0d3b mgrooms
	<tr>
509 d799787e Matthew Grooms
		<td class="tabnavtbl">
510
			<ul id="tabnav">
511
			<?php 
512
				$tab_array = array();
513
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
514
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
515
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
516 5540aee6 Ermal Lu?i
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
517 6785f06a Chris Buechler
				$tab_array[] = array(gettext("Logs"), false, "diag_logs_openvpn.php");
518 b63f2e8b Matthew Grooms
				add_package_tabs("OpenVPN", $tab_array);
519 d799787e Matthew Grooms
				display_top_tabs($tab_array);
520
			?>
521
			</ul>
522
		</td>
523
	</tr>    
524
	<tr>
525
		<td class="tabcont">
526
527
			<?php if($act=="new" || $act=="edit"): ?>
528
529
			<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
530
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
531 47c00c09 Scott Ullrich
					<tr>
532
						<td colspan="2" valign="top" class="listtopic">General information</td>
533 b63f2e8b Matthew Grooms
					</tr>
534 d799787e Matthew Grooms
					<tr>
535
						<td width="22%" valign="top" class="vncellreq">Disabled</td>
536
						<td width="78%" class="vtable">
537
							<table border="0" cellpadding="0" cellspacing="0">
538
								<tr>
539
									<td>
540
										<?php set_checked($pconfig['disable'],$chk); ?>
541
										<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
542
									</td>
543
									<td>
544
										&nbsp;
545
										<span class="vexpl">
546
											<strong>Disable this server</strong><br>
547
										</span>
548
									</td>
549
								</tr>
550
							</table>
551
							Set this option to disable this server without removing it from the list.
552
						</td>
553
					</tr>
554 3c11bd3c Matthew Grooms
					<tr>
555
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
556
							<td width="78%" class="vtable">
557
							<select name='mode' id='mode' class="formselect" onchange='mode_change()'>
558
							<?php
559
								foreach ($openvpn_server_modes as $name => $desc):
560
									$selected = "";
561
									if ($pconfig['mode'] == $name)
562
										$selected = "selected";
563
							?>
564
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
565
							<?php endforeach; ?>
566
							</select>
567
						</td>
568
					</tr>
569 e8a58de4 Ermal Lu?i
					<tr id="authmodetr" style="display:none">
570
                                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Backend for authentication");?></td>
571
                                                        <td width="78%" class="vtable">
572 6306b5dd Ermal Lu?i
                                                        <select name='authmode[]' id='authmode' class="formselect" multiple="true" size="<?php echo count($auth_servers); ?>">
573 c61e4626 Ermal Lu?i
							<?php $authmodes = explode(",", $pconfig['authmode']); ?>
574 e8a58de4 Ermal Lu?i
                                                        <?php
575 6306b5dd Ermal Lu?i
								$auth_servers = auth_get_authserver_list();
576 e8a58de4 Ermal Lu?i
                                                                foreach ($auth_servers as $auth_server):
577
                                                                        $selected = "";
578 c61e4626 Ermal Lu?i
                                                                        if (in_array($auth_server['name'], $authmodes))
579 e8a58de4 Ermal Lu?i
                                                                                $selected = "selected";
580
                                                        ?>
581
                                                                <option value="<?=$auth_server['name'];?>" <?=$selected;?>><?=$auth_server['name'];?></option>
582
                                                        <?php 	endforeach; ?>
583
                                                        </select>
584
                                                </td>
585
                                        </tr>
586 d799787e Matthew Grooms
					<tr>
587
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
588
							<td width="78%" class="vtable">
589
							<select name='protocol' class="formselect">
590
							<?php
591
								foreach ($openvpn_prots as $prot):
592
									$selected = "";
593
									if ($pconfig['protocol'] == $prot)
594
										$selected = "selected";
595
							?>
596
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
597
							<?php endforeach; ?>
598
							</select>
599
							</td>
600
					</tr>
601
					<tr>
602
						<td width="22%" valign="top" class="vncellreq">Interface</td>
603
						<td width="78%" class="vtable">
604
							<select name="interface" class="formselect">
605
								<?php
606
									$interfaces = get_configured_interface_with_descr();
607 3d06e8f0 pierrepomes
									$carplist = get_configured_carp_interface_list();
608
									foreach ($carplist as $cif => $carpip)
609 67b0902f pierrepomes
										$interfaces[$cif.'|'.$carpip] = strtoupper($cif) . " ({$carpip})";
610
									$aliaslist = get_configured_ip_aliases_list();
611
									foreach ($aliaslist as $aliasip => $aliasif)
612
										$interfaces[$aliasif.'|'.$aliasip] = strtoupper($aliasif) . " ({$aliasip})";
613
									$interfaces['any'] = "any";
614 d799787e Matthew Grooms
									foreach ($interfaces as $iface => $ifacename):
615 1d3bcd2a Matthew Grooms
										$selected = "";
616
										if ($iface == $pconfig['interface'])
617
											$selected = "selected";
618 d799787e Matthew Grooms
								?>
619 1d3bcd2a Matthew Grooms
									<option value="<?=$iface;?>" <?=$selected;?>>
620
										<?=htmlspecialchars($ifacename);?>
621
									</option>
622 d799787e Matthew Grooms
								<?php endforeach; ?>
623
							</select> <br>
624
						</td>
625
					</tr>
626
					<tr>
627
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Local port");?></td>
628
						<td width="78%" class="vtable">
629
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
630
						</td>
631
					</tr>
632
					<tr> 
633
						<td width="22%" valign="top" class="vncell">Description</td>
634
						<td width="78%" class="vtable"> 
635
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
636
							<br>
637
							You may enter a description here for your reference (not parsed).
638
						</td>
639
					</tr>
640
					<tr>
641
						<td colspan="2" class="list" height="12"></td>
642
					</tr>
643
					<tr>
644
						<td colspan="2" valign="top" class="listtopic">Cryptographic Settings</td>
645
					</tr>
646 3c11bd3c Matthew Grooms
					<tr id="tls">
647
						<td width="22%" valign="top" class="vncellreq">TLS Authentication</td>
648
						<td width="78%" class="vtable">
649
							<table border="0" cellpadding="2" cellspacing="0">
650
								<tr>
651
									<td>
652
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
653
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onClick="tlsauth_change()">
654
									</td>
655
									<td>
656
										<span class="vexpl">
657
											Enable authentication of TLS packets.
658
										</span>
659
									</td>
660
								</tr>
661
							</table>
662
							<?php if (!$pconfig['tls']): ?>
663
							<table border="0" cellpadding="2" cellspacing="0" id='tlsauth_opts'>
664
								<tr>
665
									<td>
666
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
667
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autotls_change()">
668
									</td>
669
									<td>
670
										<span class="vexpl">
671
											Automatically generate a shared TLS authentication key.
672
										</span>
673
									</td>
674
								</tr>
675
							</table>
676
							<?php endif; ?>
677
							<table border="0" cellpadding="2" cellspacing="0" id='autotls_opts'>
678
								<tr>
679
									<td>
680
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
681
										<br/>
682
										Paste your shared key here.
683
									</td>
684
								</tr>
685
							</table>
686
						</td>
687 d799787e Matthew Grooms
					</tr>
688 3c11bd3c Matthew Grooms
					<tr id="tls_ca">
689
						<td width="22%" valign="top" class="vncellreq">Peer Certificate Authority</td>
690 d799787e Matthew Grooms
							<td width="78%" class="vtable">
691
							<select name='caref' class="formselect">
692
							<?php
693
								foreach ($config['system']['ca'] as $ca):
694
									$selected = "";
695
									if ($pconfig['caref'] == $ca['refid'])
696
										$selected = "selected";
697
							?>
698
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['name'];?></option>
699
							<?php endforeach; ?>
700
							</select>
701
							</td>
702
					</tr>
703 3c11bd3c Matthew Grooms
					<tr id="tls_cert">
704
						<td width="22%" valign="top" class="vncellreq">Server Certificate</td>
705 d799787e Matthew Grooms
							<td width="78%" class="vtable">
706
							<select name='certref' class="formselect">
707
							<?php
708
								foreach ($config['system']['cert'] as $cert):
709
									$selected = "";
710 05657769 Ermal Lu?i
									if (strstr($cert['name'], "webConfigurator"))
711
										continue;
712 d799787e Matthew Grooms
									if ($pconfig['certref'] == $cert['refid'])
713
										$selected = "selected";
714
							?>
715
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
716
							<?php endforeach; ?>
717
							</select>
718
						</td>
719
					</tr>
720 fe787fc7 Matthew Grooms
					<tr id="tls_dh">
721
						<td width="22%" valign="top" class="vncellreq">DH Parameters Length</td>
722
						<td width="78%" class="vtable">
723
							<select name="dh_length" class="formselect">
724
								<?php
725
									foreach ($openvpn_dh_lengths as $length):
726
									$selected = '';
727
									if ($length == $pconfig['dh_length'])
728
										$selected = ' selected';
729
								?>
730
								<option<?=$selected?>><?=$length;?></option>
731
								<?php endforeach; ?>
732
							</select>
733
							<span class="vexpl">
734
								bits
735
							</span>
736
						</td>
737
					</tr>
738 d799787e Matthew Grooms
					<tr id="psk">
739
						<td width="22%" valign="top" class="vncellreq">Shared Key</td>
740 3c11bd3c Matthew Grooms
						<td width="78%" class="vtable">
741
							<?php if (!$pconfig['shared_key']): ?>
742
							<table border="0" cellpadding="2" cellspacing="0">
743
								<tr>
744
									<td>
745
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
746
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autokey_change()">
747
									</td>
748
									<td>
749
										<span class="vexpl">
750
											Automatically generate a shared key.
751
										</span>
752
									</td>
753
								</tr>
754
							</table>
755
							<?php endif; ?>
756
							<table border="0" cellpadding="2" cellspacing="0" id='autokey_opts'>
757
								<tr>
758
									<td>
759
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
760
										<br/>
761
										Paste your shared key here.
762
									</td>
763
								</tr>
764
							</table>
765 d799787e Matthew Grooms
						</td>
766
					</tr>
767
					<tr>
768
						<td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
769
						<td width="78%" class="vtable">
770
							<select name="crypto" class="formselect">
771
								<?php
772
									$cipherlist = openvpn_get_cipherlist();
773
									foreach ($cipherlist as $name => $desc):
774
									$selected = '';
775
									if ($name == $pconfig['crypto'])
776
										$selected = ' selected';
777
								?>
778
								<option value="<?=$name;?>"<?=$selected?>>
779
									<?=htmlspecialchars($desc);?>
780
								</option>
781
								<?php endforeach; ?>
782
							</select>
783
						</td>
784
					</tr>
785
					<tr>
786
						<td colspan="2" class="list" height="12"></td>
787
					</tr>
788
					<tr>
789
						<td colspan="2" valign="top" class="listtopic">Tunnel Settings</td>
790
					</tr>
791
					<tr>
792
						<td width="22%" valign="top" class="vncellreq">Tunnel Network</td>
793
						<td width="78%" class="vtable">
794
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
795
							<br>
796
							This is the virtual network used for private
797
							communications between this server and client
798
							hosts expressed using CIDR (eg. 10.0.8.0/24).
799
							The first network address will be assigned to
800
							the	server virtual interface. The remaining
801
							network addresses can optionally be assigned
802
							to connecting clients. (see Address Pool)
803
						</td>
804
					</tr>
805
					<tr>
806
						<td width="22%" valign="top" class="vncell">Redirect Gateway</td>
807
						<td width="78%" class="vtable">
808
							<table border="0" cellpadding="2" cellspacing="0">
809
								<tr>
810
									<td>
811
										<?php set_checked($pconfig['gwredir'],$chk); ?>
812
										<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> onClick="gwredir_change()"/>
813
									</td>
814
									<td>
815
										<span class="vexpl">
816
											Force all client generated traffic through the tunnel.
817
										</span>
818
									</td>
819
								</tr>
820
							</table>
821
						</td>
822
					</tr>
823
					<tr id="local_opts">
824
						<td width="22%" valign="top" class="vncell">Local Network</td>
825
						<td width="78%" class="vtable">
826
							<input name="local_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['local_network']);?>">
827
							<br>
828 6bc6bf79 Chris Buechler
							This is the network that will be accessible
829 d799787e Matthew Grooms
							from the remote endpoint. Expressed as a CIDR
830
							range. You may leave this blank if you don't
831
							want to add a route to the local network
832
							through this tunnel on the remote machine.
833
							This is generally set to your LAN network.
834
						</td>
835
					</tr>
836 3c11bd3c Matthew Grooms
					<tr id="remote_opts">
837
						<td width="22%" valign="top" class="vncell">Remote Network</td>
838
						<td width="78%" class="vtable">
839
							<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
840
							<br>
841
							This is a network that will be routed through
842
							the tunnel, so that a site-to-site VPN can be
843
							established without manually changing the
844
							routing tables. Expressed as a CIDR range. If
845
							this is a site-to-site VPN, enter here the
846
							remote LAN here. You may leave this blank if
847
							you don't want a site-to-site VPN.
848
						</td>
849
					</tr>
850 d799787e Matthew Grooms
					<tr>
851
						<td width="22%" valign="top" class="vncell"><?=gettext("Concurrent connections");?></td>
852
						<td width="78%" class="vtable">
853
							<input name="maxclients" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['maxclients']);?>"/>
854
							<br/>
855
							Specify the maximum number of clients allowed to concurrently connect to this server.
856
						</td>
857
					</tr>
858
					<tr>
859
						<td width="22%" valign="top" class="vncell">Compression</td>
860
						<td width="78%" class="vtable">
861
							<table border="0" cellpadding="2" cellspacing="0">
862
								<tr>
863
									<td>
864
										<?php set_checked($pconfig['compression'],$chk); ?>
865
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
866
									</td>
867
									<td>
868
										<span class="vexpl">
869
											Compress tunnel packets using the LZO algorithm.
870
										</span>
871
									</td>
872
								</tr>
873
							</table>
874
						</td>
875
					</tr>
876
					<tr>
877
						<td width="22%" valign="top" class="vncell">Type-of-Service</td>
878
						<td width="78%" class="vtable">
879
							<table border="0" cellpadding="2" cellspacing="0">
880
								<tr>
881
									<td>
882 1cb0b40a Matthew Grooms
										<?php set_checked($pconfig['passtos'],$chk); ?>
883
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?>>
884 d799787e Matthew Grooms
									</td>
885
									<td>
886
										<span class="vexpl">
887
											Set the TOS IP header value of tunnel packets to match the encapsulated packet value.
888
										</span>
889
									</td>
890
								</tr>
891
							</table>
892
						</td>
893
					</tr>
894
					<tr>
895
						<td width="22%" valign="top" class="vncell">Inter-client communication</td>
896
						<td width="78%" class="vtable">
897
							<table border="0" cellpadding="2" cellspacing="0">
898
								<tr>
899
									<td>
900
										<?php set_checked($pconfig['client2client'],$chk); ?>
901
										<input name="client2client" type="checkbox" value="yes" <?=$chk;?>/>
902
									</td>
903
									<td>
904
										<span class="vexpl">
905
											Allow communication between clients connected to this server
906
										</span>
907
									</td>
908
								</tr>
909
							</table>
910
						</td>
911
					</tr>
912 3c11bd3c Matthew Grooms
				</table>
913
914
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
915 d799787e Matthew Grooms
					<tr>
916
						<td colspan="2" class="list" height="12"></td>
917
					</tr>
918
					<tr>
919
						<td colspan="2" valign="top" class="listtopic">Client Settings</td>
920
					</tr>
921 65ff8497 jim-p
					<tr>
922
						<td width="22%" valign="top" class="vncell">Dynamic IP</td>
923
						<td width="78%" class="vtable">
924
							<table border="0" cellpadding="2" cellspacing="0">
925
								<tr>
926
									<td>
927
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
928
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?>">
929
									</td>
930
									<td>
931
										<span class="vexpl">
932 599d5c62 jim-p
											Allow connected clients to retain their connections if their IP address changes.<br>
933 65ff8497 jim-p
										</span>
934
									</td>
935
								</tr>
936
							</table>
937
						</td>
938
					</tr>
939 d799787e Matthew Grooms
					<tr>
940
						<td width="22%" valign="top" class="vncell">Address Pool</td>
941
						<td width="78%" class="vtable">
942
							<table border="0" cellpadding="2" cellspacing="0">
943
								<tr>
944
									<td>
945
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
946
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>">
947
									</td>
948
									<td>
949
										<span class="vexpl">
950
											Provide a virtual adapter IP address to clients (see Tunnel Network)<br>
951
										</span>
952
									</td>
953
								</tr>
954
							</table>
955
						</td>
956
					</tr>
957
					<tr>
958
						<td width="22%" valign="top" class="vncell">DNS Default Domain</td>
959
						<td width="78%" class="vtable">
960
							<table border="0" cellpadding="2" cellspacing="0">
961
								<tr>
962
									<td>
963
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
964
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
965
									</td>
966
									<td>
967
										<span class="vexpl">
968
	                                        Provide a default domain name to clients<br>
969
										</span>
970
									</td>
971
								</tr>
972
							</table>
973
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
974
								<tr>
975
									<td>
976
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
977
									</td>
978
								</tr>
979
							</table>
980
						</td>
981
					</tr>
982
					<tr>
983
						<td width="22%" valign="top" class="vncell">DNS Servers</td>
984
						<td width="78%" class="vtable">
985
							<table border="0" cellpadding="2" cellspacing="0">
986
								<tr>
987
									<td>
988
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
989
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
990
									</td>
991
									<td>
992
										<span class="vexpl">
993
											Provide a DNS server list to clients<br>
994
										</span>
995
									</td>
996
								</tr>
997
							</table>
998
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
999
								<tr>
1000
									<td>
1001
										<span class="vexpl">
1002
											Server #1:&nbsp;
1003
										</span>
1004
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=$pconfig['dns_server1'];?>">
1005
									</td>
1006
								</tr>
1007
								<tr>
1008
									<td>
1009
										<span class="vexpl">
1010
											Server #2:&nbsp;
1011
										</span>
1012
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=$pconfig['dns_server2'];?>">
1013
									</td>
1014
								</tr>
1015
								<tr>
1016
									<td>
1017
										<span class="vexpl">
1018
											Server #3:&nbsp;
1019
										</span>
1020
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=$pconfig['dns_server3'];?>">
1021
									</td>
1022
								</tr>
1023
								<tr>
1024
									<td>
1025
										<span class="vexpl">
1026
											Server #4:&nbsp;
1027
										</span>
1028
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=$pconfig['dns_server4'];?>">
1029
									</td>
1030
								</tr>
1031
							</table>
1032
						</td>
1033
					</tr>
1034
					<tr>
1035
						<td width="22%" valign="top" class="vncell">NTP Servers</td>
1036
						<td width="78%" class="vtable">
1037
							<table border="0" cellpadding="2" cellspacing="0">
1038
								<tr>
1039
									<td>
1040
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1041
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
1042
									</td>
1043
									<td>
1044
										<span class="vexpl">
1045
											Provide a NTP server list to clients<br>
1046
										</span>
1047
									</td>
1048
								</tr>
1049
							</table>
1050
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
1051
								<tr>
1052
									<td>
1053
										<span class="vexpl">
1054
											Server #1:&nbsp;
1055
										</span>
1056
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=$pconfig['ntp_server1'];?>">
1057
									</td>
1058
								</tr>
1059
								<tr>
1060
									<td>
1061
										<span class="vexpl">
1062
											Server #2:&nbsp;
1063
										</span>
1064
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=$pconfig['ntp_server2'];?>">
1065
									</td>
1066
								</tr>
1067
							</table>
1068
						</td>
1069
					</tr>
1070
					<tr>
1071
						<td width="22%" valign="top" class="vncell">NetBIOS Options</td>
1072
						<td width="78%" class="vtable">
1073
							<table border="0" cellpadding="2" cellspacing="0">
1074
								<tr>
1075
									<td>
1076
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1077
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
1078
									</td>
1079
									<td>
1080
										<span class="vexpl">
1081
											Enable NetBIOS over TCP/IP<br>
1082
										</span>
1083
									</td>
1084
								</tr>
1085
							</table>
1086 f31607c5 Chris Buechler
							If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled.
1087 d799787e Matthew Grooms
							<br/>
1088
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
1089
								<tr>
1090
									<td>
1091
										<br/>
1092
										<span class="vexpl">
1093
											Node Type:&nbsp;
1094
										</span>
1095
										<select name='netbios_ntype' class="formselect">
1096
										<?php
1097
											foreach ($netbios_nodetypes as $type => $name):
1098
												$selected = "";
1099
												if ($pconfig['netbios_ntype'] == $type)
1100
													$selected = "selected";
1101
										?>
1102
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1103
										<?php endforeach; ?>
1104
										</select>
1105
										<br/>
1106
										Possible options: b-node (broadcasts), p-node
1107
										(point-to-point name queries to a WINS server),
1108
										m-node (broadcast then query name server), and
1109
										h-node (query name server, then broadcast).
1110
									</td>
1111
								</tr>
1112
								<tr>
1113
									<td>
1114
										<br/>
1115
										<span class="vexpl">
1116
											Scope ID:&nbsp;
1117
										</span>
1118
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
1119
										<br/>
1120
										A NetBIOS Scope	ID provides an extended naming
1121
										service for	NetBIOS over TCP/IP. The NetBIOS
1122
										scope ID isolates NetBIOS traffic on a single
1123
										network to only those nodes with the same
1124
										NetBIOS scope ID.
1125
									</td>
1126
								</tr>
1127
							</table>
1128
						</td>
1129
					</tr>
1130
					<tr id="wins_opts">
1131
						<td width="22%" valign="top" class="vncell">WINS Servers</td>
1132
						<td width="78%" class="vtable">
1133
							<table border="0" cellpadding="2" cellspacing="0">
1134
								<tr>
1135
									<td>
1136
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1137
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
1138
									</td>
1139
									<td>
1140
										<span class="vexpl">
1141
											Provide a WINS server list to clients<br>
1142
										</span>
1143
									</td>
1144
								</tr>
1145
							</table>
1146
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
1147
								<tr>
1148
									<td>
1149
										<span class="vexpl">
1150
											Server #1:&nbsp;
1151
										</span>
1152
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=$pconfig['wins_server1'];?>">
1153
									</td>
1154
								</tr>
1155
								<tr>
1156
									<td>
1157
										<span class="vexpl">
1158
											Server #2:&nbsp;
1159
										</span>
1160
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=$pconfig['wins_server2'];?>">
1161
									</td>
1162
								</tr>
1163
							</table>
1164
						</td>
1165
					</tr>
1166 3c11bd3c Matthew Grooms
				</table>
1167
1168 2f4f30ee Scott Ullrich
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1169
					<tr>
1170
						<td colspan="2" class="list" height="12"></td>
1171
					</tr>
1172
					<tr>
1173
						<td colspan="2" valign="top" class="listtopic">Advanced configuration</td>
1174
					</tr>
1175
					<tr>
1176 6804263e Scott Ullrich
						<td width="22%" valign="top" class="vncell">Advanced</td>
1177 2f4f30ee Scott Ullrich
						<td width="78%" class="vtable">
1178
							<table border="0" cellpadding="2" cellspacing="0">
1179
								<tr>
1180
									<td>
1181 a9a613dd Scott Ullrich
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];?></textarea><br/>
1182 1a4f9b42 Chris Buechler
										Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon<br/>
1183 53be9d3c Scott Ullrich
										EXAMPLE: push "route 10.0.0.0 255.255.255.0";
1184 2f4f30ee Scott Ullrich
									</td>
1185
								</tr>
1186
							</table>
1187
						</td>
1188
					</tr>
1189
				</table>
1190
1191 f68fc963 Scott Ullrich
				<br/>
1192
1193 3c11bd3c Matthew Grooms
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1194 d799787e Matthew Grooms
					<tr>
1195
						<td width="22%" valign="top">&nbsp;</td>
1196
						<td width="78%"> 
1197
							<input name="save" type="submit" class="formbtn" value="Save"> 
1198
							<input name="act" type="hidden" value="<?=$act;?>">
1199
							<?php if (isset($id) && $a_server[$id]): ?>
1200
							<input name="id" type="hidden" value="<?=$id;?>">
1201
							<?php endif; ?>
1202
						</td>
1203
					</tr>
1204
				</table>
1205
			</form>
1206
1207
			<?php else: ?>
1208
1209 7128ed17 Scott Ullrich
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1210 d799787e Matthew Grooms
				<tr>
1211
					<td width="10%" class="listhdrr">Disabled</td>
1212 43cea754 Chris Buechler
					<td width="10%" class="listhdrr">Protocol / Port</td>
1213 d799787e Matthew Grooms
					<td width="30%" class="listhdrr">Tunnel Network</td>
1214
					<td width="40%" class="listhdrr">Description</td>
1215
					<td width="10%" class="list"></td>
1216
				</tr>
1217
				<?php
1218
					$i = 0;
1219
					foreach($a_server as $server):
1220
						$disabled = "NO";
1221 870318b9 Ermal Lu?i
						if (isset($server['disable']))
1222 d799787e Matthew Grooms
							$disabled = "YES";
1223
				?>
1224
				<tr>
1225 d3d9b0ee Scott Ullrich
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1226 d799787e Matthew Grooms
						<?=$disabled;?>
1227
					</td>
1228 d3d9b0ee Scott Ullrich
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1229 43cea754 Chris Buechler
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1230 d799787e Matthew Grooms
					</td>
1231 d3d9b0ee Scott Ullrich
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1232 d799787e Matthew Grooms
						<?=htmlspecialchars($server['tunnel_network']);?>
1233
					</td>
1234 d3d9b0ee Scott Ullrich
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1235 d799787e Matthew Grooms
						<?=htmlspecialchars($server['description']);?>
1236
					</td>
1237
					<td valign="middle" nowrap class="list">
1238
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1239
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit server" width="17" height="17" border="0">
1240
						</a>
1241
						&nbsp;
1242
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this server?')">
1243
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete server" width="17" height="17" border="0">
1244
						</a>
1245
					</td>
1246
				</tr>
1247
				<?php
1248
					$i++;
1249
					endforeach;
1250
				?>
1251
				<tr>
1252
					<td class="list" colspan="4"></td>
1253
					<td class="list">
1254
						<a href="vpn_openvpn_server.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="add server" width="17" height="17" border="0">
1255
						</a>
1256
					</td>
1257
				</tr>
1258
			</table>
1259
1260 7128ed17 Scott Ullrich
			<?=gettext("Additional OpenVPN servers can be added here.");?>
1261
1262 d799787e Matthew Grooms
			<? endif; ?>
1263
1264
		</td>
1265
	</tr>
1266
</table>
1267
<script language="JavaScript">
1268
<!--
1269 3c11bd3c Matthew Grooms
mode_change();
1270
autokey_change();
1271
tlsauth_change();
1272 d799787e Matthew Grooms
gwredir_change();
1273
dns_domain_change();
1274
dns_server_change();
1275
wins_server_change();
1276
ntp_server_change();
1277
netbios_change();
1278
//-->
1279
</script>
1280
</body>
1281
<?php include("fend.inc"); ?>
1282
1283
<?php
1284
1285
/* local utility functions */
1286
1287
function set_checked($var,& $chk) {
1288
    if($var)
1289
        $chk = 'checked';
1290
    else
1291
        $chk = '';
1292
}
1293
1294 43cea754 Chris Buechler
?>