Project

General

Profile

Download (24.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php 
2
/*
3
	vpn_openvpn_client.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-client
32
##|*NAME=OpenVPN: Client page
33
##|*DESCR=Allow access to the 'OpenVPN: Client' page.
34
##|*MATCH=vpn_openvpn_client.php*
35
##|-PRIV
36

    
37

    
38
require("guiconfig.inc");
39

    
40
$pgtitle = array("OpenVPN", "Client");
41

    
42
if (!is_array($config['openvpn']['openvpn-client']))
43
	$config['openvpn']['openvpn-client'] = array();
44

    
45
$a_client = &$config['openvpn']['openvpn-client'];
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_client[$id]) {
58
		pfSenseHeader("vpn_openvpn_client.php");
59
		exit;
60
	}
61

    
62
	openvpn_delete('client', $a_client[$id]);
63
	unset($a_client[$id]);
64
	write_config();
65
	$savemsg = gettext("Client 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['interface'] = "wan";
73
	$pconfig['server_port'] = 1194;
74
}
75

    
76
if($_GET['act']=="edit"){
77

    
78
	if (isset($id) && $a_client[$id]) {
79

    
80
		$pconfig['disable'] = $a_client[$id]['disable'];
81
		$pconfig['mode'] = $a_client[$id]['mode'];
82
		$pconfig['protocol'] = $a_client[$id]['protocol'];
83
		$pconfig['interface'] = $a_client[$id]['interface'];
84
		$pconfig['local_port'] = $a_client[$id]['local_port'];
85
		$pconfig['server_addr'] = $a_client[$id]['server_addr'];
86
		$pconfig['server_port'] = $a_client[$id]['server_port'];
87
		$pconfig['resolve_retry'] = $a_client[$id]['resolve_retry'];
88
		$pconfig['proxy_addr'] = $a_client[$id]['proxy_addr'];
89
		$pconfig['proxy_port'] = $a_client[$id]['proxy_port'];
90
		$pconfig['description'] = $a_client[$id]['description'];
91

    
92
		if ($pconfig['mode'] != "p2p_shared_key") {
93
			$pconfig['caref'] = $a_client[$id]['caref'];
94
			$pconfig['certref'] = $a_client[$id]['certref'];
95
			if ($a_client[$id]['tls']) {
96
				$pconfig['tlsauth_enable'] = "yes";
97
				$pconfig['tls'] = base64_decode($a_client[$id]['tls']);
98
			}
99
		} else
100
			$pconfig['shared_key'] = base64_decode($a_client[$id]['shared_key']);
101
		$pconfig['crypto'] = $a_client[$id]['crypto'];
102

    
103
		$pconfig['tunnel_network'] = $a_client[$id]['tunnel_network'];
104
		$pconfig['remote_network'] = $a_client[$id]['remote_network'];
105
		$pconfig['compression'] = $a_client[$id]['compression'];
106
		$pconfig['passtos'] = $a_client[$id]['passtos'];
107

    
108
		// just in case the modes switch
109
		$pconfig['autokey_enable'] = "yes";
110
		$pconfig['autotls_enable'] = "yes";
111
	}
112
}
113

    
114
if ($_POST) {
115

    
116
	unset($input_errors);
117
	$pconfig = $_POST;
118

    
119
	if (isset($id) && $a_client[$id])
120
		$vpnid = $a_client[$id]['vpnid'];
121
	else
122
		$vpnid = 0;
123

    
124
	if ($client['mode'] != "p2p_shared_key")
125
		$tls_mode = true;
126
	else
127
		$tls_mode = false;
128

    
129
	/* input validation */
130
	if ($pconfig['local_port']) {
131

    
132
		if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
133
			$input_errors[] = $result;
134

    
135
		if (openvpn_port_used($pconfig['protocol'], $pconfig['local_port']) != $vpnid)
136
			$input_errors[] = "The specified 'Local port' is in use. Please select another value";
137
	}
138

    
139
	if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address'))
140
		$input_errors[] = $result;
141

    
142
	if ($result = openvpn_validate_port($pconfig['server_port'], 'Server port'))
143
		$input_errors[] = $result;
144

    
145
	if ($pconfig['proxy_addr']) {
146

    
147
		if ($result = openvpn_validate_host($pconfig['proxy_addr'], 'Proxy host or address'))
148
			$input_errors[] = $result;
149

    
150
		if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port'))
151
			$input_errors[] = $result;
152
	}
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 (!$tls_mode && !$pconfig['autokey_enable'])
161
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
162
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
163
			$input_errors[] = "The field 'Shared Key' does not appear to be valid";
164

    
165
	if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
166
		if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
167
			!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
168
			$input_errors[] = "The field 'TLS Authentication Key' does not appear to be valid";
169

    
170
	if (!$tls_mode) {
171
		$reqdfields = array('shared_key');
172
		$reqdfieldsn = array('Shared key');
173
    } else {
174
		$reqdfields = explode(" ", "caref certref");
175
		$reqdfieldsn = explode(",", "Certificate Authority,Certificate");;
176
	}
177

    
178
    $reqdfields[] = 'tunnel_network';
179
    $reqdfieldsn[] = 'Tunnel network';
180

    
181
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
182
	
183
	if (!$input_errors) {
184

    
185
		$client = array();
186

    
187
		if ($vpnid)
188
			$client['vpnid'] = $vpnid;
189
		else
190
			$client['vpnid'] = openvpn_vpnid_next();
191

    
192
		$client['disable'] = $pconfig['disable'];
193
		$client['protocol'] = $pconfig['protocol'];
194
		$client['interface'] = $pconfig['interface'];
195
		$client['local_port'] = $pconfig['local_port'];
196
		$client['server_addr'] = $pconfig['server_addr'];
197
		$client['server_port'] = $pconfig['server_port'];
198
		$client['resolve_retry'] = $pconfig['resolve_retry'];
199
		$client['proxy_addr'] = $pconfig['proxy_addr'];
200
		$client['proxy_port'] = $pconfig['proxy_port'];
201
		$client['description'] = $pconfig['description'];
202

    
203
        if ($tls_mode) {
204
            $client['caref'] = $pconfig['caref'];
205
            $client['certref'] = $pconfig['certref'];
206
            if ($pconfig['tlsauth_enable']) {
207
                if ($pconfig['autotls_enable'])
208
                    $pconfig['tls'] = openvpn_create_key();
209
                $client['tls'] = base64_encode($pconfig['tls']);
210
            }
211
        } else {
212
            if ($pconfig['autokey_enable'])
213
                $pconfig['shared_key'] = openvpn_create_key();
214
            $client['shared_key'] = base64_encode($pconfig['shared_key']);
215
        }
216
		$client['crypto'] = $pconfig['crypto'];
217

    
218
		$client['tunnel_network'] = $pconfig['tunnel_network'];
219
		$client['remote_network'] = $pconfig['remote_network'];
220
		$client['compression'] = $pconfig['compression'];
221

    
222
		if (isset($id) && $a_client[$id])
223
			$a_client[$id] = $client;
224
		else
225
			$a_client[] = $client;
226

    
227
		openvpn_resync('client', $client);
228
		write_config();
229
		
230
		header("Location: vpn_openvpn_client.php");
231
		exit;
232
	}
233
}
234

    
235
include("head.inc");
236

    
237
?>
238

    
239
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
240
<?php include("fbegin.inc"); ?>
241
<script language="JavaScript">
242
<!--
243

    
244
function mode_change() {
245
	index = document.iform.mode.selectedIndex;
246
	value = document.iform.mode.options[index].value;
247
	switch(value) {
248
		case "p2p_tls":
249
			document.getElementById("tls").style.display="";
250
			document.getElementById("tls_ca").style.display="";
251
			document.getElementById("tls_cert").style.display="";
252
			document.getElementById("psk").style.display="none";
253
			break;
254
		case "p2p_shared_key":
255
			document.getElementById("tls").style.display="none";
256
			document.getElementById("tls_ca").style.display="none";
257
			document.getElementById("tls_cert").style.display="none";
258
			document.getElementById("psk").style.display="";
259
			break;
260
	}
261
}
262

    
263
function autokey_change() {
264
	if (document.iform.autokey_enable.checked)
265
		document.getElementById("autokey_opts").style.display="none";
266
	else
267
		document.getElementById("autokey_opts").style.display="";
268
}
269

    
270
function tlsauth_change() {
271

    
272
<?php if (!$pconfig['tls']): ?>
273
	if (document.iform.tlsauth_enable.checked)
274
		document.getElementById("tlsauth_opts").style.display="";
275
	else
276
		document.getElementById("tlsauth_opts").style.display="none";
277
<?php endif; ?>
278

    
279
	autotls_change();
280
}
281

    
282
function autotls_change() {
283

    
284
<?php if (!$pconfig['tls']): ?>
285
	autocheck = document.iform.autotls_enable.checked;
286
<?php else: ?>
287
	autocheck = false;
288
<?php endif; ?>
289

    
290
	if (document.iform.tlsauth_enable.checked && !autocheck)
291
		document.getElementById("autotls_opts").style.display="";
292
	else
293
		document.getElementById("autotls_opts").style.display="none";
294
}
295

    
296
//-->
297
</script>
298
<?php
299
	if ($input_errors)
