Project

General

Profile

Download (47.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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
require_once("openvpn.inc");
39

    
40
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
41
$statusurl = "status_openvpn.php";
42
$logurl = "diag_logs_openvpn.php";
43

    
44
if (!is_array($config['openvpn']['openvpn-server']))
45
	$config['openvpn']['openvpn-server'] = array();
46

    
47
$a_server = &$config['openvpn']['openvpn-server'];
48

    
49
$id = $_GET['id'];
50
if (isset($_POST['id']))
51
	$id = $_POST['id'];
52

    
53
$act = $_GET['act'];
54
if (isset($_POST['act']))
55
	$act = $_POST['act'];
56

    
57
if ($_GET['act'] == "del") {
58

    
59
	if (!$a_server[$id]) {
60
		pfSenseHeader("vpn_openvpn_server.php");
61
		exit;
62
	}
63

    
64
	openvpn_delete('server', $a_server[$id]);
65
	unset($a_server[$id]);
66
	write_config();
67
	$savemsg = gettext("Server successfully deleted")."<br/>";
68
}
69

    
70
if($_GET['act']=="new"){
71
	$pconfig['autokey_enable'] = "yes";
72
	$pconfig['tlsauth_enable'] = "yes";
73
	$pconfig['autotls_enable'] = "yes";
74
	$pconfig['dh_length'] = 1024;
75
	$pconfig['interface'] = "wan";
76
	$pconfig['local_port'] = openvpn_port_next('UDP');
77
	$pconfig['pool_enable'] = "yes";
78
}
79

    
80
if($_GET['act']=="edit"){
81

    
82
	if (isset($id) && $a_server[$id]) {
83

    
84
		$pconfig['disable'] = isset($a_server[$id]['disable']);
85
		$pconfig['mode'] = $a_server[$id]['mode'];
86
		$pconfig['protocol'] = $a_server[$id]['protocol'];
87
		$pconfig['authmode'] = $a_server[$id]['authmode'];
88
		$pconfig['interface'] = $a_server[$id]['interface'];
89
		if (!empty($a_server[$id]['ipaddr'])) {
90
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_server[$id]['ipaddr'];
91
		}
92
		$pconfig['local_port'] = $a_server[$id]['local_port'];
93
		$pconfig['description'] = $a_server[$id]['description'];
94
		$pconfig['custom_options'] = $a_server[$id]['custom_options'];
95

    
96
		if ($pconfig['mode'] != "p2p_shared_key") {
97
			if ($a_server[$id]['tls']) {
98
				$pconfig['tlsauth_enable'] = "yes";
99
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
100
			}
101
			$pconfig['caref'] = $a_server[$id]['caref'];
102
			$pconfig['certref'] = $a_server[$id]['certref'];
103
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
104
		} else
105
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
106
		$pconfig['crypto'] = $a_server[$id]['crypto'];
107

    
108
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
109
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
110
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
111
		$pconfig['local_network'] = $a_server[$id]['local_network'];
112
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
113
		$pconfig['compression'] = $a_server[$id]['compression'];
114
		$pconfig['passtos'] = $a_server[$id]['passtos'];
115
		$pconfig['client2client'] = $a_server[$id]['client2client'];
116

    
117
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
118
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
119

    
120
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
121
		if ($pconfig['dns_domain'])
122
			$pconfig['dns_domain_enable'] = true;
123

    
124
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
125
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
126
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
127
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
128
		if ($pconfig['dns_server1'] ||
129
			$pconfig['dns_server2'] ||
130
			$pconfig['dns_server3'] ||
131
			$pconfig['dns_server4'])
132
			$pconfig['dns_server_enable'] = true;
133

    
134
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
135
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
136
		if ($pconfig['ntp_server1'] ||
137
			$pconfig['ntp_server2'])
138
			$pconfig['ntp_server_enable'] = true;
139

    
140
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
141
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
142
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
143

    
144
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
145
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
146
		if ($pconfig['wins_server1'] ||
147
			$pconfig['wins_server2'])
148
			$pconfig['wins_server_enable'] = true;
149

    
150
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
151
		if ($pconfig['nbdd_server1'])
152
			$pconfig['nbdd_server_enable'] = true;
153

    
154
		// just in case the modes switch
155
		$pconfig['autokey_enable'] = "yes";
156
		$pconfig['autotls_enable'] = "yes";
157
	}
158
}
159

    
160
if ($_POST) {
161

    
162
	unset($input_errors);
163
	$pconfig = $_POST;
164

    
165
	if (isset($id) && $a_server[$id])
166
		$vpnid = $a_server[$id]['vpnid'];
167
	else
168
		$vpnid = 0;
169

    
170
	if ($pconfig['mode'] != "p2p_shared_key")
171
		$tls_mode = true;
172
	else
173
		$tls_mode = false;
174

    
175
	if (!empty($pconfig['authmode'])) {
176
		foreach ($pconfig['authmode'] as $pauthmode) {
177
			if ($pauthmode != "Local Database" && $pconfig['mode'] == "server_tls_user") 
178
				$input_errors[] = gettext("Only 'Local authentication database'  is allowed with") . " " . $openvpn_server_modes[$pconfig['mode']];
179
		}
180
	}
181

    
182
	if (empty($pconfig['authmode']) && (($pconfig['mode'] == "server_user") || ($pconfig['mode'] == "server_tls_user")))
183
		$input_errors[] = gettext("You must select a Backend for Authentication if the server mode requires User Auth.");
184

    
185
	/* input validation */
186
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
187
		$input_errors[] = $result;
188

    
189
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
190
		$input_errors[] = $result;
191

    
192
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
193
		$input_errors[] = $result;
194

    
195
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
196
		$input_errors[] = $result;
197

    
198
	$portused = openvpn_port_used($pconfig['protocol'], $pconfig['local_port']);
199
	if (($portused != $vpnid) && ($portused != 0))
200
		$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
201

    
202
	if ($pconfig['autokey_enable'])
203
		$pconfig['shared_key'] = openvpn_create_key();
204

    
205
	if (!$tls_mode && !$pconfig['autokey_enable'])
206
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
207
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
208
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
209

    
210
	if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
211
		if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
212
			!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
213
			$input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid");
214

    
215
	if ($pconfig['dns_server_enable']) {
216
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
217
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
218
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
219
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
220
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
221
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
222
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
223
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
224
	}
225

    
226
	if ($pconfig['ntp_server_enable']) {
227
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
228
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
229
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
230
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
231
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
232
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
233
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
234
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
235
	}
236

    
237
	if ($pconfig['netbios_enable']) {
238
		if ($pconfig['wins_server_enable']) {
239
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
240
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
241
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
242
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
243
		}
244
		if ($pconfig['nbdd_server_enable'])
245
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
246
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
247
	}
248

    
249
	if ($pconfig['maxclients'] && !is_numeric($pconfig['maxclients']))
250
		$input_errors[] = gettext("The field 'Concurrent connections' must be numeric.");
251

    
252
	/* If we are not in shared key mode, then we need the CA/Cert. */
253
	if ($pconfig['mode'] != "p2p_shared_key") {
254
		$reqdfields = explode(" ", "caref certref");
255
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
256
	} elseif (!$pconfig['autokey_enable']) {
257
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
258
		$reqdfields = array('shared_key');
259
		$reqdfieldsn = array(gettext('Shared key'));
260
	}
261

    
262
	$reqdfields[] = 'tunnel_network';
263
	$reqdfieldsn[] = gettext('Tunnel network');
264

    
265
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
266
	
267
	if (!$input_errors) {
268

    
269
		$server = array();
270

    
271
		if ($vpnid)
272
			$server['vpnid'] = $vpnid;
273
		else
274
			$server['vpnid'] = openvpn_vpnid_next();
275

    
276
		if ($_POST['disable'] == "yes")
277
			$server['disable'] = true;
278
		$server['mode'] = $pconfig['mode'];
279
		if (!empty($pconfig['authmode']))
280
			$server['authmode'] = implode(",", $pconfig['authmode']);
281
		$server['protocol'] = $pconfig['protocol'];
282
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
283
		$server['local_port'] = $pconfig['local_port'];
284
		$server['description'] = $pconfig['description'];
285
		$server['custom_options'] = $pconfig['custom_options'];
286

    
287
		if ($tls_mode) {
288
			if ($pconfig['tlsauth_enable']) {
289
				if ($pconfig['autotls_enable'])
290
					$pconfig['tls'] = openvpn_create_key();
291
				$server['tls'] = base64_encode($pconfig['tls']);
292
			}
293
			$server['caref'] = $pconfig['caref'];
294
			$server['certref'] = $pconfig['certref'];
295
			$server['dh_length'] = $pconfig['dh_length'];
296
		} else {
297
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
298
		}
299
		$server['crypto'] = $pconfig['crypto'];
300

    
301
		$server['tunnel_network'] = $pconfig['tunnel_network'];
302
		$server['remote_network'] = $pconfig['remote_network'];
303
		$server['gwredir'] = $pconfig['gwredir'];
304
		$server['local_network'] = $pconfig['local_network'];
305
		$server['maxclients'] = $pconfig['maxclients'];
306
		$server['compression'] = $pconfig['compression'];
307
		$server['passtos'] = $pconfig['passtos'];
308
		$server['client2client'] = $pconfig['client2client'];
309

    
310
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
311
		$server['pool_enable'] = $pconfig['pool_enable'];
312

    
313
		if ($pconfig['dns_domain_enable'])
314
			$server['dns_domain'] = $pconfig['dns_domain'];
315

    
316
		if ($pconfig['dns_server_enable']) {
317
			$server['dns_server1'] = $pconfig['dns_server1'];
318
			$server['dns_server2'] = $pconfig['dns_server2'];
319
			$server['dns_server3'] = $pconfig['dns_server3'];
320
			$server['dns_server4'] = $pconfig['dns_server4'];
321
		}
322

    
323
		if ($pconfig['ntp_server_enable']) {
324
			$server['ntp_server1'] = $pconfig['ntp_server1'];
325
			$server['ntp_server2'] = $pconfig['ntp_server2'];
326
		}
327

    
328
		$server['netbios_enable'] = $pconfig['netbios_enable'];
329
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
330
		$server['netbios_scope'] = $pconfig['netbios_scope'];
331

    
332
		if ($pconfig['netbios_enable']) {
333

    
334
			if ($pconfig['wins_server_enable']) {
335
				$server['wins_server1'] = $pconfig['wins_server1'];
336
				$server['wins_server2'] = $pconfig['wins_server2'];
337
			}
338

    
339
			if ($pconfig['dns_server_enable'])
340
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
341
		}
342
	
343
		if (isset($id) && $a_server[$id])
344
			$a_server[$id] = $server;
345
		else
346
			$a_server[] = $server;
347

    
348
		openvpn_resync('server', $server);
349
		write_config();
350
		
351
		header("Location: vpn_openvpn_server.php");
352
		exit;
353
	}
354
	if (!empty($pconfig['authmode']))
355
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
356
}
357

    
358
include("head.inc");
359

    
360
?>
361

    
362
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
363
<?php include("fbegin.inc"); ?>
364
<script language="JavaScript">
365
<!--
366

    
367
function mode_change() {
368
	index = document.iform.mode.selectedIndex;
369
	value = document.iform.mode.options[index].value;
370
	switch(value) {
371
		case "p2p_tls":
372
		case "server_tls":
373
		case "server_user":
374
		case "server_tls_user":
375
			document.getElementById("tls").style.display="";
376
			document.getElementById("tls_ca").style.display="";
377
			document.getElementById("tls_cert").style.display="";
378
			document.getElementById("tls_dh").style.display="";
379
			document.getElementById("psk").style.display="none";
380
			break;
381
		case "p2p_shared_key":
382
			document.getElementById("tls").style.display="none";
383
			document.getElementById("tls_ca").style.display="none";
384
			document.getElementById("tls_cert").style.display="none";
385
			document.getElementById("tls_dh").style.display="none";
386
			document.getElementById("psk").style.display="";
387
			break;
388
	}
389
	switch(value) {
390
		case "p2p_shared_key":
391
			document.getElementById("client_opts").style.display="none";
392
			document.getElementById("remote_opts").style.display="";
393
			document.getElementById("local_opts").style.display="none";
394
			document.getElementById("authmodetr").style.display="none";
395
			document.getElementById("inter_client_communication").style.display="none";
396
			break;
397
		case "p2p_tls":
398
			document.getElementById("client_opts").style.display="none";
399
			document.getElementById("remote_opts").style.display="";
400
			document.getElementById("local_opts").style.display="";
401
			document.getElementById("authmodetr").style.display="none";
402
			document.getElementById("inter_client_communication").style.display="none";
403
			break;
404
		case "server_user":
405
                case "server_tls_user":
406
			document.getElementById("authmodetr").style.display="";
407
			document.getElementById("client_opts").style.display="";
408
			document.getElementById("remote_opts").style.display="none";
409
			document.getElementById("local_opts").style.display="";
410
			document.getElementById("inter_client_communication").style.display="";
411
			break;
412
		case "server_tls":
413
			document.getElementById("authmodetr").style.display="none";
414
		default:
415
			document.getElementById("client_opts").style.display="";
416
			document.getElementById("remote_opts").style.display="none";
417
			document.getElementById("local_opts").style.display="";
418
			document.getElementById("inter_client_communication").style.display="";
419
			break;
420
	}
421
}
422

    
423
function autokey_change() {
424

    
425
	if (document.iform.autokey_enable.checked)
426
		document.getElementById("autokey_opts").style.display="none";
427
	else
428
		document.getElementById("autokey_opts").style.display="";
429
}
430

    
431
function tlsauth_change() {
432

    
433
<?php if (!$pconfig['tls']): ?>
434
	if (document.iform.tlsauth_enable.checked)
435
		document.getElementById("tlsauth_opts").style.display="";
436
	else
437
		document.getElementById("tlsauth_opts").style.display="none";
438
<?php endif; ?>
439

    
440
	autotls_change();
441
}
442

    
443
function autotls_change() {
444

    
445
<?php if (!$pconfig['tls']): ?>
446
	autocheck = document.iform.autotls_enable.checked;
447
<?php else: ?>
448
	autocheck = false;
449
<?php endif; ?>
450

    
451
	if (document.iform.tlsauth_enable.checked && !autocheck)
452
		document.getElementById("autotls_opts").style.display="";
453
	else
454
		document.getElementById("autotls_opts").style.display="none";
455
}
456

    
457
function gwredir_change() {
458

    
459
	if (document.iform.gwredir.checked)
460
		document.getElementById("local_opts").style.display="none";
461
	else
462
		document.getElementById("local_opts").style.display="";
463
}
464

    
465
function dns_domain_change() {
466

    
467
	if (document.iform.dns_domain_enable.checked)
468
		document.getElementById("dns_domain_data").style.display="";
469
	else
470
		document.getElementById("dns_domain_data").style.display="none";
471
}
472

    
473
function dns_server_change() {
474

    
475
	if (document.iform.dns_server_enable.checked)
476
		document.getElementById("dns_server_data").style.display="";
477
	else
478
		document.getElementById("dns_server_data").style.display="none";
479
}
480

    
481
function wins_server_change() {
482

    
483
	if (document.iform.wins_server_enable.checked)
484
		document.getElementById("wins_server_data").style.display="";
485
	else
486
		document.getElementById("wins_server_data").style.display="none";
487
}
488

    
489
function ntp_server_change() {
490

    
491
	if (document.iform.ntp_server_enable.checked)
492
		document.getElementById("ntp_server_data").style.display="";
493
	else
494
		document.getElementById("ntp_server_data").style.display="none";
495
}
496

    
497
function netbios_change() {
498

    
499
	if (document.iform.netbios_enable.checked) {
500
		document.getElementById("netbios_data").style.display="";
501
		document.getElementById("wins_opts").style.display="";
502
	} else {
503
		document.getElementById("netbios_data").style.display="none";
504
		document.getElementById("wins_opts").style.display="none";
505
	}
506
}
507

    
508
//-->
509
</script>
510
<?php
511
	if ($input_errors)
512
		print_input_errors($input_errors);
513
	if ($savemsg)
514
		print_info_box($savemsg);
515
?>
516
<table width="100%" border="0" cellpadding="0" cellspacing="0">
517
	<tr>
518
		<td class="tabnavtbl">
519
			<ul id="tabnav">
520
			<?php 
521
				$tab_array = array();
522
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
523
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
524
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
525
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
526
				add_package_tabs("OpenVPN", $tab_array);
527
				display_top_tabs($tab_array);
528
			?>
529
			</ul>
530
		</td>
531
	</tr>    
532
	<tr>
533
		<td class="tabcont">
534

    
535
			<?php if($act=="new" || $act=="edit"): ?>
536

    
537
			<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
538
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
539
					<tr>
540
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
541
					</tr>
542
					<tr>
543
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
544
						<td width="78%" class="vtable">
545
							<table border="0" cellpadding="0" cellspacing="0">
546
								<tr>
547
									<td>
548
										<?php set_checked($pconfig['disable'],$chk); ?>
549
										<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
550
									</td>
551
									<td>
552
										&nbsp;
553
										<span class="vexpl">
554
											<strong><?=gettext("Disable this server"); ?></strong><br>
555
										</span>
556
									</td>
557
								</tr>
558
							</table>
559
							<?=gettext("Set this option to disable this server without removing it from the list"); ?>.
560
						</td>
561
					</tr>
562
					<tr>
563
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
564
							<td width="78%" class="vtable">
565
							<select name='mode' id='mode' class="formselect" onchange='mode_change()'>
566
							<?php
567
								foreach ($openvpn_server_modes as $name => $desc):
568
									$selected = "";
569
									if ($pconfig['mode'] == $name)
570
										$selected = "selected";
571
							?>
572
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
573
							<?php endforeach; ?>
574
							</select>
575
						</td>
576
					</tr>
577
					<tr id="authmodetr" style="display:none">
578
                                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Backend for authentication");?></td>
579
                                                        <td width="78%" class="vtable">
580
                                                        <select name='authmode[]' id='authmode' class="formselect" multiple="true" size="<?php echo count($auth_servers); ?>">
581
							<?php $authmodes = explode(",", $pconfig['authmode']); ?>
582
                                                        <?php
583
								$auth_servers = auth_get_authserver_list();
584
                                                                foreach ($auth_servers as $auth_server):
585
                                                                        $selected = "";
586
                                                                        if (in_array($auth_server['name'], $authmodes))
587
                                                                                $selected = "selected";
588
                                                        ?>
589
                                                                <option value="<?=$auth_server['name'];?>" <?=$selected;?>><?=$auth_server['name'];?></option>
590
                                                        <?php 	endforeach; ?>
591
                                                        </select>
592
                                                </td>
593
                                        </tr>
594
					<tr>
595
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
596
							<td width="78%" class="vtable">
597
							<select name='protocol' class="formselect">
598
							<?php
599
								foreach ($openvpn_prots as $prot):
600
									$selected = "";
601
									if ($pconfig['protocol'] == $prot)
602
										$selected = "selected";
603
							?>
604
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
605
							<?php endforeach; ?>
606
							</select>
607
							</td>
608
					</tr>
609
					<tr>
610
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
611
						<td width="78%" class="vtable">
612
							<select name="interface" class="formselect">
613
								<?php
614
									$interfaces = get_configured_interface_with_descr();
615
									$carplist = get_configured_carp_interface_list();
616
									foreach ($carplist as $cif => $carpip)
617
										$interfaces[$cif.'|'.$carpip] = strtoupper($cif) . " ({$carpip})";
618
									$aliaslist = get_configured_ip_aliases_list();
619
									foreach ($aliaslist as $aliasip => $aliasif)
620
										$interfaces[$aliasif.'|'.$aliasip] = strtoupper($aliasif) . " ({$aliasip})";
621
									$interfaces['any'] = "any";
622
									foreach ($interfaces as $iface => $ifacename):
623
										$selected = "";
624
										if ($iface == $pconfig['interface'])
625
											$selected = "selected";
626
								?>
627
									<option value="<?=$iface;?>" <?=$selected;?>>
628
										<?=htmlspecialchars($ifacename);?>
629
									</option>
630
								<?php endforeach; ?>
631
							</select> <br>
632
						</td>
633
					</tr>
634
					<tr>
635
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Local port");?></td>
636
						<td width="78%" class="vtable">
637
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
638
						</td>
639
					</tr>
640
					<tr> 
641
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
642
						<td width="78%" class="vtable"> 
643
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
644
							<br>
645
							<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
646
						</td>
647
					</tr>
648
					<tr>
649
						<td colspan="2" class="list" height="12"></td>
650
					</tr>
651
					<tr>
652
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
653
					</tr>
654
					<tr id="tls">
655
						<td width="22%" valign="top" class="vncellreq"><?=gettext("TLS Authentication"); ?></td>
656
						<td width="78%" class="vtable">
657
							<table border="0" cellpadding="2" cellspacing="0">
658
								<tr>
659
									<td>
660
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
661
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onClick="tlsauth_change()">
662
									</td>
663
									<td>
664
										<span class="vexpl">
665
											<?=gettext("Enable authentication of TLS packets"); ?>.
666
										</span>
667
									</td>
668
								</tr>
669
							</table>
670
							<?php if (!$pconfig['tls']): ?>
671
							<table border="0" cellpadding="2" cellspacing="0" id='tlsauth_opts'>
672
								<tr>
673
									<td>
674
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
675
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autotls_change()">
676
									</td>
677
									<td>
678
										<span class="vexpl">
679
											<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
680
										</span>
681
									</td>
682
								</tr>
683
							</table>
684
							<?php endif; ?>
685
							<table border="0" cellpadding="2" cellspacing="0" id='autotls_opts'>
686
								<tr>
687
									<td>
688
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
689
										<br/>
690
										<?=gettext("Paste your shared key here"); ?>.
691
									</td>
692
								</tr>
693
							</table>
694
						</td>
695
					</tr>
696
					<tr id="tls_ca">
697
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
698
							<td width="78%" class="vtable">
699
							<select name='caref' class="formselect">
700
							<?php
701
								foreach ($config['ca'] as $ca):
702
									$selected = "";
703
									if ($pconfig['caref'] == $ca['refid'])
704
										$selected = "selected";
705
							?>
706
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['name'];?></option>
707
							<?php endforeach; ?>
708
							</select>
709
							</td>
710
					</tr>
711
					<tr id="tls_cert">
712
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Certificate"); ?></td>
713
							<td width="78%" class="vtable">
714
							<select name='certref' class="formselect">
715
							<?php
716
								foreach ($config['cert'] as $cert):
717
									$selected = "";
718
									if (strstr($cert['name'], "webConfigurator"))
719
										continue;
720
									if ($pconfig['certref'] == $cert['refid'])
721
										$selected = "selected";
722
							?>
723
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
724
							<?php endforeach; ?>
725
							</select>
726
						</td>
727
					</tr>
728
					<tr id="tls_dh">
729
						<td width="22%" valign="top" class="vncellreq"><?=gettext("DH Parameters Length"); ?></td>
730
						<td width="78%" class="vtable">
731
							<select name="dh_length" class="formselect">
732
								<?php
733
									foreach ($openvpn_dh_lengths as $length):
734
									$selected = '';
735
									if ($length == $pconfig['dh_length'])
736
										$selected = ' selected';
737
								?>
738
								<option<?=$selected?>><?=$length;?></option>
739
								<?php endforeach; ?>
740
							</select>
741
							<span class="vexpl">
742
								<?=gettext("bits"); ?>
743
							</span>
744
						</td>
745
					</tr>
746
					<tr id="psk">
747
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Key"); ?></td>
748
						<td width="78%" class="vtable">
749
							<?php if (!$pconfig['shared_key']): ?>
750
							<table border="0" cellpadding="2" cellspacing="0">
751
								<tr>
752
									<td>
753
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
754
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autokey_change()">
755
									</td>
756
									<td>
757
										<span class="vexpl">
758
											<?=gettext("Automatically generate a shared key"); ?>.
759
										</span>
760
									</td>
761
								</tr>
762
							</table>
763
							<?php endif; ?>
764
							<table border="0" cellpadding="2" cellspacing="0" id='autokey_opts'>
765
								<tr>
766
									<td>
767
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
768
										<br/>
769
										<?=gettext("Paste your shared key here"); ?>.
770
									</td>
771
								</tr>
772
							</table>
773
						</td>
774
					</tr>
775
					<tr>
776
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
777
						<td width="78%" class="vtable">
778
							<select name="crypto" class="formselect">
779
								<?php
780
									$cipherlist = openvpn_get_cipherlist();
781
									foreach ($cipherlist as $name => $desc):
782
									$selected = '';
783
									if ($name == $pconfig['crypto'])
784
										$selected = ' selected';
785
								?>
786
								<option value="<?=$name;?>"<?=$selected?>>
787
									<?=htmlspecialchars($desc);?>
788
								</option>
789
								<?php endforeach; ?>
790
							</select>
791
						</td>
792
					</tr>
793
					<tr>
794
						<td colspan="2" class="list" height="12"></td>
795
					</tr>
796
					<tr>
797
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
798
					</tr>
799
					<tr>
800
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Tunnel Network"); ?></td>
801
						<td width="78%" class="vtable">
802
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
803
							<br>
804
							<?=gettext("This is the virtual network used for private " .
805
							"communications between this server and client " .
806
							"hosts expressed using CIDR (eg. 10.0.8.0/24). " .
807
							"The first network address will be assigned to " .
808
							"the	server virtual interface. The remaining " .
809
							"network addresses can optionally be assigned " .
810
							"to connecting clients. (see Address Pool)"); ?>
811
						</td>
812
					</tr>
813
					<tr>
814
						<td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td>
815
						<td width="78%" class="vtable">
816
							<table border="0" cellpadding="2" cellspacing="0">
817
								<tr>
818
									<td>
819
										<?php set_checked($pconfig['gwredir'],$chk); ?>
820
										<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> onClick="gwredir_change()"/>
821
									</td>
822
									<td>
823
										<span class="vexpl">
824
											<?=gettext("Force all client generated traffic through the tunnel"); ?>.
825
										</span>
826
									</td>
827
								</tr>
828
							</table>
829
						</td>
830
					</tr>
831
					<tr id="local_opts">
832
						<td width="22%" valign="top" class="vncell"><?=gettext("Local Network"); ?></td>
833
						<td width="78%" class="vtable">
834
							<input name="local_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['local_network']);?>">
835
							<br>
836
							<?=gettext("This is the network that will be accessible " .
837
							"from the remote endpoint. Expressed as a CIDR " .
838
							"range. You may leave this blank if you don't " .
839
							"want to add a route to the local network " .
840
							"through this tunnel on the remote machine. " .
841
							"This is generally set to your LAN network"); ?>.
842
						</td>
843
					</tr>
844
					<tr id="remote_opts">
845
						<td width="22%" valign="top" class="vncell"><?=gettext("Remote Network"); ?></td>
846
						<td width="78%" class="vtable">
847
							<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
848
							<br>
849
							<?=gettext("This is a network that will be routed through " .
850
							"the tunnel, so that a site-to-site VPN can be " .
851
							"established without manually changing the " .
852
							"routing tables. Expressed as a CIDR range. If " .
853
							"this is a site-to-site VPN, enter here the " .
854
							"remote LAN here. You may leave this blank if " .
855
							"you don't want a site-to-site VPN"); ?>.
856
						</td>
857
					</tr>
858
					<tr>
859
						<td width="22%" valign="top" class="vncell"><?=gettext("Concurrent connections");?></td>
860
						<td width="78%" class="vtable">
861
							<input name="maxclients" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['maxclients']);?>"/>
