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
require_once("openvpn.inc");
40

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

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

    
46
$a_client = &$config['openvpn']['openvpn-client'];
47

    
48
$id = $_GET['id'];
49
if (isset($_POST['id']))
50
	$id = $_POST['id'];
51

    
52
$act = $_GET['act'];
53
if (isset($_POST['act']))
54
	$act = $_POST['act'];
55

    
56
if ($_GET['act'] == "del") {
57

    
58
	if (!$a_client[$id]) {
59
		pfSenseHeader("vpn_openvpn_client.php");
60
		exit;
61
	}
62

    
63
	openvpn_delete('client', $a_client[$id]);
64
	unset($a_client[$id]);
65
	write_config();
66
	$savemsg = gettext("Client successfully deleted")."<br/>";
67
}
68

    
69
if($_GET['act']=="new"){
70
	$pconfig['autokey_enable'] = "yes";
71
	$pconfig['tlsauth_enable'] = "yes";
72
	$pconfig['autotls_enable'] = "yes";
73
	$pconfig['interface'] = "wan";
74
	$pconfig['server_port'] = 1194;
75
}
76

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

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

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

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

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

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

    
115
if ($_POST) {
116

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

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

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

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

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

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

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

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

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

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

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

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

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

    
162
    if ($pconfig['autokey_enable'])
163
        $pconfig['shared_key'] = openvpn_create_key();
164

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

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

    
175
	if (!$tls_mode && !$pconfig['autokey_enable']) {
176
		$reqdfields = array('shared_key');
177
		$reqdfieldsn = array('Shared key');
178
    } else {
179
		$reqdfields = explode(" ", "caref certref");
180
		$reqdfieldsn = explode(",", "Certificate Authority,Certificate");;
181
	}
182

    
183
    $reqdfields[] = 'tunnel_network';
184
    $reqdfieldsn[] = 'Tunnel network';
185

    
186
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
187
	
188
	if (!$input_errors) {
189

    
190
		$client = array();
191

    
192
		if ($vpnid)
193
			$client['vpnid'] = $vpnid;
194
		else
195
			$client['vpnid'] = openvpn_vpnid_next();
196

    
197
		$client['disable'] = $pconfig['disable'];
198
		$client['protocol'] = $pconfig['protocol'];
199
		$client['interface'] = $pconfig['interface'];
200
		$client['local_port'] = $pconfig['local_port'];
201
		$client['server_addr'] = $pconfig['server_addr'];
202
		$client['server_port'] = $pconfig['server_port'];
203
		$client['resolve_retry'] = $pconfig['resolve_retry'];
204
		$client['proxy_addr'] = $pconfig['proxy_addr'];
205
		$client['proxy_port'] = $pconfig['proxy_port'];
206
		$client['description'] = $pconfig['description'];
207
		$client['mode'] = $pconfig['mode'];
208

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

    
222
		$client['tunnel_network'] = $pconfig['tunnel_network'];
223
		$client['remote_network'] = $pconfig['remote_network'];
224
		$client['compression'] = $pconfig['compression'];
225

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

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

    
239
include("head.inc");
240

    
241
?>
242

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

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

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

    
274
function tlsauth_change() {
275

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

    
283
	autotls_change();
284
}
285

    
286
function autotls_change() {
287

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

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

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

    
326
			<?php if($act=="new" || $act=="edit"): ?>
327

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

    
681
			<?php else: ?>
682

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

    
742
			<? endif; ?>
743

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

    
757
<?php
758

    
759
/* local utility functions */
760

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

    
768
?>
769

    
(205-205/215)