Project

General

Profile

Download (33.7 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

    
38
require("guiconfig.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['interface'] = "wan";
70
	$pconfig['local_port'] = openvpn_port_next('UDP');
71
	$pconfig['pool_enable'] = "yes";
72
}
73

    
74
if($_GET['act']=="edit"){
75

    
76
	if (isset($id) && $a_server[$id]) {
77

    
78
		$pconfig['disable'] = $a_server[$id]['disable'];
79
		$pconfig['protocol'] = $a_server[$id]['protocol'];
80
		$pconfig['interface'] = $a_server[$id]['interface'];
81
		$pconfig['local_port'] = $a_server[$id]['local_port'];
82
		$pconfig['description'] = $a_server[$id]['description'];
83

    
84
		$pconfig['auth_method'] = $a_server[$id]['auth_method'];
85
		if ($pconfig['auth_method'] == "shared_key")
86
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
87
		else {
88
			$pconfig['caref'] = $a_server[$id]['caref'];
89
			$pconfig['certref'] = $a_server[$id]['certref'];
90
		}
91
		$pconfig['crypto'] = $a_server[$id]['crypto'];
92

    
93
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
94
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
95
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
96
		$pconfig['local_network'] = $a_server[$id]['local_network'];
97
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
98
		$pconfig['compression'] = $a_server[$id]['compression'];
99
		$pconfig['settos'] = $a_server[$id]['settos'];
100
		$pconfig['client2client'] = $a_server[$id]['client2client'];
101

    
102
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
103

    
104
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
105
		if ($pconfig['dns_domain'])
106
			$pconfig['dns_domain_enable'] = true;
107

    
108
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
109
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
110
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
111
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
112
		if ($pconfig['dns_server1'] ||
113
			$pconfig['dns_server2'] ||
114
			$pconfig['dns_server3'] ||
115
			$pconfig['dns_server4'])
116
			$pconfig['dns_server_enable'] = true;
117

    
118
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
119
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
120
		if ($pconfig['ntp_server1'] ||
121
			$pconfig['ntp_server2'])
122
			$pconfig['ntp_server_enable'] = true;
123

    
124
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
125
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
126
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
127

    
128
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
129
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
130
		if ($pconfig['wins_server1'] ||
131
			$pconfig['wins_server2'])
132
			$pconfig['wins_server_enable'] = true;
133

    
134
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
135
		if ($pconfig['nbdd_server1'])
136
			$pconfig['nbdd_server_enable'] = true;
137
	}
138
}
139

    
140
if ($_POST) {
141

    
142
	unset($input_errors);
143
	$pconfig = $_POST;
144

    
145
	if (isset($id) && $a_server[$id])
146
		$vpnid = $a_server[$id]['vpnid'];
147
	else
148
		$vpnid = 0;
149

    
150
	/* input validation */
151
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
152
		$input_errors[] = $result;
153

    
154
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
155
		$input_errors[] = $result;
156

    
157
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
158
		$input_errors[] = $result;
159

    
160
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
161
		$input_errors[] = $result;
162

    
163
	if (openvpn_port_used($pconfig['protocol'], $pconfig['local_port']) != $vpnid)
164
		$input_errors[] = "The specified 'Local port' is in use. Please select another value";
165

    
166
	if ($pconfig['auth_method'] == 'shared_key')
167
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
168
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
169
            $input_errors[] = "The field 'Shared Key' does not appear to be valid";
170

    
171
	if ($pconfig['dns_server_enable']) {
172
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
173
			$input_errors[] = "The field 'DNS Server #1' must contain a valid IP address";
174
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
175
			$input_errors[] = "The field 'DNS Server #2' must contain a valid IP address";
176
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
177
			$input_errors[] = "The field 'DNS Server #3' must contain a valid IP address";
178
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
179
			$input_errors[] = "The field 'DNS Server #4' must contain a valid IP address";
180
	}
181

    
182
	if ($pconfig['ntp_server_enable']) {
183
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
184
			$input_errors[] = "The field 'NTP Server #1' must contain a valid IP address";
185
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
186
			$input_errors[] = "The field 'NTP Server #2' must contain a valid IP address";
187
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
188
			$input_errors[] = "The field 'NTP Server #3' must contain a valid IP address";
189
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
190
			$input_errors[] = "The field 'NTP Server #4' must contain a valid IP address";
191
	}
192

    
193
	if ($pconfig['netbios_enable']) {
194
		if ($pconfig['wins_server_enable']) {
195
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
196
				$input_errors[] = "The field 'WINS Server #1' must contain a valid IP address";
197
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
198
				$input_errors[] = "The field 'WINS Server #2' must contain a valid IP address";
199
		}
200
		if ($pconfig['nbdd_server_enable'])
201
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
202
				$input_errors[] = "The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address";
203
	}
204

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

    
208
	if ($pconfig['auth_method'] == 'shared_key') {
209
		$reqdfields = array('shared_key');
210
		$reqfieldsn = array('Shared key');
211
    } else {
212
		$reqdfields = explode(" ", "caref certref");
213
		$reqdfieldsn = explode(",", "Certificate Authority,Certificate");;
214
	}
215

    
216
	$reqdfields[] = 'tunnel_network';
217
	$reqdfieldsn[] = 'Tunnel network';
218

    
219
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
220
	
221
	if (!$input_errors) {
222

    
223
		$server = array();
224

    
225
		if ($vpnid)
226
			$server['vpnid'] = $vpnid;
227
		else
228
			$server['vpnid'] = openvpn_vpnid_next();
229

    
230
		$server['disable'] = $pconfig['disable'];
231
		$server['protocol'] = $pconfig['protocol'];
232
		$server['interface'] = $pconfig['interface'];
233
		$server['local_port'] = $pconfig['local_port'];
234
		$server['description'] = $pconfig['description'];
235

    
236
		$server['auth_method'] = $pconfig['auth_method'];
237
		if ($server['auth_method'] == "shared_key")
238
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
239
		else {
240
			$server['caref'] = $pconfig['caref'];
241
			$server['certref'] = $pconfig['certref'];
242
		}
243
		$server['crypto'] = $pconfig['crypto'];
244

    
245
		$server['tunnel_network'] = $pconfig['tunnel_network'];
246
		$server['remote_network'] = $pconfig['remote_network'];
247
		$server['gwredir'] = $pconfig['gwredir'];
248
		$server['local_network'] = $pconfig['local_network'];
249
		$server['maxclients'] = $pconfig['maxclients'];
250
		$server['compression'] = $pconfig['compression'];
251
		$server['client2client'] = $pconfig['client2client'];
252

    
253
		$server['pool_enable'] = $pconfig['pool_enable'];
254

    
255
		if ($pconfig['dns_domain_enable'])
256
			$server['dns_domain'] = $pconfig['dns_domain'];
257

    
258
		if ($pconfig['dns_server_enable']) {
259
			$server['dns_server1'] = $pconfig['dns_server1'];
260
			$server['dns_server2'] = $pconfig['dns_server2'];
261
			$server['dns_server3'] = $pconfig['dns_server3'];
262
			$server['dns_server4'] = $pconfig['dns_server4'];
263
		}
264

    
265
		if ($pconfig['ntp_server_enable']) {
266
			$server['ntp_server1'] = $pconfig['ntp_server1'];
267
			$server['ntp_server2'] = $pconfig['ntp_server2'];
268
		}
269

    
270
		$server['netbios_enable'] = $pconfig['netbios_enable'];
271
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
272
		$server['netbios_scope'] = $pconfig['netbios_scope'];
273

    
274
		if ($pconfig['netbios_enable']) {
275

    
276
			if ($pconfig['wins_server_enable']) {
277
				$server['wins_server1'] = $pconfig['wins_server1'];
278
				$server['wins_server2'] = $pconfig['wins_server2'];
279
			}
280

    
281
			if ($pconfig['dns_server_enable'])
282
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
283
		}
284
	
285
		if (isset($id) && $a_server[$id])
286
			$a_server[$id] = $server;
287
		else
288
			$a_server[] = $server;
289

    
290
		openvpn_resync('server', $server);
291
		write_config();
292
		
293
		header("Location: vpn_openvpn_server.php");
294
		exit;
295
	}
296
}
297

    
298
include("head.inc");
299

    
300
?>
301

    
302
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
303
<?php include("fbegin.inc"); ?>
304
<script language="JavaScript">
305
<!--
306

    
307
function method_change() {
308
	index = document.iform.auth_method.selectedIndex;
309
	value = document.iform.auth_method.options[index].value;
310
	switch(value) {
311
		case "pki":
312
			document.getElementById("pki_ca").style.display="";
313
			document.getElementById("pki_cert").style.display="";
314
			document.getElementById("psk").style.display="none";
315
			break;
316
		case "shared_key":
317
			document.getElementById("pki_ca").style.display="none";
318
			document.getElementById("pki_cert").style.display="none";
319
			document.getElementById("psk").style.display="";
320
			break;
321
	}
322
}
323

    
324
function gwredir_change() {
325

    
326
	if (document.iform.gwredir.checked)
327
		document.getElementById("local_opts").style.display="none";
328
	else
329
		document.getElementById("local_opts").style.display="";
330
}
331

    
332
function dns_domain_change() {
333

    
334
	if (document.iform.dns_domain_enable.checked)
335
		document.getElementById("dns_domain_data").style.display="";
336
	else
337
		document.getElementById("dns_domain_data").style.display="none";
338
}
339

    
340
function dns_server_change() {
341

    
342
	if (document.iform.dns_server_enable.checked)
343
		document.getElementById("dns_server_data").style.display="";
344
	else
345
		document.getElementById("dns_server_data").style.display="none";
346
}
347

    
348
function wins_server_change() {
349

    
350
	if (document.iform.wins_server_enable.checked)
351
		document.getElementById("wins_server_data").style.display="";
352
	else
353
		document.getElementById("wins_server_data").style.display="none";
354
}
355

    
356
function ntp_server_change() {
357

    
358
	if (document.iform.ntp_server_enable.checked)
359
		document.getElementById("ntp_server_data").style.display="";
360
	else
361
		document.getElementById("ntp_server_data").style.display="none";
362
}
363

    
364
function netbios_change() {
365

    
366
	if (document.iform.netbios_enable.checked) {
367
		document.getElementById("netbios_data").style.display="";
368
		document.getElementById("wins_opts").style.display="";
369
	} else {
370
		document.getElementById("netbios_data").style.display="none";
371
		document.getElementById("wins_opts").style.display="none";
372
	}
373
}
374

    
375
//-->
376
</script>
377
<?php
378
	if ($input_errors)
379
		print_input_errors($input_errors);
380
	if ($savemsg)
381
		print_info_box($savemsg);
382
?>
383
<table width="100%" border="0" cellpadding="0" cellspacing="0">
384
 	<tr>
385
		<td class="tabnavtbl">
386
			<ul id="tabnav">
387
			<?php 
388
				$tab_array = array();
389
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
390
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
391
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
392
				display_top_tabs($tab_array);
393
			?>
394
			</ul>
395
		</td>
396
	</tr>    
397
	<tr>
398
		<td class="tabcont">
399

    
400
			<?php if($act=="new" || $act=="edit"): ?>
401

    
402
			<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
403
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
404
					<tr>
405
						<td width="22%" valign="top" class="vncellreq">Disabled</td>
406
						<td width="78%" class="vtable">
407
							<table border="0" cellpadding="0" cellspacing="0">
408
								<tr>
409
									<td>
410
										<?php set_checked($pconfig['disable'],$chk); ?>
411
										<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
412
									</td>
413
									<td>
414
										&nbsp;
415
										<span class="vexpl">
416
											<strong>Disable this server</strong><br>
417
										</span>
418
									</td>
419
								</tr>
420
							</table>
421
							Set this option to disable this server without removing it from the list.
422
						</td>
423
					</tr>
424
					<tr>
425
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
426
							<td width="78%" class="vtable">
427
							<select name='protocol' class="formselect">
428
							<?php
429
								foreach ($openvpn_prots as $prot):
430
									$selected = "";
431
									if ($pconfig['protocol'] == $prot)
432
										$selected = "selected";
433
							?>
434
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
435
							<?php endforeach; ?>
436
							</select>
437
							</td>
438
					</tr>
439
					<tr>
440
						<td width="22%" valign="top" class="vncellreq">Interface</td>
441
						<td width="78%" class="vtable">
442
							<select name="interface" class="formselect">
443
								<?php
444
									$interfaces = get_configured_interface_with_descr();
445
									$carpips = find_number_of_needed_carp_interfaces();
446
									for ($i=0; $i<$carpips; $i++) {
447
										$carpip = find_interface_ip("carp" . $i);
448
										$interfaces['carp' . $i] = "CARP{$i} ({$carpip})";
449
									}
450
									foreach ($interfaces as $iface => $ifacename):
451
								?>
452
								<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
453
									<?=htmlspecialchars($ifacename);?>
454
								</option>
455
								<?php endforeach; ?>
456
							</select> <br>
457
						</td>
458
					</tr>
459
					<tr>
460
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Local port");?></td>
461
						<td width="78%" class="vtable">
462
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
463
						</td>
464
					</tr>
465
					<tr> 
466
						<td width="22%" valign="top" class="vncell">Description</td>
467
						<td width="78%" class="vtable"> 
468
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
469
							<br>
470
							You may enter a description here for your reference (not parsed).
471
						</td>
472
					</tr>
473
					<tr>
474
						<td colspan="2" class="list" height="12"></td>
475
					</tr>
476
					<tr>
477
						<td colspan="2" valign="top" class="listtopic">Cryptographic Settings</td>
478
					</tr>
479
					<tr>
480
						<td width="22%" valign="top" class="vncellreq">Authentication Method</td>
481
							<td width="78%" class="vtable">
482
							<select name='auth_method' id='auth_method' class="formselect" onchange='method_change()'>
483
							<?php
484
								foreach ($openvpn_auth_methods as $method => $name):
485
									$selected = "";
486
									if ($pconfig['auth_method'] == $method)
487
										$selected = "selected";
488
							?>
489
								<option value="<?=$method;?>" <?=$selected;?>><?=$name;?></option>
490
							<?php endforeach; ?>
491
							</select>
492
							</td>
493
					</tr>
494
					<tr id="pki_ca">
495
						<td width="22%" valign="top" class="vncellreq">Certificate Authority</td>
496
							<td width="78%" class="vtable">
497
							<select name='caref' class="formselect">
498
							<?php
499
								foreach ($config['system']['ca'] as $ca):
500
									$selected = "";
501
									if ($pconfig['caref'] == $ca['refid'])
502
										$selected = "selected";
503
							?>
504
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['name'];?></option>
505
							<?php endforeach; ?>
506
							</select>
507
							</td>
508
					</tr>
509
					<tr id="pki_cert">
510
						<td width="22%" valign="top" class="vncellreq">Certificate</td>
511
							<td width="78%" class="vtable">
512
							<select name='certref' class="formselect">
513
							<?php
514
								foreach ($config['system']['cert'] as $cert):
515
									$selected = "";
516
									if ($pconfig['certref'] == $cert['refid'])
517
										$selected = "selected";
518
							?>
519
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
520
							<?php endforeach; ?>
521
							</select>
522
						</td>
523
					</tr>
524
					<tr id="psk">
525
						<td width="22%" valign="top" class="vncellreq">Shared Key</td>
526
						<td width="78%" class="vtable"> 
527
							<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
528
							<br/>
529
							Paste your shared key here.
530
						</td>
531
					</tr>
532
					<tr>
533
						<td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
534
						<td width="78%" class="vtable">
535
							<select name="crypto" class="formselect">
536
								<?php
537
									$cipherlist = openvpn_get_cipherlist();
538
									foreach ($cipherlist as $name => $desc):
539
									$selected = '';
540
									if ($name == $pconfig['crypto'])
541
										$selected = ' selected';
542
								?>
543
								<option value="<?=$name;?>"<?=$selected?>>
544
									<?=htmlspecialchars($desc);?>
545
								</option>
546
								<?php endforeach; ?>
547
							</select>
548
						</td>
549
					</tr>
550
					<tr>
551
						<td colspan="2" class="list" height="12"></td>
552
					</tr>
553
					<tr>
554
						<td colspan="2" valign="top" class="listtopic">Tunnel Settings</td>
555
					</tr>
556
					<tr>
557
						<td width="22%" valign="top" class="vncellreq">Tunnel Network</td>
558
						<td width="78%" class="vtable">
559
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
560
							<br>
561
							This is the virtual network used for private
562
							communications between this server and client
563
							hosts expressed using CIDR (eg. 10.0.8.0/24).
564
							The first network address will be assigned to
565
							the	server virtual interface. The remaining
566
							network addresses can optionally be assigned
567
							to connecting clients. (see Address Pool)
568
						</td>
569
					</tr>
570
					<tr>
571
						<td width="22%" valign="top" class="vncell">Remote Network</td>
572
						<td width="78%" class="vtable">
573
							<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
574
							<br>
575
							This is a network that will be routed through
576
							the tunnel, so that a site-to-site VPN can be
577
							established without manually changing the
578
							routing tables. Expressed as a CIDR range. If
579
							this is a site-to-site VPN, enter here the
580
							remote LAN here. You may leave this blank if
581
							you don't want a site-to-site VPN.
582
						</td>
583
					</tr>
584
					<tr>
585
						<td width="22%" valign="top" class="vncell">Redirect Gateway</td>
586
						<td width="78%" class="vtable">
587
							<table border="0" cellpadding="2" cellspacing="0">
588
								<tr>
589
									<td>
590
										<?php set_checked($pconfig['gwredir'],$chk); ?>
591
										<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> onClick="gwredir_change()"/>
592
									</td>
593
									<td>
594
										<span class="vexpl">
595
											Force all client generated traffic through the tunnel.
596
										</span>
597
									</td>
598
								</tr>
599
							</table>
600
						</td>
601
					</tr>
602
					<tr id="local_opts">
603
						<td width="22%" valign="top" class="vncell">Local Network</td>
604
						<td width="78%" class="vtable">
605
							<input name="local_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['local_network']);?>">
606
							<br>
607
							This is the network that will be accessable
608
							from the remote endpoint. Expressed as a CIDR
609
							range. You may leave this blank if you don't
610
							want to add a route to the local network
611
							through this tunnel on the remote machine.
612
							This is generally set to your LAN network.
613
						</td>
614
					</tr>
615
					<tr>
616
						<td width="22%" valign="top" class="vncell"><?=gettext("Concurrent connections");?></td>
617
						<td width="78%" class="vtable">
618
							<input name="maxclients" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['maxclients']);?>"/>