862
							<br/>
863
							<?=gettext("Specify the maximum number of clients allowed to concurrently connect to this server"); ?>.
864
						</td>
865
					</tr>
866
					<tr>
867
						<td width="22%" valign="top" class="vncell"><?=gettext("Compression"); ?></td>
868
						<td width="78%" class="vtable">
869
							<table border="0" cellpadding="2" cellspacing="0">
870
								<tr>
871
									<td>
872
										<?php set_checked($pconfig['compression'],$chk); ?>
873
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
874
									</td>
875
									<td>
876
										<span class="vexpl">
877
											<?=gettext("Compress tunnel packets using the LZO algorithm"); ?>.
878
										</span>
879
									</td>
880
								</tr>
881
							</table>
882
						</td>
883
					</tr>
884
					<tr>
885
						<td width="22%" valign="top" class="vncell"><?=gettext("Type-of-Service"); ?></td>
886
						<td width="78%" class="vtable">
887
							<table border="0" cellpadding="2" cellspacing="0">
888
								<tr>
889
									<td>
890
										<?php set_checked($pconfig['passtos'],$chk); ?>
891
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?>>
892
									</td>
893
									<td>
894
										<span class="vexpl">
895
											<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
896
										</span>
897
									</td>
898
								</tr>
899
							</table>
