Project

General

Profile

Download (45 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
$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[] = "Only 'Local authentication database'  is allowed with " . $openvpn_server_modes[$pconfig['mode']];
179
		}
180
	}
181

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

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

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

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

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

    
199
	if ($pconfig['autokey_enable'])
200
		$pconfig['shared_key'] = openvpn_create_key();
201

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

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

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

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

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

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

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

    
259
	$reqdfields[] = 'tunnel_network';
260
	$reqdfieldsn[] = 'Tunnel network';
261

    
262
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
263
	
264
	if (!$input_errors) {
265

    
266
		$server = array();
267

    
268
		if ($vpnid)
269
			$server['vpnid'] = $vpnid;
270
		else
271
			$server['vpnid'] = openvpn_vpnid_next();
272

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

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

    
298
		$server['tunnel_network'] = $pconfig['tunnel_network'];
299
		$server['remote_network'] = $pconfig['remote_network'];
300
		$server['gwredir'] = $pconfig['gwredir'];
301
		$server['local_network'] = $pconfig['local_network'];
302
		$server['maxclients'] = $pconfig['maxclients'];
303
		$server['compression'] = $pconfig['compression'];
304
		$server['passtos'] = $pconfig['passtos'];
305
		$server['client2client'] = $pconfig['client2client'];
306

    
307
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
308
		$server['pool_enable'] = $pconfig['pool_enable'];
309

    
310
		if ($pconfig['dns_domain_enable'])
311
			$server['dns_domain'] = $pconfig['dns_domain'];
312

    
313
		if ($pconfig['dns_server_enable']) {
314
			$server['dns_server1'] = $pconfig['dns_server1'];
315
			$server['dns_server2'] = $pconfig['dns_server2'];
316
			$server['dns_server3'] = $pconfig['dns_server3'];
317
			$server['dns_server4'] = $pconfig['dns_server4'];
318
		}
319

    
320
		if ($pconfig['ntp_server_enable']) {
321
			$server['ntp_server1'] = $pconfig['ntp_server1'];
322
			$server['ntp_server2'] = $pconfig['ntp_server2'];
323
		}
324

    
325
		$server['netbios_enable'] = $pconfig['netbios_enable'];
326
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
327
		$server['netbios_scope'] = $pconfig['netbios_scope'];
328

    
329
		if ($pconfig['netbios_enable']) {
330

    
331
			if ($pconfig['wins_server_enable']) {
332
				$server['wins_server1'] = $pconfig['wins_server1'];
333
				$server['wins_server2'] = $pconfig['wins_server2'];
334
			}
335

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

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

    
355
include("head.inc");
356

    
357
?>
358

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

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

    
416
function autokey_change() {
417

    
418
	if (document.iform.autokey_enable.checked)
419
		document.getElementById("autokey_opts").style.display="none";
420
	else
421
		document.getElementById("autokey_opts").style.display="";
422
}
423

    
424
function tlsauth_change() {
425

    
426
<?php if (!$pconfig['tls']): ?>
427
	if (document.iform.tlsauth_enable.checked)
428
		document.getElementById("tlsauth_opts").style.display="";
429
	else
430
		document.getElementById("tlsauth_opts").style.display="none";
431
<?php endif; ?>
432

    
433
	autotls_change();
434
}
435

    
436
function autotls_change() {
437

    
438
<?php if (!$pconfig['tls']): ?>
439
	autocheck = document.iform.autotls_enable.checked;
440
<?php else: ?>
441
	autocheck = false;
442
<?php endif; ?>
443

    
444
	if (document.iform.tlsauth_enable.checked && !autocheck)
445
		document.getElementById("autotls_opts").style.display="";
446
	else
447
		document.getElementById("autotls_opts").style.display="none";
448
}
449

    
450
function gwredir_change() {
451

    
452
	if (document.iform.gwredir.checked)
453
		document.getElementById("local_opts").style.display="none";
454
	else
455
		document.getElementById("local_opts").style.display="";
456
}
457

    
458
function dns_domain_change() {
459

    
460
	if (document.iform.dns_domain_enable.checked)
461
		document.getElementById("dns_domain_data").style.display="";
462
	else
463
		document.getElementById("dns_domain_data").style.display="none";
464
}
465

    
466
function dns_server_change() {
467

    
468
	if (document.iform.dns_server_enable.checked)
469
		document.getElementById("dns_server_data").style.display="";
470
	else
471
		document.getElementById("dns_server_data").style.display="none";
472
}
473

    
474
function wins_server_change() {
475

    
476
	if (document.iform.wins_server_enable.checked)
477
		document.getElementById("wins_server_data").style.display="";
478
	else
479
		document.getElementById("wins_server_data").style.display="none";
480
}
481

    
482
function ntp_server_change() {
483

    
484
	if (document.iform.ntp_server_enable.checked)
485
		document.getElementById("ntp_server_data").style.display="";
486
	else
487
		document.getElementById("ntp_server_data").style.display="none";
488
}
489

    
490
function netbios_change() {
491

    
492
	if (document.iform.netbios_enable.checked) {
493
		document.getElementById("netbios_data").style.display="";
494
		document.getElementById("wins_opts").style.display="";
495
	} else {
496
		document.getElementById("netbios_data").style.display="none";
497
		document.getElementById("wins_opts").style.display="none";
498
	}
499
}
500

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

    
528
			<?php if($act=="new" || $act=="edit"): ?>
529

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

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

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

    
1192
				<br/>
1193

    
1194
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts">
1195
					<tr>
1196
						<td width="22%" valign="top">&nbsp;</td>
1197
						<td width="78%"> 
1198
							<input name="save" type="submit" class="formbtn" value="Save"> 
1199
							<input name="act" type="hidden" value="<?=$act;?>">
1200
							<?php if (isset($id) && $a_server[$id]): ?>
1201
							<input name="id" type="hidden" value="<?=$id;?>">
1202
							<?php endif; ?>
1203
						</td>
1204
					</tr>
1205
				</table>
1206
			</form>
1207

    
1208
			<?php else: ?>
1209

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

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

    
1263
			<? endif; ?>
1264

    
1265
		</td>
1266
	</tr>
1267
</table>
1268
<script language="JavaScript">
1269
<!--
1270
mode_change();
1271
autokey_change();
1272
tlsauth_change();
1273
gwredir_change();
1274
dns_domain_change();
1275
dns_server_change();
1276
wins_server_change();
1277
ntp_server_change();
1278
netbios_change();
1279
//-->
1280
</script>
1281
</body>
1282
<?php include("fend.inc"); ?>
1283

    
1284
<?php
1285

    
1286
/* local utility functions */
1287

    
1288
function set_checked($var,& $chk) {
1289
    if($var)
1290
        $chk = 'checked';
1291
    else
1292
        $chk = '';
1293
}
1294

    
1295
?>
(213-213/221)