619
							<br/>
620
							Specify the maximum number of clients allowed to concurrently connect to this server.
621
						</td>
622
					</tr>
623
					<tr>
624
						<td width="22%" valign="top" class="vncell">Compression</td>
625
						<td width="78%" class="vtable">
626
							<table border="0" cellpadding="2" cellspacing="0">
627
								<tr>
628
									<td>
629
										<?php set_checked($pconfig['compression'],$chk); ?>
630
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
631
									</td>
632
									<td>
633
										<span class="vexpl">
634
											Compress tunnel packets using the LZO algorithm.
635
										</span>
636
									</td>
637
								</tr>
638
							</table>
639
						</td>
640
					</tr>
641
					<tr>
642
						<td width="22%" valign="top" class="vncell">Type-of-Service</td>
643
						<td width="78%" class="vtable">
644
							<table border="0" cellpadding="2" cellspacing="0">
645
								<tr>
646
									<td>
647
										<?php set_checked($pconfig['settos'],$chk); ?>
648
										<input name="settos" type="checkbox" value="yes" <?=$chk;?>>
649
									</td>
650
									<td>
651
										<span class="vexpl">
652
											Set the TOS IP header value of tunnel packets to match the encapsulated packet value.
653
										</span>
654
									</td>
655
								</tr>