900
						</td>
901
					</tr>
902
					<tr id="inter_client_communication">
903
						<td width="22%" valign="top" class="vncell"><?=gettext("Inter-client communication"); ?></td>
904
						<td width="78%" class="vtable">
905
							<table border="0" cellpadding="2" cellspacing="0">
906
								<tr>
907
									<td>
908
										<?php set_checked($pconfig['client2client'],$chk); ?>
909
										<input name="client2client" type="checkbox" value="yes" <?=$chk;?>/>
910
									</td>
911
									<td>
912
										<span class="vexpl">
913
											<?=gettext("Allow communication between clients connected to this server"); ?>
914
										</span>
915
									</td>
916
								</tr>
917
							</table>
918
						</td>
919
					</tr>
920
				</table>
921

    
922
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
923
					<tr>
924
						<td colspan="2" class="list" height="12"></td>
925
					</tr>
926
					<tr>
927
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
928
					</tr>
929
					<tr>
930
						<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic IP"); ?></td>
931
						<td width="78%" class="vtable">
932
							<table border="0" cellpadding="2" cellspacing="0">
933
								<tr>
934
									<td>
935
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
936
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?>/>
937
									</td>
938
									<td>
939
										<span class="vexpl">
940
											<?=gettext("Allow connected clients to retain their connections if their IP address changes"); ?>.<br>
