Project

General

Profile

Download (25.8 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
require("guiconfig.inc");
38
require_once("openvpn.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
		$pconfig['custom_options'] = $a_client[$id]['custom_options'];
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
		$client['custom_options'] = $pconfig['custom_options'];
209

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

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

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

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

    
240
include("head.inc");
241

    
242
?>
243

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

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

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

    
275
function tlsauth_change() {
276

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

    
284
	autotls_change();
285
}
286

    
287
function autotls_change() {
288

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

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

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

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

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

    
705
			<?php else: ?>
706

    
707
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
708
				<tr>
709
					<td width="10%" class="listhdrr">Disabled</td>
710
					<td width="10%" class="listhdrr">Protocol</td>
711
					<td width="30%" class="listhdrr">Server</td>
712
					<td width="40%" class="listhdrr">Description</td>
713
					<td width="10%" class="list"></td>
714
				</tr>
715
				<?php
716
					$i = 0;
717
					foreach($a_client as $client):
718
						$disabled = "NO";
719
						if ($client['disable'])
720
							$disabled = "YES";
721
						$server = "{$client['server_addr']}:{$client['server_port']}";
722
				?>
723
				<tr>
724
					<td class="listlr">
725
						<?=$disabled;?>
726
					</td>
727
					<td class="listr">
728
						<?=htmlspecialchars($client['protocol']);?>
729
					</td>
730
					<td class="listr">
731
						<?=htmlspecialchars($server);?>
732
					</td>
733
					<td class="listbg">
734
						<?=htmlspecialchars($client['description']);?>
735
					</td>
736
					<td valign="middle" nowrap class="list">
737
						<a href="vpn_openvpn_client.php?act=edit&id=<?=$i;?>">
738
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit client" width="17" height="17" border="0">
739
						</a>
740
						&nbsp;
741
						<a href="vpn_openvpn_client.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this client?')">
742
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete client" width="17" height="17" border="0">
743
						</a>
744
					</td>
745
				</tr>
746
				<?php
747
					$i++;
748
					endforeach;
749
				?>
750
				<tr>
751
					<td class="list" colspan="4"></td>
752
					<td class="list">
753
						<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">
754
						</a>
755
					</td>
756
				</tr>
757
				<tr>
758
					<td colspan="4">
759
						<p>
760
							<?=gettext("Additional OpenVPN clients can be added here.");?>
761
						</p>
762
					</td>
763
				</tr>
764
			</table>
765

    
766
			<? endif; ?>
767

    
768
		</td>
769
	</tr>
770
</table>
771
<script language="JavaScript">
772
<!--
773
mode_change();
774
autokey_change();
775
tlsauth_change();
776
//-->
777
</script>
778
</body>
779
<?php include("fend.inc"); ?>
780

    
781
<?php
782

    
783
/* local utility functions */
784

    
785
function set_checked($var,& $chk) {
786
    if($var)
787
        $chk = 'checked';
788
    else
789
        $chk = '';
790
}
791

    
792
?>
793

    
(204-204/214)