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