Project

General

Profile

Download (44.3 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("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
	openvpn_delete('server', $a_server[$id]);
63
	unset($a_server[$id]);
64
	write_config();
65
	$savemsg = gettext("Server successfully deleted")."<br/>";
66
}
67

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

    
78
if($_GET['act']=="edit"){
79

    
80
	if (isset($id) && $a_server[$id]) {
81

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

    
94
		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
			$pconfig['caref'] = $a_server[$id]['caref'];
100
			$pconfig['certref'] = $a_server[$id]['certref'];
101
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
102
		} else
103
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
104
		$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
		$pconfig['passtos'] = $a_server[$id]['passtos'];
113
		$pconfig['client2client'] = $a_server[$id]['client2client'];
114

    
115
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
116
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
117

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

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

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

    
138
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
139
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
140
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
141

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

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

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

    
158
if ($_POST) {
159

    
160
	unset($input_errors);
161
	$pconfig = $_POST;
162

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

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

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

    
180
	/* input validation */
181
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
182
		$input_errors[] = $result;
183

    
184
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
185
		$input_errors[] = $result;
186

    
187
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
188
		$input_errors[] = $result;
189

    
190
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
191
		$input_errors[] = $result;
192

    
193
	$portused = openvpn_port_used($pconfig['protocol'], $pconfig['local_port']);
194
	if (($portused != $vpnid) && ($portused != 0))
195
		$input_errors[] = "The specified 'Local port' is in use. Please select another value";
196

    
197
	if ($pconfig['autokey_enable'])
198
		$pconfig['shared_key'] = openvpn_create_key();
199

    
200
	if (!$tls_mode && !$pconfig['autokey_enable'])
201
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
202
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
203
			$input_errors[] = "The field 'Shared Key' does not appear to be valid";
204

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

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

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

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

    
244
	if ($pconfig['maxclients'] && !is_numeric($pconfig['maxclients']))
245
		$input_errors[] = "The field 'Concurrent connections' must be numeric.";
246

    
247
	if (!$tls_mode && !$pconfig['autokey_enable']) {
248
		$reqdfields = array('shared_key');
249
		$reqdfieldsn = array('Shared key');
250
	} else {
251
		$reqdfields = explode(" ", "caref certref");
252
		$reqdfieldsn = explode(",", "Certificate Authority,Certificate");;
253
	}
254

    
255
	$reqdfields[] = 'tunnel_network';
256
	$reqdfieldsn[] = 'Tunnel network';
257

    
258
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
259
	
260
	if (!$input_errors) {
261

    
262
		$server = array();
263

    
264
		if ($vpnid)
265
			$server['vpnid'] = $vpnid;
266
		else
267
			$server['vpnid'] = openvpn_vpnid_next();
268

    
269
		if ($_POST['disable'] == "yes")
270
			$server['disable'] = true;
271
		$server['mode'] = $pconfig['mode'];
272
		if (!empty($pconfig['authmode']))
273
			$server['authmode'] = implode(",", $pconfig['authmode']);
274
		$server['protocol'] = $pconfig['protocol'];
275
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
276
		$server['local_port'] = $pconfig['local_port'];
277
		$server['description'] = $pconfig['description'];
278
		$server['custom_options'] = $pconfig['custom_options'];
279

    
280
		if ($tls_mode) {
281
			if ($pconfig['tlsauth_enable']) {
282
				if ($pconfig['autotls_enable'])
283
					$pconfig['tls'] = openvpn_create_key();
284
				$server['tls'] = base64_encode($pconfig['tls']);
285
			}
286
			$server['caref'] = $pconfig['caref'];
287
			$server['certref'] = $pconfig['certref'];
288
			$server['dh_length'] = $pconfig['dh_length'];
289
		} else {
290
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
291
		}
292
		$server['crypto'] = $pconfig['crypto'];
293

    
294
		$server['tunnel_network'] = $pconfig['tunnel_network'];
295
		$server['remote_network'] = $pconfig['remote_network'];
296
		$server['gwredir'] = $pconfig['gwredir'];
297
		$server['local_network'] = $pconfig['local_network'];
298
		$server['maxclients'] = $pconfig['maxclients'];
299
		$server['compression'] = $pconfig['compression'];
300
		$server['passtos'] = $pconfig['passtos'];
301
		$server['client2client'] = $pconfig['client2client'];
302

    
303
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
304
		$server['pool_enable'] = $pconfig['pool_enable'];
305

    
306
		if ($pconfig['dns_domain_enable'])
307
			$server['dns_domain'] = $pconfig['dns_domain'];
308

    
309
		if ($pconfig['dns_server_enable']) {
310
			$server['dns_server1'] = $pconfig['dns_server1'];
311
			$server['dns_server2'] = $pconfig['dns_server2'];
312
			$server['dns_server3'] = $pconfig['dns_server3'];
313
			$server['dns_server4'] = $pconfig['dns_server4'];
314
		}
315

    
316
		if ($pconfig['ntp_server_enable']) {
317
			$server['ntp_server1'] = $pconfig['ntp_server1'];
318
			$server['ntp_server2'] = $pconfig['ntp_server2'];
319
		}
320

    
321
		$server['netbios_enable'] = $pconfig['netbios_enable'];
322
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
323
		$server['netbios_scope'] = $pconfig['netbios_scope'];
324

    
325
		if ($pconfig['netbios_enable']) {
326

    
327
			if ($pconfig['wins_server_enable']) {
328
				$server['wins_server1'] = $pconfig['wins_server1'];
329
				$server['wins_server2'] = $pconfig['wins_server2'];
330
			}
331

    
332
			if ($pconfig['dns_server_enable'])
333
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
334
		}
335
	
336
		if (isset($id) && $a_server[$id])
337
			$a_server[$id] = $server;
338
		else
339
			$a_server[] = $server;
340

    
341
		openvpn_resync('server', $server);
342
		write_config();
343
		
344
		header("Location: vpn_openvpn_server.php");
345
		exit;
346
	}
347
	if (!empty($pconfig['authmode']))
348
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
349
}
350

    
351
include("head.inc");
352

    
353
?>
354

    
355
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
356
<?php include("fbegin.inc"); ?>
357
<script language="JavaScript">
358
<!--
359

    
360
function mode_change() {
361
	index = document.iform.mode.selectedIndex;
362
	value = document.iform.mode.options[index].value;
363
	switch(value) {
364
		case "p2p_tls":
365
		case "server_tls":
366
		case "server_user":
367
		case "server_tls_user":
368
			document.getElementById("tls").style.display="";
369
			document.getElementById("tls_ca").style.display="";
370
			document.getElementById("tls_cert").style.display="";
371
			document.getElementById("tls_dh").style.display="";
372
			document.getElementById("psk").style.display="none";
373
			break;
374
		case "p2p_shared_key":
375
			document.getElementById("tls").style.display="none";
376
			document.getElementById("tls_ca").style.display="none";
377
			document.getElementById("tls_cert").style.display="none";
378
			document.getElementById("tls_dh").style.display="none";
379
			document.getElementById("psk").style.display="";
380
			break;
381
	}
382
	switch(value) {
383
		case "p2p_tls":
384
		case "p2p_shared_key":
385
			document.getElementById("client_opts").style.display="none";
386
			document.getElementById("remote_opts").style.display="";
387
			document.getElementById("authmodetr").style.display="none";
388
			break;
389
		case "server_user":
390
                case "server_tls_user":
391
			document.getElementById("authmodetr").style.display="";
392
			document.getElementById("client_opts").style.display="";
393
			document.getElementById("remote_opts").style.display="none";
394
			break;
395
		case "server_tls":
396
			document.getElementById("authmodetr").style.display="none";
397
		default:
398
			document.getElementById("client_opts").style.display="";
399
			document.getElementById("remote_opts").style.display="none";
400
			break;
401
	}
402
}
403

    
404
function autokey_change() {
405

    
406
	if (document.iform.autokey_enable.checked)
407
		document.getElementById("autokey_opts").style.display="none";
408
	else
409
		document.getElementById("autokey_opts").style.display="";
410
}
411

    
412
function tlsauth_change() {
413

    
414
<?php if (!$pconfig['tls']): ?>
415
	if (document.iform.tlsauth_enable.checked)
416
		document.getElementById("tlsauth_opts").style.display="";
417
	else
418
		document.getElementById("tlsauth_opts").style.display="none";
419
<?php endif; ?>
420

    
421
	autotls_change();
422
}
423

    
424
function autotls_change() {
425

    
426
<?php if (!$pconfig['tls']): ?>
427
	autocheck = document.iform.autotls_enable.checked;
428
<?php else: ?>
429
	autocheck = false;
430
<?php endif; ?>
431

    
432
	if (document.iform.tlsauth_enable.checked && !autocheck)
433
		document.getElementById("autotls_opts").style.display="";
434
	else
435
		document.getElementById("autotls_opts").style.display="none";
436
}
437

    
438
function gwredir_change() {
439

    
440
	if (document.iform.gwredir.checked)
441
		document.getElementById("local_opts").style.display="none";
442
	else
443
		document.getElementById("local_opts").style.display="";
444
}
445

    
446
function dns_domain_change() {
447

    
448
	if (document.iform.dns_domain_enable.checked)
449
		document.getElementById("dns_domain_data").style.display="";
450
	else
451
		document.getElementById("dns_domain_data").style.display="none";
452
}
453

    
454
function dns_server_change() {
455

    
456
	if (document.iform.dns_server_enable.checked)
457
		document.getElementById("dns_server_data").style.display="";
458
	else
459
		document.getElementById("dns_server_data").style.display="none";
460
}
461

    
462
function wins_server_change() {
463

    
464
	if (document.iform.wins_server_enable.checked)
465
		document.getElementById("wins_server_data").style.display="";
466
	else
467
		document.getElementById("wins_server_data").style.display="none";
468
}
469

    
470
function ntp_server_change() {
471

    
472
	if (document.iform.ntp_server_enable.checked)
473
		document.getElementById("ntp_server_data").style.display="";
474
	else
475
		document.getElementById("ntp_server_data").style.display="none";
476
}
477

    
478
function netbios_change() {
479

    
480
	if (document.iform.netbios_enable.checked) {
481
		document.getElementById("netbios_data").style.display="";
482
		document.getElementById("wins_opts").style.display="";
483
	} else {
484
		document.getElementById("netbios_data").style.display="none";
485
		document.getElementById("wins_opts").style.display="none";
486
	}
487
}
488

    
489
//-->
490
</script>
491
<?php
492
	if ($input_errors)
493
		print_input_errors($input_errors);
494
	if ($savemsg)
495
		print_info_box($savemsg);
496
?>
497
<table width="100%" border="0" cellpadding="0" cellspacing="0">
498
	<tr>
499
		<td class="tabnavtbl">
500
			<ul id="tabnav">
501
			<?php 
502
				$tab_array = array();
503
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
504
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
505
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
506
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
507
				add_package_tabs("OpenVPN", $tab_array);
508
				display_top_tabs($tab_array);
509
			?>
510
			</ul>
511
		</td>
512
	</tr>    
513
	<tr>
514
		<td class="tabcont">
515

    
516
			<?php if($act=="new" || $act=="edit"): ?>
517

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

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

    
1157
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1158
					<tr>
1159
						<td colspan="2" class="list" height="12"></td>
1160
					</tr>
1161
					<tr>
1162
						<td colspan="2" valign="top" class="listtopic">Advanced configuration</td>
1163
					</tr>
1164
					<tr>
1165
						<td width="22%" valign="top" class="vncell">Advanced</td>
1166
						<td width="78%" class="vtable">
1167
							<table border="0" cellpadding="2" cellspacing="0">
1168
								<tr>
1169
									<td>
1170
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=$pconfig['custom_options'];?></textarea><br/>
1171
										Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon<br/>
1172
										EXAMPLE: push "route 10.0.0.0 255.255.255.0";
1173
									</td>
1174
								</tr>
1175
							</table>
1176
						</td>
1177
					</tr>
1178
				</table>
1179

    
1180
				<br/>
1181

    
1182
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1183
					<tr>
1184
						<td width="22%" valign="top">&nbsp;</td>
1185
						<td width="78%"> 
1186
							<input name="save" type="submit" class="formbtn" value="Save"> 
1187
							<input name="act" type="hidden" value="<?=$act;?>">
1188
							<?php if (isset($id) && $a_server[$id]): ?>
1189
							<input name="id" type="hidden" value="<?=$id;?>">
1190
							<?php endif; ?>
1191
						</td>
1192
					</tr>
1193
				</table>
1194
			</form>
1195

    
1196
			<?php else: ?>
1197

    
1198
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0">
1199
				<tr>
1200
					<td width="10%" class="listhdrr">Disabled</td>
1201
					<td width="10%" class="listhdrr">Protocol / Port</td>
1202
					<td width="30%" class="listhdrr">Tunnel Network</td>
1203
					<td width="40%" class="listhdrr">Description</td>
1204
					<td width="10%" class="list"></td>
1205
				</tr>
1206
				<?php
1207
					$i = 0;
1208
					foreach($a_server as $server):
1209
						$disabled = "NO";
1210
						if (isset($server['disable']))
1211
							$disabled = "YES";
1212
				?>
1213
				<tr>
1214
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1215
						<?=$disabled;?>
1216
					</td>
1217
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1218
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1219
					</td>
1220
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1221
						<?=htmlspecialchars($server['tunnel_network']);?>
1222
					</td>
1223
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&id=<?=$i;?>'">
1224
						<?=htmlspecialchars($server['description']);?>
1225
					</td>
1226
					<td valign="middle" nowrap class="list">
1227
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
1228
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit server" width="17" height="17" border="0">
1229
						</a>
1230
						&nbsp;
1231
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this server?')">
1232
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete server" width="17" height="17" border="0">
1233
						</a>
1234
					</td>
1235
				</tr>
1236
				<?php
1237
					$i++;
1238
					endforeach;
1239
				?>
1240
				<tr>
1241
					<td class="list" colspan="4"></td>
1242
					<td class="list">
1243
						<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">
1244
						</a>
1245
					</td>
1246
				</tr>
1247
			</table>
1248

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

    
1251
			<? endif; ?>
1252

    
1253
		</td>
1254
	</tr>
1255
</table>
1256
<script language="JavaScript">
1257
<!--
1258
mode_change();
1259
autokey_change();
1260
tlsauth_change();
1261
gwredir_change();
1262
dns_domain_change();
1263
dns_server_change();
1264
wins_server_change();
1265
ntp_server_change();
1266
netbios_change();
1267
//-->
1268
</script>
1269
</body>
1270
<?php include("fend.inc"); ?>
1271

    
1272
<?php
1273

    
1274
/* local utility functions */
1275

    
1276
function set_checked($var,& $chk) {
1277
    if($var)
1278
        $chk = 'checked';
1279
    else
1280
        $chk = '';
1281
}
1282

    
1283
?>
(208-208/216)