941
										</span>
942
									</td>
943
								</tr>
944
							</table>
945
						</td>
946
					</tr>
947
					<tr>
948
						<td width="22%" valign="top" class="vncell"><?=gettext("Address Pool"); ?></td>
949
						<td width="78%" class="vtable">
950
							<table border="0" cellpadding="2" cellspacing="0">
951
								<tr>
952
									<td>
953
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
954
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>/>
955
									</td>
956
									<td>
957
										<span class="vexpl">
958
											<?=gettext("Provide a virtual adapter IP address to clients (see Tunnel Network)"); ?><br>
959
										</span>
960
									</td>
961
								</tr>
962
							</table>
963
						</td>
964
					</tr>
965
					<tr>
966
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
967
						<td width="78%" class="vtable">
968
							<table border="0" cellpadding="2" cellspacing="0">
969
								<tr>
970
									<td>
971
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
972
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
973
									</td>
974
									<td>
975
										<span class="vexpl">
976
	                                        <?=gettext("Provide a default domain name to clients"); ?><br>
977
										</span>
978
									</td>
979
								</tr>
980
							</table>
981
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
982
								<tr>
983
									<td>
984
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
985
									</td>
986
								</tr>
987
							</table>
988
						</td>
989
					</tr>
990
					<tr>
991
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
992
						<td width="78%" class="vtable">