656
							</table>
657
						</td>
658
					</tr>
659
					<tr>
660
						<td width="22%" valign="top" class="vncell">Inter-client communication</td>
661
						<td width="78%" class="vtable">
662
							<table border="0" cellpadding="2" cellspacing="0">
663
								<tr>
664
									<td>
665
										<?php set_checked($pconfig['client2client'],$chk); ?>
666
										<input name="client2client" type="checkbox" value="yes" <?=$chk;?>/>
667
									</td>
668
									<td>
669
										<span class="vexpl">
670
											Allow communication between clients connected to this server
671
										</span>
672
									</td>
673
								</tr>
674
							</table>
675
						</td>
676
					</tr>
677
					<tr>
678
						<td colspan="2" class="list" height="12"></td>
679
					</tr>
680
					<tr>
681
						<td colspan="2" valign="top" class="listtopic">Client Settings</td>
682
					</tr>
683
					<tr>
684
						<td width="22%" valign="top" class="vncell">Address Pool</td>
685
						<td width="78%" class="vtable">
686
							<table border="0" cellpadding="2" cellspacing="0">
687
								<tr>
688
									<td>
689
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
690
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>">
691
									</td>
692
									<td>
693
										<span class="vexpl">
694
											Provide a virtual adapter IP address to clients (see Tunnel Network)<br>
