Project

General

Profile

Download (24.7 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
		$portused = openvpn_port_used($pconfig['protocol'], $pconfig['local_port']);
136
		if (($portused != $vpnid) && ($portused != 0))
137
			$input_errors[] = "The specified 'Local port' is in use. Please select another value";
138
	}
139

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

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

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

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

    
151
		if ($result = openvpn_validate_port($pconfig['proxy_port'], 'Proxy port'))
152
			$input_errors[] = $result;
153
	}
154

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

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

    
161
	if (!$tls_mode && !$pconfig['autokey_enable'])
162
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
163
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
164
			$input_errors[] = "The field 'Shared Key' does not appear to be valid";
165

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

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

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

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

    
186
		$client = array();
187

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

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

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

    
220
		$client['tunnel_network'] = $pconfig['tunnel_network'];
221
		$client['remote_network'] = $pconfig['remote_network'];
222
		$client['compression'] = $pconfig['compression'];
223

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

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

    
237
include("head.inc");
238

    
239
?>
240

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

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

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

    
272
function tlsauth_change() {
273

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

    
281
	autotls_change();
282
}
283

    
284
function autotls_change() {
285

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

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

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

    
324
			<?php if($act=="new" || $act=="edit"): ?>
325

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

    
679
			<?php else: ?>
680

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

    
740
			<? endif; ?>
741

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

    
755
<?php
756

    
757
/* local utility functions */
758

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

    
766
?>
767

    
(197-197/207)