993
							<table border="0" cellpadding="2" cellspacing="0">
994
								<tr>
995
									<td>
996
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
997
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
998
									</td>
999
									<td>
1000
										<span class="vexpl">
1001
											<?=gettext("Provide a DNS server list to clients"); ?><br>
1002
										</span>
1003
									</td>
1004
								</tr>
1005
							</table>
1006
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
1007
								<tr>
1008
									<td>
1009
										<span class="vexpl">
1010
											<?=gettext("Server"); ?> #1:&nbsp;
1011
										</span>
1012
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=$pconfig['dns_server1'];?>">
1013
									</td>
1014
								</tr>
1015
								<tr>
1016
									<td>
1017
										<span class="vexpl">
1018
											<?=gettext("Server"); ?> #2:&nbsp;
1019
										</span>
1020
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=$pconfig['dns_server2'];?>">
1021
									</td>
1022
								</tr>
1023
								<tr>
1024
									<td>
1025
										<span class="vexpl">
1026
											<?=gettext("Server"); ?> #3:&nbsp;
1027
										</span>
1028
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=$pconfig['dns_server3'];?>">
1029
									</td>
1030
								</tr>
1031
								<tr>
1032
									<td>
1033
										<span class="vexpl">
1034
											<?=gettext("Server"); ?> #4:&nbsp;