695
										</span>
696
									</td>
697
								</tr>
698
							</table>
699
						</td>
700
					</tr>
701
					<tr>
702
						<td width="22%" valign="top" class="vncell">DNS Default Domain</td>
703
						<td width="78%" class="vtable">
704
							<table border="0" cellpadding="2" cellspacing="0">
705
								<tr>
706
									<td>
707
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
708
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
709
									</td>
710
									<td>
711
										<span class="vexpl">
712
	                                        Provide a default domain name to clients<br>
713
										</span>
714
									</td>
715
								</tr>
716
							</table>
717
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
718
								<tr>
719
									<td>
720
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
721
									</td>
722
								</tr>
723
							</table>
724
						</td>
725
					</tr>
726
					<tr>
727
						<td width="22%" valign="top" class="vncell">DNS Servers</td>
728
						<td width="78%" class="vtable">
729
							<table border="0" cellpadding="2" cellspacing="0">
730
								<tr>
731
									<td>
732
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
733
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
734
									</td>
735
									<td>
736
										<span class="vexpl">
737
											Provide a DNS server list to clients<br>
738
										</span>
739
									</td>
740
								</tr>
741
							</table>
742
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
743
								<tr>
744
									<td>
745
										<span class="vexpl">
746
											Server #1:&nbsp;