300
		print_input_errors($input_errors);
301
	if ($savemsg)
302
		print_info_box($savemsg);
303
?>
304
<table width="100%" border="0" cellpadding="0" cellspacing="0">
305
 	<tr>
306
		<td class="tabnavtbl">
307
			<ul id="tabnav">
308
			<?php 
309
				$tab_array = array();
310
				$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
311
				$tab_array[] = array(gettext("Client"), true, "vpn_openvpn_client.php");
312
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
313
				add_package_tabs("OpenVPN", $tab_array);
314
				display_top_tabs($tab_array);
315
			?>
316
			</ul>
317
		</td>
318
	</tr>    
319
	<tr>
320
		<td class="tabcont">
321

    
322
			<?php if($act=="new" || $act=="edit"): ?>
323

    
324
			<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
325
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
326
					<tr>
327
						<td colspan="2" valign="top" class="listtopic">General information</td>
328
					</tr>
329
					<tr>
330
						<td width="22%" valign="top" class="vncellreq">Disabled</td>
331
						<td width="78%" class="vtable">
332
							<table border="0" cellpadding="0" cellspacing="0">
333
								<tr>
334
									<td>
335
										<?php set_checked($pconfig['disable'],$chk); ?>
336
										<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
337
									</td>
338
									<td>