1035
										</span>
1036
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=$pconfig['dns_server4'];?>">
1037
									</td>
1038
								</tr>
1039
							</table>
1040
						</td>
1041
					</tr>
1042
					<tr>
1043
						<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
1044
						<td width="78%" class="vtable">
1045
							<table border="0" cellpadding="2" cellspacing="0">
1046
								<tr>
1047
									<td>
1048
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1049
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
1050
									</td>
1051
									<td>
1052
										<span class="vexpl">
1053
											<?=gettext("Provide a NTP server list to clients"); ?><br>
1054
										</span>
1055
									</td>
1056
								</tr>
1057
							</table>
1058
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
1059
								<tr>
1060
									<td>
1061
										<span class="vexpl">
1062
											<?=gettext("Server"); ?> #1:&nbsp;
1063
										</span>
1064
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=$pconfig['ntp_server1'];?>">
1065
									</td>
1066
								</tr>
1067
								<tr>
1068
									<td>
1069
										<span class="vexpl">
1070
											<?=gettext("Server"); ?> #2:&nbsp;
1071
										</span>
1072
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=$pconfig['ntp_server2'];?>">
1073
									</td>
1074
								</tr>
1075
							</table>
1076
						</td>
1077
					</tr>
1078
					<tr>
1079
						<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