747
										</span>
748
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=$pconfig['dns_server1'];?>">
749
									</td>
750
								</tr>
751
								<tr>
752
									<td>
753
										<span class="vexpl">
754
											Server #2:&nbsp;
755
										</span>
756
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=$pconfig['dns_server2'];?>">
757
									</td>
758
								</tr>
759
								<tr>
760
									<td>
761
										<span class="vexpl">
762
											Server #3:&nbsp;
763
										</span>
764
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=$pconfig['dns_server3'];?>">
765
									</td>
766
								</tr>
767
								<tr>
768
									<td>
769
										<span class="vexpl">
770
											Server #4:&nbsp;
771
										</span>
772
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=$pconfig['dns_server4'];?>">
773
									</td>
774
								</tr>
775
							</table>
776
						</td>
777
					</tr>
778
					<tr>
779
						<td width="22%" valign="top" class="vncell">NTP Servers</td>
780
						<td width="78%" class="vtable">
781
							<table border="0" cellpadding="2" cellspacing="0">
782
								<tr>
783
									<td>
784
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
785
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
786
									</td>
787
									<td>
788
										<span class="vexpl">
789
											Provide a NTP server list to clients<br>
790
										</span>
791
									</td>
792
								</tr>
793
							</table>
794
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
795
								<tr>