339
										&nbsp;
340
										<span class="vexpl">
341
											<strong>Disable this client</strong><br>
342
										</span>
343
									</td>
344
								</tr>
345
							</table>
346
							Set this option to disable this client without removing it from the list.
347
						</td>
348
					</tr>
349
					<tr>
350
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
351
						<td width="78%" class="vtable">
352
							<select name='mode' id='mode' class="formselect" onchange='mode_change()'>
353
							<?php
354
								foreach ($openvpn_client_modes as $name => $desc):
355
									$selected = "";
356
									if ($pconfig['mode'] == $name)
357
										$selected = "selected";
358
							?>
359
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
360
							<?php endforeach; ?>
361
							</select>
362
						</td>
363
					</tr>
364
					<tr>
365
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
366
							<td width="78%" class="vtable">
367
							<select name='protocol' class="formselect">
368
							<?php
369
								foreach ($openvpn_prots as $prot):
370
									$selected = "";
371
									if ($pconfig['protocol'] == $prot)
372
										$selected = "selected";
373
							?>
374
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
375
							<?php endforeach; ?>
376
							</select>
377
							</td>
378
					</tr>
379
					<tr>
380
						<td width="22%" valign="top" class="vncellreq">Interface</td>
381
						<td width="78%" class="vtable">
382
							<select name="interface" class="formselect">
383
								<?php
384
									$interfaces = get_configured_interface_with_descr();
385
										foreach ($interfaces as $iface => $ifacename):
386
										$selected = "";
387
										if ($iface == $pconfig['interface'])
388
											$selected = "selected";
389
								?>