1080
						<td width="78%" class="vtable">
1081
							<table border="0" cellpadding="2" cellspacing="0">
1082
								<tr>
1083
									<td>
1084
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1085
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
1086
									</td>
1087
									<td>
1088
										<span class="vexpl">
1089
											<?=gettext("Enable NetBIOS over TCP/IP"); ?><br>
1090
										</span>
1091
									</td>
1092
								</tr>
1093
							</table>
1094
							<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
1095
							<br/>
1096
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
1097
								<tr>
1098
									<td>
1099
										<br/>
1100
										<span class="vexpl">
1101
											<?=gettext("Node Type"); ?>:&nbsp;
1102
										</span>
1103
										<select name='netbios_ntype' class="formselect">
1104
										<?php
1105
											foreach ($netbios_nodetypes as $type => $name):
1106
												$selected = "";
1107
												if ($pconfig['netbios_ntype'] == $type)
1108
													$selected = "selected";
1109
										?>
1110
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1111
										<?php endforeach; ?>
1112
										</select>
1113
										<br/>
1114
										<?=gettext("Possible options: b-node (broadcasts), p-node " .
1115
										"(point-to-point name queries to a WINS server), " .
1116
										"m-node (broadcast then query name server), and " .
1117
										"h-node (query name server, then broadcast)"); ?>.
