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
|
|
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 ($pconfig['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 ($pconfig['autokey_enable'])
|
162
|
$pconfig['shared_key'] = openvpn_create_key();
|
163
|
|
164
|
if (!$tls_mode && !$pconfig['autokey_enable'])
|
165
|
if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
|
166
|
!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
|
167
|
$input_errors[] = "The field 'Shared Key' does not appear to be valid";
|
168
|
|
169
|
if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
|
170
|
if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
|
171
|
!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
|
172
|
$input_errors[] = "The field 'TLS Authentication Key' does not appear to be valid";
|
173
|
|
174
|
if (!$tls_mode && !$pconfig['autokey_enable']) {
|
175
|
$reqdfields = array('shared_key');
|
176
|
$reqdfieldsn = array('Shared key');
|
177
|
} else {
|
178
|
$reqdfields = explode(" ", "caref certref");
|
179
|
$reqdfieldsn = explode(",", "Certificate Authority,Certificate");;
|
180
|
}
|
181
|
|
182
|
$reqdfields[] = 'tunnel_network';
|
183
|
$reqdfieldsn[] = 'Tunnel network';
|
184
|
|
185
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
186
|
|
187
|
if (!$input_errors) {
|
188
|
|
189
|
$client = array();
|
190
|
|
191
|
if ($vpnid)
|
192
|
$client['vpnid'] = $vpnid;
|
193
|
else
|
194
|
$client['vpnid'] = openvpn_vpnid_next();
|
195
|
|
196
|
$client['disable'] = $pconfig['disable'];
|
197
|
$client['protocol'] = $pconfig['protocol'];
|
198
|
$client['interface'] = $pconfig['interface'];
|
199
|
$client['local_port'] = $pconfig['local_port'];
|
200
|
$client['server_addr'] = $pconfig['server_addr'];
|
201
|
$client['server_port'] = $pconfig['server_port'];
|
202
|
$client['resolve_retry'] = $pconfig['resolve_retry'];
|
203
|
$client['proxy_addr'] = $pconfig['proxy_addr'];
|
204
|
$client['proxy_port'] = $pconfig['proxy_port'];
|
205
|
$client['description'] = $pconfig['description'];
|
206
|
$client['mode'] = $pconfig['mode'];
|
207
|
|
208
|
if ($tls_mode) {
|
209
|
$client['caref'] = $pconfig['caref'];
|
210
|
$client['certref'] = $pconfig['certref'];
|
211
|
if ($pconfig['tlsauth_enable']) {
|
212
|
if ($pconfig['autotls_enable'])
|
213
|
$pconfig['tls'] = openvpn_create_key();
|
214
|
$client['tls'] = base64_encode($pconfig['tls']);
|
215
|
}
|
216
|
} else {
|
217
|
$client['shared_key'] = base64_encode($pconfig['shared_key']);
|
218
|
}
|
219
|
$client['crypto'] = $pconfig['crypto'];
|
220
|
|
221
|
$client['tunnel_network'] = $pconfig['tunnel_network'];
|
222
|
$client['remote_network'] = $pconfig['remote_network'];
|
223
|
$client['compression'] = $pconfig['compression'];
|
224
|
|
225
|
if (isset($id) && $a_client[$id])
|
226
|
$a_client[$id] = $client;
|
227
|
else
|
228
|
$a_client[] = $client;
|
229
|
|
230
|
openvpn_resync('client', $client);
|
231
|
write_config();
|
232
|
|
233
|
header("Location: vpn_openvpn_client.php");
|
234
|
exit;
|
235
|
}
|
236
|
}
|
237
|
|
238
|
include("head.inc");
|
239
|
|
240
|
?>
|
241
|
|
242
|
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
|
243
|
<?php include("fbegin.inc"); ?>
|
244
|
<script language="JavaScript">
|
245
|
<!--
|
246
|
|
247
|
function mode_change() {
|
248
|
index = document.iform.mode.selectedIndex;
|
249
|
value = document.iform.mode.options[index].value;
|
250
|
switch(value) {
|
251
|
case "p2p_tls":
|
252
|
document.getElementById("tls").style.display="";
|
253
|
document.getElementById("tls_ca").style.display="";
|
254
|
document.getElementById("tls_cert").style.display="";
|
255
|
document.getElementById("psk").style.display="none";
|
256
|
break;
|
257
|
case "p2p_shared_key":
|
258
|
document.getElementById("tls").style.display="none";
|
259
|
document.getElementById("tls_ca").style.display="none";
|
260
|
document.getElementById("tls_cert").style.display="none";
|
261
|
document.getElementById("psk").style.display="";
|
262
|
break;
|
263
|
}
|
264
|
}
|
265
|
|
266
|
function autokey_change() {
|
267
|
if (document.iform.autokey_enable.checked)
|
268
|
document.getElementById("autokey_opts").style.display="none";
|
269
|
else
|
270
|
document.getElementById("autokey_opts").style.display="";
|
271
|
}
|
272
|
|
273
|
function tlsauth_change() {
|
274
|
|
275
|
<?php if (!$pconfig['tls']): ?>
|
276
|
if (document.iform.tlsauth_enable.checked)
|
277
|
document.getElementById("tlsauth_opts").style.display="";
|
278
|
else
|
279
|
document.getElementById("tlsauth_opts").style.display="none";
|
280
|
<?php endif; ?>
|
281
|
|
282
|
autotls_change();
|
283
|
}
|
284
|
|
285
|
function autotls_change() {
|
286
|
|
287
|
<?php if (!$pconfig['tls']): ?>
|
288
|
autocheck = document.iform.autotls_enable.checked;
|
289
|
<?php else: ?>
|
290
|
autocheck = false;
|
291
|
<?php endif; ?>
|
292
|
|
293
|
if (document.iform.tlsauth_enable.checked && !autocheck)
|
294
|
document.getElementById("autotls_opts").style.display="";
|
295
|
else
|
296
|
document.getElementById("autotls_opts").style.display="none";
|
297
|
}
|
298
|
|
299
|
//-->
|
300
|
</script>
|
301
|
<?php
|
302
|
if ($input_errors)
|
303
|
print_input_errors($input_errors);
|
304
|
if ($savemsg)
|
305
|
print_info_box($savemsg);
|
306
|
?>
|
307
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
308
|
<tr>
|
309
|
<td class="tabnavtbl">
|
310
|
<ul id="tabnav">
|
311
|
<?php
|
312
|
$tab_array = array();
|
313
|
$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
|
314
|
$tab_array[] = array(gettext("Client"), true, "vpn_openvpn_client.php");
|
315
|
$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
|
316
|
add_package_tabs("OpenVPN", $tab_array);
|
317
|
display_top_tabs($tab_array);
|
318
|
?>
|
319
|
</ul>
|
320
|
</td>
|
321
|
</tr>
|
322
|
<tr>
|
323
|
<td class="tabcont">
|
324
|
|
325
|
<?php if($act=="new" || $act=="edit"): ?>
|
326
|
|
327
|
<form action="vpn_openvpn_client.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
|
328
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
329
|
<tr>
|
330
|
<td colspan="2" valign="top" class="listtopic">General information</td>
|
331
|
</tr>
|
332
|
<tr>
|
333
|
<td width="22%" valign="top" class="vncellreq">Disabled</td>
|
334
|
<td width="78%" class="vtable">
|
335
|
<table border="0" cellpadding="0" cellspacing="0">
|
336
|
<tr>
|
337
|
<td>
|
338
|
<?php set_checked($pconfig['disable'],$chk); ?>
|
339
|
<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
|
340
|
</td>
|
341
|
<td>
|
342
|
|
343
|
<span class="vexpl">
|
344
|
<strong>Disable this client</strong><br>
|
345
|
</span>
|
346
|
</td>
|
347
|
</tr>
|
348
|
</table>
|
349
|
Set this option to disable this client without removing it from the list.
|
350
|
</td>
|
351
|
</tr>
|
352
|
<tr>
|
353
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
|
354
|
<td width="78%" class="vtable">
|
355
|
<select name='mode' id='mode' class="formselect" onchange='mode_change()'>
|
356
|
<?php
|
357
|
foreach ($openvpn_client_modes as $name => $desc):
|
358
|
$selected = "";
|
359
|
if ($pconfig['mode'] == $name)
|
360
|
$selected = "selected";
|
361
|
?>
|
362
|
<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
|
363
|
<?php endforeach; ?>
|
364
|
</select>
|
365
|
</td>
|
366
|
</tr>
|
367
|
<tr>
|
368
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
|
369
|
<td width="78%" class="vtable">
|
370
|
<select name='protocol' class="formselect">
|
371
|
<?php
|
372
|
foreach ($openvpn_prots as $prot):
|
373
|
$selected = "";
|
374
|
if ($pconfig['protocol'] == $prot)
|
375
|
$selected = "selected";
|
376
|
?>
|
377
|
<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
|
378
|
<?php endforeach; ?>
|
379
|
</select>
|
380
|
</td>
|
381
|
</tr>
|
382
|
<tr>
|
383
|
<td width="22%" valign="top" class="vncellreq">Interface</td>
|
384
|
<td width="78%" class="vtable">
|
385
|
<select name="interface" class="formselect">
|
386
|
<?php
|
387
|
$interfaces = get_configured_interface_with_descr();
|
388
|
foreach ($interfaces as $iface => $ifacename):
|
389
|
$selected = "";
|
390
|
if ($iface == $pconfig['interface'])
|
391
|
$selected = "selected";
|
392
|
?>
|
393
|
<option value="<?=$iface;?>" <?=$selected;?>>
|
394
|
<?=htmlspecialchars($ifacename);?>
|
395
|
</option>
|
396
|
<?php endforeach; ?>
|
397
|
</select> <br>
|
398
|
</td>
|
399
|
</tr>
|
400
|
<tr>
|
401
|
<td width="22%" valign="top" class="vncell"><?=gettext("Local port");?></td>
|
402
|
<td width="78%" class="vtable">
|
403
|
<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
|
404
|
<br/>
|
405
|
Set this option if you would like to bind to a specific port.
|
406
|
</td>
|
407
|
</tr>
|
408
|
<tr>
|
409
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Server host or address");?></td>
|
410
|
<td width="78%" class="vtable">
|
411
|
<input name="server_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['server_addr']);?>"/>
|
412
|
</td>
|
413
|
</tr>
|
414
|
<tr>
|
415
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Server port");?></td>
|
416
|
<td width="78%" class="vtable">
|
417
|
<input name="server_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['server_port']);?>"/>
|
418
|
</td>
|
419
|
</tr>
|
420
|
<tr>
|
421
|
<td width="22%" valign="top" class="vncell"><?=gettext("Proxy host or address");?></td>
|
422
|
<td width="78%" class="vtable">
|
423
|
<input name="proxy_addr" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['proxy_addr']);?>"/>
|
424
|
</td>
|
425
|
</tr>
|
426
|
<tr>
|
427
|
<td width="22%" valign="top" class="vncell"><?=gettext("Proxy port");?></td>
|
428
|
<td width="78%" class="vtable">
|
429
|
<input name="proxy_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['proxy_port']);?>"/>
|
430
|
</td>
|
431
|
</tr>
|
432
|
<tr>
|
433
|
<td width="22%" valign="top" class="vncell">Server host name resolution</td>
|
434
|
<td width="78%" class="vtable">
|
435
|
<table border="0" cellpadding="2" cellspacing="0">
|
436
|
<tr>
|
437
|
<td>
|
438
|
<?php set_checked($pconfig['resolve_retry'],$chk); ?>
|
439
|
<input name="resolve_retry" type="checkbox" value="yes" <?=$chk;?>>
|
440
|
</td>
|
441
|
<td>
|
442
|
<span class="vexpl">
|
443
|
Infinitely resolve server
|
444
|
</span>
|
445
|
</td>
|
446
|
</tr>
|
447
|
</table>
|
448
|
Continuously attempt to resolve the server host
|
449
|
name. Useful when communicating with a server
|
450
|
that is not permanently connected to the internet.
|
451
|
</td>
|
452
|
</tr>
|
453
|
<tr>
|
454
|
<td width="22%" valign="top" class="vncell">Description</td>
|
455
|
<td width="78%" class="vtable">
|
456
|
<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
|
457
|
<br>
|
458
|
You may enter a description here for your reference (not parsed).
|
459
|
</td>
|
460
|
</tr>
|
461
|
<tr>
|
462
|
<td colspan="2" class="list" height="12"></td>
|
463
|
</tr>
|
464
|
<tr>
|
465
|
<td colspan="2" valign="top" class="listtopic">Cryptographic Settings</td>
|
466
|
</tr>
|
467
|
<tr id="tls">
|
468
|
<td width="22%" valign="top" class="vncellreq">TLS Authentication</td>
|
469
|
<td width="78%" class="vtable">
|
470
|
<table border="0" cellpadding="2" cellspacing="0">
|
471
|
<tr>
|
472
|
<td>
|
473
|
<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
|
474
|
<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onClick="tlsauth_change()">
|
475
|
</td>
|
476
|
<td>
|
477
|
<span class="vexpl">
|
478
|
Enable authentication of TLS packets.
|
479
|
</span>
|
480
|
</td>
|
481
|
</tr>
|
482
|
</table>
|
483
|
<?php if (!$pconfig['tls']): ?>
|
484
|
<table border="0" cellpadding="2" cellspacing="0" id='tlsauth_opts'>
|
485
|
<tr>
|
486
|
<td>
|
487
|
<?php set_checked($pconfig['autotls_enable'],$chk); ?>
|
488
|
<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autotls_change()">
|
489
|
</td>
|
490
|
<td>
|
491
|
<span class="vexpl">
|
492
|
Automatically generate a shared TLS authentication key.
|
493
|
</span>
|
494
|
</td>
|
495
|
</tr>
|
496
|
</table>
|
497
|
<?php endif; ?>
|
498
|
<table border="0" cellpadding="2" cellspacing="0" id='autotls_opts'>
|
499
|
<tr>
|
500
|
<td>
|
501
|
<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
|
502
|
<br/>
|
503
|
Paste your shared key here.
|
504
|
</td>
|
505
|
</tr>
|
506
|
</table>
|
507
|
</td>
|
508
|
</tr>
|
509
|
<tr id="tls_ca">
|
510
|
<td width="22%" valign="top" class="vncellreq">Peer Certificate Authority</td>
|
511
|
<td width="78%" class="vtable">
|
512
|
<select name='caref' class="formselect">
|
513
|
<?php
|
514
|
foreach ($config['system']['ca'] as $ca):
|
515
|
$selected = "";
|
516
|
if ($pconfig['caref'] == $ca['refid'])
|
517
|
$selected = "selected";
|
518
|
?>
|
519
|
<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['name'];?></option>
|
520
|
<?php endforeach; ?>
|
521
|
</select>
|
522
|
</td>
|
523
|
</tr>
|
524
|
<tr id="tls_cert">
|
525
|
<td width="22%" valign="top" class="vncellreq">Client Certificate</td>
|
526
|
<td width="78%" class="vtable">
|
527
|
<select name='certref' class="formselect">
|
528
|
<?php
|
529
|
foreach ($config['system']['cert'] as $cert):
|
530
|
$selected = "";
|
531
|
if ($pconfig['certref'] == $cert['refid'])
|
532
|
$selected = "selected";
|
533
|
?>
|
534
|
<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
|
535
|
<?php endforeach; ?>
|
536
|
</select>
|
537
|
</td>
|
538
|
</tr>
|
539
|
<tr id="psk">
|
540
|
<td width="22%" valign="top" class="vncellreq">Shared Key</td>
|
541
|
<td width="78%" class="vtable">
|
542
|
<?php if (!$pconfig['shared_key']): ?>
|
543
|
<table border="0" cellpadding="2" cellspacing="0">
|
544
|
<tr>
|
545
|
<td>
|
546
|
<?php set_checked($pconfig['autokey_enable'],$chk); ?>
|
547
|
<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onClick="autokey_change()">
|
548
|
</td>
|
549
|
<td>
|
550
|
<span class="vexpl">
|
551
|
Automatically generate a shared key.
|
552
|
</span>
|
553
|
</td>
|
554
|
</tr>
|
555
|
</table>
|
556
|
<?php endif; ?>
|
557
|
<table border="0" cellpadding="2" cellspacing="0" id='autokey_opts'>
|
558
|
<tr>
|
559
|
<td>
|
560
|
<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
|
561
|
<br/>
|
562
|
Paste your shared key here.
|
563
|
</td>
|
564
|
</tr>
|
565
|
</table>
|
566
|
</td>
|
567
|
</tr>
|
568
|
<tr>
|
569
|
<td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
|
570
|
<td width="78%" class="vtable">
|
571
|
<select name="crypto" class="formselect">
|
572
|
<?php
|
573
|
$cipherlist = openvpn_get_cipherlist();
|
574
|
foreach ($cipherlist as $name => $desc):
|
575
|
$selected = '';
|
576
|
if ($name == $pconfig['crypto'])
|
577
|
$selected = ' selected';
|
578
|
?>
|
579
|
<option value="<?=$name;?>"<?=$selected?>>
|
580
|
<?=htmlspecialchars($desc);?>
|
581
|
</option>
|
582
|
<?php endforeach; ?>
|
583
|
</select>
|
584
|
</td>
|
585
|
</tr>
|
586
|
<tr>
|
587
|
<td colspan="2" class="list" height="12"></td>
|
588
|
</tr>
|
589
|
<tr>
|
590
|
<td colspan="2" valign="top" class="listtopic">Tunnel Settings</td>
|
591
|
</tr>
|
592
|
<tr>
|
593
|
<td width="22%" valign="top" class="vncellreq">Tunnel Network</td>
|
594
|
<td width="78%" class="vtable">
|
595
|
<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
|
596
|
<br>
|
597
|
This is the virtual network used for private
|
598
|
communications between this client and the
|
599
|
server expressed using CIDR (eg. 10.0.8.0/24).
|
600
|
The first network address is assumed to be the
|
601
|
server address and the second network address
|
602
|
will be assigned to the client virtual
|
603
|
interface.
|
604
|
</td>
|
605
|
</tr>
|
606
|
<tr>
|
607
|
<td width="22%" valign="top" class="vncell">Remote Network</td>
|
608
|
<td width="78%" class="vtable">
|
609
|
<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
|
610
|
<br>
|
611
|
This is a network that will be routed through
|
612
|
the tunnel, so that a site-to-site VPN can be
|
613
|
established without manually changing the
|
614
|
routing tables. Expressed as a CIDR range. If
|
615
|
this is a site-to-site VPN, enter here the
|
616
|
remote LAN here. You may leave this blank to
|
617
|
only communicate with other clients.
|
618
|
</td>
|
619
|
</tr>
|
620
|
<tr>
|
621
|
<td width="22%" valign="top" class="vncell"><?=gettext("Limit outgoing bandwidth");?></td>
|
622
|
<td width="78%" class="vtable">
|
623
|
<input name="use_shaper" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['use_shaper']);?>"/>
|
624
|
<br/>
|
625
|
Maximum outgoing bandwidth for this tunnel.
|
626
|
Leave empty for no limit. The input value has
|
627
|
to be something between 100 bytes/sec and 100
|
628
|
Mbytes/sec (entered as bytes per second).
|
629
|
</td>
|
630
|
</tr>
|
631
|
<tr>
|
632
|
<td width="22%" valign="top" class="vncell">Compression</td>
|
633
|
<td width="78%" class="vtable">
|
634
|
<table border="0" cellpadding="2" cellspacing="0">
|
635
|
<tr>
|
636
|
<td>
|
637
|
<?php set_checked($pconfig['compression'],$chk); ?>
|
638
|
<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
|
639
|
</td>
|
640
|
<td>
|
641
|
<span class="vexpl">
|
642
|
Compress tunnel packets using the LZO algorithm.
|
643
|
</span>
|
644
|
</td>
|
645
|
</tr>
|
646
|
</table>
|
647
|
</td>
|
648
|
</tr>
|
649
|
<tr>
|
650
|
<td width="22%" valign="top" class="vncell">Type-of-Service</td>
|
651
|
<td width="78%" class="vtable">
|
652
|
<table border="0" cellpadding="2" cellspacing="0">
|
653
|
<tr>
|
654
|
<td>
|
655
|
<?php set_checked($pconfig['passtos'],$chk); ?>
|
656
|
<input name="passtos" type="checkbox" value="yes" <?=$chk;?>>
|
657
|
</td>
|
658
|
<td>
|
659
|
<span class="vexpl">
|
660
|
Set the TOS IP header value of tunnel packets to match the encapsulated packet value.
|
661
|
</span>
|
662
|
</td>
|
663
|
</tr>
|
664
|
</table>
|
665
|
</td>
|
666
|
</tr>
|
667
|
<tr>
|
668
|
<td width="22%" valign="top"> </td>
|
669
|
<td width="78%">
|
670
|
<input name="save" type="submit" class="formbtn" value="Save">
|
671
|
<input name="act" type="hidden" value="<?=$act;?>">
|
672
|
<?php if (isset($id) && $a_client[$id]): ?>
|
673
|
<input name="id" type="hidden" value="<?=$id;?>">
|
674
|
<?php endif; ?>
|
675
|
</td>
|
676
|
</tr>
|
677
|
</table>
|
678
|
</form>
|
679
|
|
680
|
<?php else: ?>
|
681
|
|
682
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
683
|
<tr>
|
684
|
<td width="10%" class="listhdrr">Disabled</td>
|
685
|
<td width="10%" class="listhdrr">Protocol</td>
|
686
|
<td width="30%" class="listhdrr">Server</td>
|
687
|
<td width="40%" class="listhdrr">Description</td>
|
688
|
<td width="10%" class="list"></td>
|
689
|
</tr>
|
690
|
<?php
|
691
|
$i = 0;
|
692
|
foreach($a_client as $client):
|
693
|
$disabled = "NO";
|
694
|
if ($client['disable'])
|
695
|
$disabled = "YES";
|
696
|
$server = "{$client['server_addr']}:{$client['server_port']}";
|
697
|
?>
|
698
|
<tr>
|
699
|
<td class="listlr">
|
700
|
<?=$disabled;?>
|
701
|
</td>
|
702
|
<td class="listr">
|
703
|
<?=htmlspecialchars($client['protocol']);?>
|
704
|
</td>
|
705
|
<td class="listr">
|
706
|
<?=htmlspecialchars($server);?>
|
707
|
</td>
|
708
|
<td class="listbg">
|
709
|
<?=htmlspecialchars($client['description']);?>
|
710
|
</td>
|
711
|
<td valign="middle" nowrap class="list">
|
712
|
<a href="vpn_openvpn_client.php?act=edit&id=<?=$i;?>">
|
713
|
<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit client" width="17" height="17" border="0">
|
714
|
</a>
|
715
|
|
716
|
<a href="vpn_openvpn_client.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this client?')">
|
717
|
<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete client" width="17" height="17" border="0">
|
718
|
</a>
|
719
|
</td>
|
720
|
</tr>
|
721
|
<?php
|
722
|
$i++;
|
723
|
endforeach;
|
724
|
?>
|
725
|
<tr>
|
726
|
<td class="list" colspan="4"></td>
|
727
|
<td class="list">
|
728
|
<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">
|
729
|
</a>
|
730
|
</td>
|
731
|
</tr>
|
732
|
<tr>
|
733
|
<td colspan="4">
|
734
|
<p>
|
735
|
<?=gettext("Additional OpenVPN clients can be added here.");?>
|
736
|
</p>
|
737
|
</td>
|
738
|
</tr>
|
739
|
</table>
|
740
|
|
741
|
<? endif; ?>
|
742
|
|
743
|
</td>
|
744
|
</tr>
|
745
|
</table>
|
746
|
<script language="JavaScript">
|
747
|
<!--
|
748
|
mode_change();
|
749
|
autokey_change();
|
750
|
tlsauth_change();
|
751
|
//-->
|
752
|
</script>
|
753
|
</body>
|
754
|
<?php include("fend.inc"); ?>
|
755
|
|
756
|
<?php
|
757
|
|
758
|
/* local utility functions */
|
759
|
|
760
|
function set_checked($var,& $chk) {
|
761
|
if($var)
|
762
|
$chk = 'checked';
|
763
|
else
|
764
|
$chk = '';
|
765
|
}
|
766
|
|
767
|
?>
|
768
|
|