390
									<option value="<?=$iface;?>" <?=$selected;?>>
391
										<?=htmlspecialchars($ifacename);?>
392
									</option>
393
								<?php endforeach; ?>
394
							</select> <br>
395
						</td>
396
					</tr>
397
					<tr>
398
						<td width="22%" valign="top" class="vncell"><?=gettext("Local port");?></td>
399
						<td width="78%" class="vtable">
400
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
401
							<br/>
402
							Set this option if you would like to bind to a specific port.
403
						</td>
404
					</tr>
405
					<tr>
406
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server host or address");?></td>
407
						<td width="78%" class="vtable">
408
							<input name="server_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['server_addr']);?>"/>
409
						</td>
410
					</tr>
411
					<tr>
412
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server port");?></td>
413
						<td width="78%" class="vtable">
414
							<input name="server_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['server_port']);?>"/>
415
						</td>
416
					</tr>
417
					<tr>
418
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy host or address");?></td>
419
						<td width="78%" class="vtable">
420
							<input name="proxy_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['proxy_addr']);?>"/>
421
						</td>
422
					</tr>
423
					<tr>
424
						<td width="22%" valign="top" class="vncell"><?=gettext("Proxy port");?></td>
425
						<td width="78%" class="vtable">
426
							<input name="proxy_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['proxy_port']);?>"/>
427
						</td>
428
					</tr>
429
					<tr>
430
						<td width="22%" valign="top" class="vncell">Server host name resolution</td>
431
						<td width="78%" class="vtable">
432
							<table border="0" cellpadding="2" cellspacing="0">
433
								<tr>
434
									<td>
435
										<?php set_checked($pconfig['resolve_retry'],$chk); ?>
436
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
437
									</td>
438
									<td>
439
										<span class="vexpl">
440
											Infinitely resolve server
441
										</span>
442
									</td>
443
								</tr>
444
							</table>
445
							Continuously attempt to resolve the server host
446
							name. Useful when communicating with a server
447
							that is not permanently connected to the internet.
448
						</td>
449
					</tr>
450
					<tr> 
451
						<td width="22%" valign="top" class="vncell">Description</td>
452
						<td width="78%" class="vtable"> 
453
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
454
							<br>
455
							You may enter a description here for your reference (not parsed).
456
						</td>
457
					</tr>
458
					<tr>
459
						<td colspan="2" class="list" height="12"></td>
460
					</tr>
461
					<tr>
462
						<td colspan="2" valign="top" class="listtopic">Cryptographic Settings</td>
463
					</tr>
464
					<tr id="tls">
465
						<td width="22%" valign="top" class="vncellreq">TLS Authentication</td>
466
						<td width="78%" class="vtable">
467
							<table border="0" cellpadding="2" cellspacing="0">
468
								<tr>
469
									<td>
470
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
471
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onClick="tlsauth_change()">
472
									</td>
473
									<td>
474
										<span class="vexpl">
475
											Enable authentication of TLS packets.
476
										</span>
477
									</td>
478
								</tr>
479
							</table>
480
							<?php if (!$pconfig['tls']): ?>
481
							<table border="0" cellpadding="2" cellspacing="0" id='tlsauth_opts'>
482
								<tr>
483
									<td>
484
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
485
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autotls_change()">
486
									</td>
487
									<td>
488
										<span class="vexpl">
489
											Automatically generate a shared TLS authentication key.
490
										</span>
491
									</td>
492
								</tr>
493
							</table>
494
							<?php endif; ?>
495
							<table border="0" cellpadding="2" cellspacing="0" id='autotls_opts'>
496
								<tr>
497
									<td>
498
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
499
										<br/>
500
										Paste your shared key here.
501
									</td>
502
								</tr>
503
							</table>
504
						</td>
505
					</tr>
506
					<tr id="tls_ca">
507
						<td width="22%" valign="top" class="vncellreq">Peer Certificate Authority</td>
508
							<td width="78%" class="vtable">
509
							<select name='caref' class="formselect">
510
							<?php
511
								foreach ($config['system']['ca'] as $ca):
512
									$selected = "";