796
									<td>
797
										<span class="vexpl">
798
											Server #1:&nbsp;
799
										</span>
800
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=$pconfig['ntp_server1'];?>">
801
									</td>
802
								</tr>
803
								<tr>
804
									<td>
805
										<span class="vexpl">
806
											Server #2:&nbsp;
807
										</span>
808
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=$pconfig['ntp_server2'];?>">
809
									</td>
810
								</tr>
811
							</table>
812
						</td>
813
					</tr>
814
					<tr>
815
						<td width="22%" valign="top" class="vncell">NetBIOS Options</td>
816
						<td width="78%" class="vtable">
817
							<table border="0" cellpadding="2" cellspacing="0">
818
								<tr>
819
									<td>
820
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
821
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
822
									</td>
823
									<td>
824
										<span class="vexpl">
825
											Enable NetBIOS over TCP/IP<br>
826
										</span>
827
									</td>
828
								</tr>
829
							</table>
830
							If this option is not set, all Netbios-over-TCP/IP options (includeing WINS) will be disabled.
831
							<br/>
832
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
833
								<tr>
834
									<td>
835
										<br/>
836
										<span class="vexpl">
837
											Node Type:&nbsp;
838
										</span>
839
										<select name='netbios_ntype' class="formselect">
840
										<?php
841
											foreach ($netbios_nodetypes as $type => $name):
842
												$selected = "";
843
												if ($pconfig['netbios_ntype'] == $type)
844
													$selected = "selected";
845
										?>
846
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
847
										<?php endforeach; ?>
848
										</select>
849
										<br/>
850
										Possible options: b-node (broadcasts), p-node
851
										(point-to-point name queries to a WINS server),
852
										m-node (broadcast then query name server), and
853
										h-node (query name server, then broadcast).
854
									</td>
855
								</tr>
856
								<tr>
857
									<td>
858
										<br/>
859
										<span class="vexpl">
860
											Scope ID:&nbsp;
