Project

General

Profile

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