513
									if ($pconfig['caref'] == $ca['refid'])
514
										$selected = "selected";
515
							?>
516
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['name'];?></option>
517
							<?php endforeach; ?>
518
							</select>
519
							</td>
520
					</tr>
521
					<tr id="tls_cert">
522
						<td width="22%" valign="top" class="vncellreq">Client Certificate</td>
523
							<td width="78%" class="vtable">
524
							<select name='certref' class="formselect">
525
							<?php
526
								foreach ($config['system']['cert'] as $cert):
527
									$selected = "";
528
									if ($pconfig['certref'] == $cert['refid'])
529
										$selected = "selected";
530
							?>
531
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
532
							<?php endforeach; ?>
533
							</select>
534
						</td>
535
					</tr>
536
					<tr id="psk">
537
						<td width="22%" valign="top" class="vncellreq">Shared Key</td>
538
						<td width="78%" class="vtable">
539
							<?php if (!$pconfig['shared_key']): ?>
540
							<table border="0" cellpadding="2" cellspacing="0">
541
								<tr>
542
									<td>
543
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
544
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autokey_change()">
545
									</td>
546
									<td>
547
										<span class="vexpl">
548
											Automatically generate a shared key.
549
										</span>
550
									</td>
551
								</tr>
552
							</table>
553
							<?php endif; ?>
554
							<table border="0" cellpadding="2" cellspacing="0" id='autokey_opts'>
555
								<tr>
556
									<td>
557
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
558
										<br/>
559
										Paste your shared key here.
560
									</td>
561
								</tr>
562
							</table>
563
						</td>
564
					</tr>
565
					<tr>
566
						<td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
567
						<td width="78%" class="vtable">
568
							<select name="crypto" class="formselect">
569
								<?php
570
									$cipherlist = openvpn_get_cipherlist();
571
									foreach ($cipherlist as $name => $desc):
572
									$selected = '';
573
									if ($name == $pconfig['crypto'])
574
										$selected = ' selected';
575
								?>
576
								<option value="<?=$name;?>"<?=$selected?>>
577
									<?=htmlspecialchars($desc);?>
578
								</option>
579
								<?php endforeach; ?>
580
							</select>
581
						</td>
582
					</tr>
583
					<tr>
584
						<td colspan="2" class="list" height="12"></td>
585
					</tr>
586
					<tr>
587
						<td colspan="2" valign="top" class="listtopic">Tunnel Settings</td>
588
					</tr>
589
					<tr>
590
						<td width="22%" valign="top" class="vncellreq">Tunnel Network</td>
591
						<td width="78%" class="vtable">
592
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
593
							<br>
594
							This is the virtual network used for private
595
							communications between this client and the
596
							server expressed using CIDR (eg. 10.0.8.0/24).
597
							The first network address is assumed to be the
598
							server address and the second network address
599
							will be assigned to the client virtual
600
							interface.
601
						</td>
602
					</tr>
603
					<tr>
604
						<td width="22%" valign="top" class="vncell">Remote Network</td>
605
						<td width="78%" class="vtable">
606
							<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
607
							<br>
608
							This is a network that will be routed through
609
							the tunnel, so that a site-to-site VPN can be
610
							established without manually changing the
611
							routing tables. Expressed as a CIDR range. If
612
							this is a site-to-site VPN, enter here the
613
							remote LAN here. You may leave this blank to
614
							only communicate with other clients.
615
						</td>
616
					</tr>
617
					<tr>
618
						<td width="22%" valign="top" class="vncell"><?=gettext("Limit outgoing bandwidth");?></td>
619
						<td width="78%" class="vtable">
620
							<input name="use_shaper" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['use_shaper']);?>"/>
621
							<br/>
622
							Maximum outgoing bandwidth for this tunnel.
623
							Leave empty for no limit. The input value has
624
							to be something between 100 bytes/sec and 100
625
							Mbytes/sec (entered as bytes per second).
626
						</td>
627
					</tr>
628
					<tr>
629
						<td width="22%" valign="top" class="vncell">Compression</td>
630
						<td width="78%" class="vtable">