1118
									</td>
1119
								</tr>
1120
								<tr>
1121
									<td>
1122
										<br/>
1123
										<span class="vexpl">
1124
											<?=gettext("Scope ID"); ?>:&nbsp;
1125
										</span>
1126
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
1127
										<br/>
1128
										<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
1129
										"service for	NetBIOS over TCP/IP. The NetBIOS " .
1130
										"scope ID isolates NetBIOS traffic on a single " .
1131
										"network to only those nodes with the same " .
1132
										"NetBIOS scope ID"); ?>.
1133
									</td>
1134
								</tr>
1135
							</table>
1136
						</td>
1137
					</tr>
1138
					<tr id="wins_opts">
1139
						<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
1140
						<td width="78%" class="vtable">
1141
							<table border="0" cellpadding="2" cellspacing="0">
1142
								<tr>
1143
									<td>
1144
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1145
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
1146
									</td>
1147
									<td>
1148
										<span class="vexpl">
1149
											<?=gettext("Provide a WINS server list to clients"); ?><br>
1150
										</span>
1151
									</td>
1152
								</tr>
1153
							</table>
1154
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
1155
								<tr>
1156
									<td>
1157
										<span class="vexpl">
1158
											<?=gettext("Server"); ?> #1:&nbsp;
1159
										</span>
1160
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=$pconfig['wins_server1'];?>">
1161
									</td>
1162
								</tr>
1163
								<tr>
1164
									<td>
1165
										<span class="vexpl">
1166
											<?=gettext("Server"); ?> #2:&nbsp;
1167
										</span>
1168
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=$pconfig['wins_server2'];?>">
1169
									</td>
1170
								</tr>
1171
							</table>
1172
						</td>
1173
					</tr>
1174
				</table>
1175

    
1176
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1177
					<tr>
1178
						<td colspan="2" class="list" height="12"></td>
1179
					</tr>
1180
					<tr>
1181
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1182
					</tr>
1183
					<tr>
1184
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1185
						<td width="78%" class="vtable">
1186
							<table border="0" cellpadding="2" cellspacing="0">
1187
								<tr>
1188
									<td>
1189
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];?></textarea><br/>
1190
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br/>
1191
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1192
									</td>
1193
								</tr>
1194
							</table>
1195
						</td>
1196
					</tr>
1197
				</table>
1198

    
1199
				<br/>
1200

    
1201
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1202
					<tr>
1203
						<td width="22%" valign="top">&nbsp;</td>
1204
						<td width="78%"> 
1205
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>"> 
1206
							<input name="act" type="hidden" value="<?=$act;?>">
1207
							<?php if (isset($id) && $a_server[$id]): ?>
1208
							<input name="id" type="hidden" value="<?=$id;?>">
1209
							<?php endif; ?>
1210
						</td>
1211
					</tr>
1212
				</table>
1213
			</form>
1214

    
1215
			<?php else: ?>
1216

    
1217
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1218
				<tr>
1219
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1220
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1221
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1222
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1223
					<td width="10%" class="list"></td>
1224
				</tr>
1225
				<?php
1226
					$i = 0;
1227
					foreach($a_server as $server):
1228
						$disabled = "NO";
1229
						if (isset($server['disable']))
1230
							$disabled = "YES";
1231
				?>
1232
				<tr>
1233
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1234
						<?=$disabled;?>
1235
					</td>
1236
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1237
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1238
					</td>
1239
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1240
						<?=htmlspecialchars($server['tunnel_network']);?>
1241
					</td>
1242
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1243
						<?=htmlspecialchars($server['description']);?>
1244
					</td>
1245
					<td valign="middle" nowrap class="list">
1246
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1247
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0">
1248
						</a>
1249
						&nbsp;
1250
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1251
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0">
1252
						</a>
1253
					</td>
1254
				</tr>
1255
				<?php
1256
					$i++;
1257
					endforeach;
1258
				?>
1259
				<tr>
1260
					<td class="list" colspan="4"></td>
1261
					<td class="list">
1262
						<a href="vpn_openvpn_server.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add server"); ?>" width="17" height="17" border="0">
1263
						</a>
1264
					</td>
1265
				</tr>
1266
			</table>
1267

    
1268
			<?=gettext("Additional OpenVPN servers can be added here.");?>
1269

    
1270
			<?php endif; ?>
1271

    
1272
		</td>
1273
	</tr>
1274
</table>
1275
<script language="JavaScript">
1276
<!--
1277
mode_change();
1278
autokey_change();
1279
tlsauth_change();
1280
gwredir_change();
1281
dns_domain_change();
1282
dns_server_change();
1283
wins_server_change();
1284
ntp_server_change();
1285
netbios_change();
1286
//-->
1287
</script>
1288
</body>
1289
<?php include("fend.inc"); ?>
1290

    
1291
<?php
1292

    
1293
/* local utility functions */
1294

    
1295
function set_checked($var,& $chk) {
1296
    if($var)
1297
        $chk = 'checked';
1298
    else
1299
        $chk = '';
1300
}
1301

    
1302
?>
(213-213/220)