861
										</span>
862
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
863
										<br/>
864
										A NetBIOS Scope	ID provides an extended naming
865
										service for	NetBIOS over TCP/IP. The NetBIOS
866
										scope ID isolates NetBIOS traffic on a single
867
										network to only those nodes with the same
868
										NetBIOS scope ID.
869
									</td>
870
								</tr>
871
							</table>
872
						</td>
873
					</tr>
874
					<tr id="wins_opts">
875
						<td width="22%" valign="top" class="vncell">WINS Servers</td>
876
						<td width="78%" class="vtable">
877
							<table border="0" cellpadding="2" cellspacing="0">
878
								<tr>
879
									<td>
880
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
881
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
882
									</td>
883
									<td>
884
										<span class="vexpl">
885
											Provide a WINS server list to clients<br>
886
										</span>
887
									</td>
888
								</tr>
889
							</table>
890
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
891
								<tr>
892
									<td>
893
										<span class="vexpl">
894
											Server #1:&nbsp;
895
										</span>
896
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=$pconfig['wins_server1'];?>">
897
									</td>
898
								</tr>
899
								<tr>
900
									<td>
901
										<span class="vexpl">
902
											Server #2:&nbsp;
903
										</span>
904
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=$pconfig['wins_server2'];?>">
905
									</td>
906
								</tr>
907
							</table>
908
						</td>
909
					</tr>
910
					<tr>
911
						<td width="22%" valign="top">&nbsp;</td>
912
						<td width="78%"> 
913
							<input name="save" type="submit" class="formbtn" value="Save"> 
914
							<input name="act" type="hidden" value="<?=$act;?>">
915
							<?php if (isset($id) && $a_server[$id]): ?>
916
							<input name="id" type="hidden" value="<?=$id;?>">
917
							<?php endif; ?>
918
						</td>
919
					</tr>
920
				</table>
921
			</form>
922

    
923
			<?php else: ?>
924

    
925
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
926
				<tr>
927
					<td width="10%" class="listhdrr">Disabled</td>
928
					<td width="10%" class="listhdrr">Protocol</td>
929
					<td width="30%" class="listhdrr">Tunnel Network</td>
930
					<td width="40%" class="listhdrr">Description</td>
931
					<td width="10%" class="list"></td>
932
				</tr>
933
				<?php
934
					$i = 0;
935
					foreach($a_server as $server):
936
						$disabled = "NO";
937
						if ($server['disable'])
938
							$disabled = "YES";
939
				?>
940
				<tr>
941
					<td class="listlr">
942
						<?=$disabled;?>
943
					</td>
944
					<td class="listr">
945
						<?=htmlspecialchars($server['protocol']);?>
946
					</td>
947
					<td class="listr">
948
						<?=htmlspecialchars($server['tunnel_network']);?>
949
					</td>
950
					<td class="listr">
951
						<?=htmlspecialchars($server['description']);?>
952
					</td>
953
					<td valign="middle" nowrap class="list">
954
						<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
955
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit server" width="17" height="17" border="0">
956
						</a>
957
						&nbsp;
958
						<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this server?')">
959
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete server" width="17" height="17" border="0">
960
						</a>
961
					</td>
962
				</tr>
963
				<?php
964
					$i++;
965
					endforeach;
966
				?>
967
				<tr>
968
					<td class="list" colspan="4"></td>
969
					<td class="list">
970
						<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">
971
						</a>
972
					</td>
973
				</tr>
974
				<tr>
975
					<td colspan="4">
976
						<p>
977
							<?=gettext("Additional OpenVPN servers can be added here.");?>
978
						</p>
979
					</td>
980
				</tr>
981
			</table>
982

    
983
			<? endif; ?>
984

    
985
		</td>
986
	</tr>
987
</table>
988
<script language="JavaScript">
989
<!--
990
method_change();
991
gwredir_change();
992
dns_domain_change();
993
dns_server_change();
994
wins_server_change();
995
ntp_server_change();
996
netbios_change();
997
//-->
998
</script>
999
</body>
1000
<?php include("fend.inc"); ?>
1001

    
1002
<?php
1003

    
1004
/* local utility functions */
1005

    
1006
function set_checked($var,& $chk) {
1007
    if($var)
1008
        $chk = 'checked';
1009
    else
1010
        $chk = '';
1011
}
1012

    
1013
?>
1014

    
(197-197/205)