631
							<table border="0" cellpadding="2" cellspacing="0">
632
								<tr>
633
									<td>
634
										<?php set_checked($pconfig['compression'],$chk); ?>
635
										<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
636
									</td>
637
									<td>
638
										<span class="vexpl">
639
											Compress tunnel packets using the LZO algorithm.
640
										</span>
641
									</td>
642
								</tr>
643
							</table>
644
						</td>
645
					</tr>
646
					<tr>
647
						<td width="22%" valign="top" class="vncell">Type-of-Service</td>
648
						<td width="78%" class="vtable">
649
							<table border="0" cellpadding="2" cellspacing="0">
650
								<tr>
651
									<td>
652
										<?php set_checked($pconfig['passtos'],$chk); ?>
653
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?>>
654
									</td>
655
									<td>
656
										<span class="vexpl">
657
											Set the TOS IP header value of tunnel packets to match the encapsulated packet value.
658
										</span>
659
									</td>
660
								</tr>
661
							</table>
662
						</td>
663
					</tr>
664
					<tr>
665
						<td width="22%" valign="top">&nbsp;</td>
666
						<td width="78%"> 
667
							<input name="save" type="submit" class="formbtn" value="Save"> 
668
							<input name="act" type="hidden" value="<?=$act;?>">
669
							<?php if (isset($id) && $a_client[$id]): ?>
670
							<input name="id" type="hidden" value="<?=$id;?>">
671
							<?php endif; ?>
672
						</td>
673
					</tr>
674
				</table>
675
			</form>
676

    
677
			<?php else: ?>
678

    
679
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
680
				<tr>
681
					<td width="10%" class="listhdrr">Disabled</td>
682
					<td width="10%" class="listhdrr">Protocol</td>
683
					<td width="30%" class="listhdrr">Server</td>
684
					<td width="40%" class="listhdrr">Description</td>
685
					<td width="10%" class="list"></td>
686
				</tr>
687
				<?php
688
					$i = 0;
689
					foreach($a_client as $client):
690
						$disabled = "NO";
691
						if ($client['disable'])
692
							$disabled = "YES";
693
						$server = "{$client['server_addr']}:{$client['server_port']}";
694
				?>
695
				<tr>
696
					<td class="listlr">
697
						<?=$disabled;?>
698
					</td>
699
					<td class="listr">
700
						<?=htmlspecialchars($client['protocol']);?>
701
					</td>
702
					<td class="listr">
703
						<?=htmlspecialchars($server);?>
704
					</td>
705
					<td class="listbg">
706
						<?=htmlspecialchars($client['description']);?>
707
					</td>
708
					<td valign="middle" nowrap class="list">
709
						<a href="vpn_openvpn_client.php?act=edit&id=<?=$i;?>">
710
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit client" width="17" height="17" border="0">
711
						</a>
712
						&nbsp;
713
						<a href="vpn_openvpn_client.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this client?')">
714
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete client" width="17" height="17" border="0">
715
						</a>
716
					</td>
717
				</tr>
718
				<?php
719
					$i++;
720
					endforeach;
721
				?>
722
				<tr>
723
					<td class="list" colspan="4"></td>
724
					<td class="list">
725
						<a href="vpn_openvpn_client.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="add client" width="17" height="17" border="0">
726
						</a>
727
					</td>
728
				</tr>
729
				<tr>
730
					<td colspan="4">
731
						<p>
732
							<?=gettext("Additional OpenVPN clients can be added here.");?>
733
						</p>
734
					</td>
735
				</tr>
736
			</table>
737

    
738
			<? endif; ?>
739

    
740
		</td>
741
	</tr>
742
</table>
743
<script language="JavaScript">
744
<!--
745
mode_change();
746
autokey_change();
747
tlsauth_change();
748
//-->
749
</script>
750
</body>
751
<?php include("fend.inc"); ?>
752

    
753
<?php
754

    
755
/* local utility functions */
756

    
757
function set_checked($var,& $chk) {
758
    if($var)
759
        $chk = 'checked';
760
    else
761
        $chk = '';
762
}
763

    
764
?>
765

    
(199-199/209)