1
|
<?php
|
2
|
/*
|
3
|
vpn_ipsec_phase1.php
|
4
|
part of m0n0wall (http://m0n0.ch/wall)
|
5
|
|
6
|
Copyright (C) 2008 Shrew Soft Inc
|
7
|
Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
|
32
|
##|+PRIV
|
33
|
##|*IDENT=page-vpn-ipsec-editphase1
|
34
|
##|*NAME=VPN: IPsec: Edit Phase 1 page
|
35
|
##|*DESCR=Allow access to the 'VPN: IPsec: Edit Phase 1' page.
|
36
|
##|*MATCH=vpn_ipsec_phase1.php*
|
37
|
##|-PRIV
|
38
|
|
39
|
require("functions.inc");
|
40
|
require("guiconfig.inc");
|
41
|
require_once("ipsec.inc");
|
42
|
require_once("vpn.inc");
|
43
|
|
44
|
if (!is_array($config['ipsec']['phase1']))
|
45
|
$config['ipsec']['phase1'] = array();
|
46
|
|
47
|
if (!is_array($config['ipsec']['phase2']))
|
48
|
$config['ipsec']['phase2'] = array();
|
49
|
|
50
|
$a_phase1 = &$config['ipsec']['phase1'];
|
51
|
$a_phase2 = &$config['ipsec']['phase2'];
|
52
|
|
53
|
$p1index = $_GET['p1index'];
|
54
|
if (isset($_POST['p1index']))
|
55
|
$p1index = $_POST['p1index'];
|
56
|
|
57
|
if (isset($_GET['dup'])) {
|
58
|
$p1index = $_GET['dup'];
|
59
|
}
|
60
|
|
61
|
if (isset($p1index) && $a_phase1[$p1index]) {
|
62
|
// don't copy the ikeid on dup
|
63
|
if (!isset($_GET['dup']))
|
64
|
$pconfig['ikeid'] = $a_phase1[$p1index]['ikeid'];
|
65
|
|
66
|
$old_ph1ent = $a_phase1[$p1index];
|
67
|
|
68
|
$pconfig['disabled'] = isset($a_phase1[$p1index]['disabled']);
|
69
|
|
70
|
if ($a_phase1[$p1index]['interface'])
|
71
|
$pconfig['interface'] = $a_phase1[$p1index]['interface'];
|
72
|
else
|
73
|
$pconfig['interface'] = "wan";
|
74
|
|
75
|
list($pconfig['remotenet'],$pconfig['remotebits']) = explode("/", $a_phase1[$p1index]['remote-subnet']);
|
76
|
|
77
|
if (isset($a_phase1[$p1index]['mobile']))
|
78
|
$pconfig['mobile'] = 'true';
|
79
|
else
|
80
|
$pconfig['remotegw'] = $a_phase1[$p1index]['remote-gateway'];
|
81
|
|
82
|
$pconfig['mode'] = $a_phase1[$p1index]['mode'];
|
83
|
$pconfig['myid_type'] = $a_phase1[$p1index]['myid_type'];
|
84
|
$pconfig['myid_data'] = $a_phase1[$p1index]['myid_data'];
|
85
|
$pconfig['peerid_type'] = $a_phase1[$p1index]['peerid_type'];
|
86
|
$pconfig['peerid_data'] = $a_phase1[$p1index]['peerid_data'];
|
87
|
$pconfig['ealgo'] = $a_phase1[$p1index]['encryption-algorithm'];
|
88
|
$pconfig['halgo'] = $a_phase1[$p1index]['hash-algorithm'];
|
89
|
$pconfig['dhgroup'] = $a_phase1[$p1index]['dhgroup'];
|
90
|
$pconfig['lifetime'] = $a_phase1[$p1index]['lifetime'];
|
91
|
$pconfig['authentication_method'] = $a_phase1[$p1index]['authentication_method'];
|
92
|
$pconfig['proposal_check'] = $a_phase1[$p1index]['proposal_check'];
|
93
|
|
94
|
if (($pconfig['authentication_method'] == "pre_shared_key") ||
|
95
|
($pconfig['authentication_method'] == "xauth_psk_server")) {
|
96
|
$pconfig['pskey'] = $a_phase1[$p1index]['pre-shared-key'];
|
97
|
} else {
|
98
|
$pconfig['certref'] = $a_phase1[$p1index]['certref'];
|
99
|
$pconfig['caref'] = $a_phase1[$p1index]['caref'];
|
100
|
}
|
101
|
|
102
|
$pconfig['descr'] = $a_phase1[$p1index]['descr'];
|
103
|
$pconfig['nat_traversal'] = $a_phase1[$p1index]['nat_traversal'];
|
104
|
|
105
|
if ($a_phase1[$p1index]['dpd_delay'] && $a_phase1[$p1index]['dpd_maxfail']) {
|
106
|
$pconfig['dpd_enable'] = true;
|
107
|
$pconfig['dpd_delay'] = $a_phase1[$p1index]['dpd_delay'];
|
108
|
$pconfig['dpd_maxfail'] = $a_phase1[$p1index]['dpd_maxfail'];
|
109
|
}
|
110
|
} else {
|
111
|
/* defaults */
|
112
|
$pconfig['interface'] = "wan";
|
113
|
if($config['interfaces']['lan'])
|
114
|
$pconfig['localnet'] = "lan";
|
115
|
$pconfig['mode'] = "aggressive";
|
116
|
$pconfig['myid_type'] = "myaddress";
|
117
|
$pconfig['peerid_type'] = "peeraddress";
|
118
|
$pconfig['authentication_method'] = "pre_shared_key";
|
119
|
$pconfig['ealgo'] = array( name => "3des" );
|
120
|
$pconfig['halgo'] = "sha1";
|
121
|
$pconfig['dhgroup'] = "2";
|
122
|
$pconfig['lifetime'] = "28800";
|
123
|
$pconfig['nat_traversal'] = "on";
|
124
|
$pconfig['dpd_enable'] = true;
|
125
|
|
126
|
/* mobile client */
|
127
|
if($_GET['mobile'])
|
128
|
$pconfig['mobile']=true;
|
129
|
}
|
130
|
|
131
|
if (isset($_GET['dup']))
|
132
|
unset($p1index);
|
133
|
|
134
|
if ($_POST) {
|
135
|
unset($input_errors);
|
136
|
$pconfig = $_POST;
|
137
|
|
138
|
/* input validation */
|
139
|
|
140
|
$method = $pconfig['authentication_method'];
|
141
|
// Only require PSK here for normal PSK tunnels (not mobile) or xauth.
|
142
|
if ((($method == "pre_shared_key") && (!$pconfig['mobile']))||($method == "xauth_psk_server")) {
|
143
|
$reqdfields = explode(" ", "pskey");
|
144
|
$reqdfieldsn = array(gettext("Pre-Shared Key"));
|
145
|
} else {
|
146
|
$reqdfields = explode(" ", "caref certref");
|
147
|
$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
|
148
|
}
|
149
|
if (!$pconfig['mobile']) {
|
150
|
$reqdfields[] = "remotegw";
|
151
|
$reqdfieldsn[] = gettext("Remote gateway");
|
152
|
}
|
153
|
|
154
|
do_input_validation($pconfig, $reqdfields, $reqdfieldsn, &$input_errors);
|
155
|
|
156
|
if (($pconfig['lifetime'] && !is_numeric($pconfig['lifetime'])))
|
157
|
$input_errors[] = gettext("The P1 lifetime must be an integer.");
|
158
|
|
159
|
if (($pconfig['remotegw'] && !is_ipaddr($pconfig['remotegw']) && !is_domain($pconfig['remotegw'])))
|
160
|
$input_errors[] = gettext("A valid remote gateway address or host name must be specified.");
|
161
|
|
162
|
if (($pconfig['remotegw'] && is_ipaddr($pconfig['remotegw']) && !isset($pconfig['disabled']) )) {
|
163
|
$t = 0;
|
164
|
foreach ($a_phase1 as $ph1tmp) {
|
165
|
if ($p1index <> $t) {
|
166
|
$tremotegw = $pconfig['remotegw'];
|
167
|
if (($ph1tmp['remote-gateway'] == $tremotegw) && !isset($ph1tmp['disabled'])) {
|
168
|
$input_errors[] = sprintf(gettext('The remote gateway "%1$s" is already used by phase1 "%2$s".'), $tremotegw, $ph1tmp['descr']);
|
169
|
}
|
170
|
}
|
171
|
$t++;
|
172
|
}
|
173
|
}
|
174
|
|
175
|
/* My identity */
|
176
|
|
177
|
if ($pconfig['myid_type'] == "myaddress")
|
178
|
$pconfig['myid_data'] = "";
|
179
|
|
180
|
if ($pconfig['myid_type'] == "address" and $pconfig['myid_data'] == "")
|
181
|
$input_errors[] = gettext("Please enter an address for 'My Identifier'");
|
182
|
|
183
|
if ($pconfig['myid_type'] == "keyid tag" and $pconfig['myid_data'] == "")
|
184
|
$input_errors[] = gettext("Please enter a keyid tag for 'My Identifier'");
|
185
|
|
186
|
if ($pconfig['myid_type'] == "fqdn" and $pconfig['myid_data'] == "")
|
187
|
$input_errors[] = gettext("Please enter a fully qualified domain name for 'My Identifier'");
|
188
|
|
189
|
if ($pconfig['myid_type'] == "user_fqdn" and $pconfig['myid_data'] == "")
|
190
|
$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'My Identifier'");
|
191
|
|
192
|
if ($pconfig['myid_type'] == "dyn_dns" and $pconfig['myid_data'] == "")
|
193
|
$input_errors[] = gettext("Please enter a dynamic domain name for 'My Identifier'");
|
194
|
|
195
|
if ((($pconfig['myid_type'] == "address") && !is_ipaddr($pconfig['myid_data'])))
|
196
|
$input_errors[] = gettext("A valid IP address for 'My identifier' must be specified.");
|
197
|
|
198
|
if ((($pconfig['myid_type'] == "fqdn") && !is_domain($pconfig['myid_data'])))
|
199
|
$input_errors[] = gettext("A valid domain name for 'My identifier' must be specified.");
|
200
|
|
201
|
if ($pconfig['myid_type'] == "fqdn")
|
202
|
if (is_domain($pconfig['myid_data']) == false)
|
203
|
$input_errors[] = gettext("A valid FQDN for 'My identifier' must be specified.");
|
204
|
|
205
|
if ($pconfig['myid_type'] == "user_fqdn") {
|
206
|
$user_fqdn = explode("@",$pconfig['myid_data']);
|
207
|
if (is_domain($user_fqdn[1]) == false)
|
208
|
$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'My identifier' must be specified.");
|
209
|
}
|
210
|
|
211
|
if ($pconfig['myid_type'] == "dyn_dns")
|
212
|
if (is_domain($pconfig['myid_data']) == false)
|
213
|
$input_errors[] = gettext("A valid Dynamic DNS address for 'My identifier' must be specified.");
|
214
|
|
215
|
/* Peer identity */
|
216
|
|
217
|
if ($pconfig['myid_type'] == "peeraddress")
|
218
|
$pconfig['peerid_data'] = "";
|
219
|
|
220
|
// Only enforce peer ID if we are not dealing with a pure-psk mobile config.
|
221
|
if (!(($pconfig['authentication_method'] == "pre_shared_key") && ($pconfig['mobile']))) {
|
222
|
if ($pconfig['peerid_type'] == "address" and $pconfig['peerid_data'] == "")
|
223
|
$input_errors[] = gettext("Please enter an address for 'Peer Identifier'");
|
224
|
|
225
|
if ($pconfig['peerid_type'] == "keyid tag" and $pconfig['peerid_data'] == "")
|
226
|
$input_errors[] = gettext("Please enter a keyid tag for 'Peer Identifier'");
|
227
|
|
228
|
if ($pconfig['peerid_type'] == "fqdn" and $pconfig['peerid_data'] == "")
|
229
|
$input_errors[] = gettext("Please enter a fully qualified domain name for 'Peer Identifier'");
|
230
|
|
231
|
if ($pconfig['peerid_type'] == "user_fqdn" and $pconfig['peerid_data'] == "")
|
232
|
$input_errors[] = gettext("Please enter a user and fully qualified domain name for 'Peer Identifier'");
|
233
|
|
234
|
if ((($pconfig['peerid_type'] == "address") && !is_ipaddr($pconfig['peerid_data'])))
|
235
|
$input_errors[] = gettext("A valid IP address for 'Peer identifier' must be specified.");
|
236
|
|
237
|
if ((($pconfig['peerid_type'] == "fqdn") && !is_domain($pconfig['peerid_data'])))
|
238
|
$input_errors[] = gettext("A valid domain name for 'Peer identifier' must be specified.");
|
239
|
|
240
|
if ($pconfig['peerid_type'] == "fqdn")
|
241
|
if (is_domain($pconfig['peerid_data']) == false)
|
242
|
$input_errors[] = gettext("A valid FQDN for 'Peer identifier' must be specified.");
|
243
|
|
244
|
if ($pconfig['peerid_type'] == "user_fqdn") {
|
245
|
$user_fqdn = explode("@",$pconfig['peerid_data']);
|
246
|
if (is_domain($user_fqdn[1]) == false)
|
247
|
$input_errors[] = gettext("A valid User FQDN in the form of user@my.domain.com for 'Peer identifier' must be specified.");
|
248
|
}
|
249
|
}
|
250
|
|
251
|
if ($pconfig['dpd_enable']) {
|
252
|
if (!is_numeric($pconfig['dpd_delay']))
|
253
|
$input_errors[] = gettext("A numeric value must be specified for DPD delay.");
|
254
|
|
255
|
if (!is_numeric($pconfig['dpd_maxfail']))
|
256
|
$input_errors[] = gettext("A numeric value must be specified for DPD retries.");
|
257
|
}
|
258
|
|
259
|
/* build our encryption algorithms array */
|
260
|
$pconfig['ealgo'] = array();
|
261
|
$pconfig['ealgo']['name'] = $_POST['ealgo'];
|
262
|
if($pconfig['ealgo_keylen'])
|
263
|
$pconfig['ealgo']['keylen'] = $_POST['ealgo_keylen'];
|
264
|
|
265
|
if (!$input_errors) {
|
266
|
$ph1ent['ikeid'] = $pconfig['ikeid'];
|
267
|
$ph1ent['disabled'] = $pconfig['disabled'] ? true : false;
|
268
|
$ph1ent['interface'] = $pconfig['interface'];
|
269
|
/* if the remote gateway changed and the interface is not WAN then remove route */
|
270
|
/* the vpn_ipsec_configure() handles adding the route */
|
271
|
if ($pconfig['interface'] <> "wan") {
|
272
|
if($old_ph1ent['remote-gateway'] <> $pconfig['remotegw']) {
|
273
|
mwexec("/sbin/route delete -host {$oldph1ent['remote-gateway']}");
|
274
|
}
|
275
|
}
|
276
|
|
277
|
if ($pconfig['mobile'])
|
278
|
$ph1ent['mobile'] = true;
|
279
|
else
|
280
|
$ph1ent['remote-gateway'] = $pconfig['remotegw'];
|
281
|
|
282
|
$ph1ent['mode'] = $pconfig['mode'];
|
283
|
|
284
|
$ph1ent['myid_type'] = $pconfig['myid_type'];
|
285
|
$ph1ent['myid_data'] = $pconfig['myid_data'];
|
286
|
$ph1ent['peerid_type'] = $pconfig['peerid_type'];
|
287
|
$ph1ent['peerid_data'] = $pconfig['peerid_data'];
|
288
|
|
289
|
$ph1ent['encryption-algorithm'] = $pconfig['ealgo'];
|
290
|
$ph1ent['hash-algorithm'] = $pconfig['halgo'];
|
291
|
$ph1ent['dhgroup'] = $pconfig['dhgroup'];
|
292
|
$ph1ent['lifetime'] = $pconfig['lifetime'];
|
293
|
$ph1ent['pre-shared-key'] = $pconfig['pskey'];
|
294
|
$ph1ent['private-key'] = base64_encode($pconfig['privatekey']);
|
295
|
$ph1ent['certref'] = $pconfig['certref'];
|
296
|
$ph1ent['caref'] = $pconfig['caref'];
|
297
|
$ph1ent['authentication_method'] = $pconfig['authentication_method'];
|
298
|
$ph1ent['proposal_check'] = $pconfig['proposal_check'];
|
299
|
$ph1ent['descr'] = $pconfig['descr'];
|
300
|
$ph1ent['nat_traversal'] = $pconfig['nat_traversal'];
|
301
|
|
302
|
if (isset($pconfig['dpd_enable'])) {
|
303
|
$ph1ent['dpd_delay'] = $pconfig['dpd_delay'];
|
304
|
$ph1ent['dpd_maxfail'] = $pconfig['dpd_maxfail'];
|
305
|
}
|
306
|
|
307
|
/* generate unique phase1 ikeid */
|
308
|
if ($ph1ent['ikeid'] == 0)
|
309
|
$ph1ent['ikeid'] = ipsec_ikeid_next();
|
310
|
|
311
|
if (isset($p1index) && $a_phase1[$p1index])
|
312
|
$a_phase1[$p1index] = $ph1ent;
|
313
|
else
|
314
|
$a_phase1[] = $ph1ent;
|
315
|
|
316
|
/* now we need to find all phase2 entries for this host */
|
317
|
if (is_array($a_phase2) && (count($a_phase2))) {
|
318
|
foreach ($a_phase2 as $phase2) {
|
319
|
if($phase2['ikeid'] == $ph1ent['ikeid']) {
|
320
|
log_error("Reload {$ph1ent['descr']} tunnel(s)");
|
321
|
$old_ph1ent['remote-gateway'] = resolve_retry($old_ph1ent['remote-gateway']);
|
322
|
$old_phase2 = $phase2;
|
323
|
reload_tunnel_spd_policy ($ph1ent, $phase2, $old_ph1ent, $old_phase2);
|
324
|
}
|
325
|
}
|
326
|
}
|
327
|
write_config();
|
328
|
mark_subsystem_dirty('ipsec');
|
329
|
|
330
|
header("Location: vpn_ipsec.php");
|
331
|
exit;
|
332
|
}
|
333
|
}
|
334
|
|
335
|
if ($pconfig['mobile'])
|
336
|
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"), gettext("Mobile Client"));
|
337
|
else
|
338
|
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Edit Phase 1"));
|
339
|
$statusurl = "diag_ipsec.php";
|
340
|
$logurl = "diag_logs_ipsec.php";
|
341
|
|
342
|
|
343
|
include("head.inc");
|
344
|
|
345
|
?>
|
346
|
|
347
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
348
|
<?php include("fbegin.inc"); ?>
|
349
|
<script language="JavaScript">
|
350
|
<!--
|
351
|
|
352
|
function myidsel_change() {
|
353
|
index = document.iform.myid_type.selectedIndex;
|
354
|
value = document.iform.myid_type.options[index].value;
|
355
|
if (value == 'myaddress')
|
356
|
document.getElementById('myid_data').style.visibility = 'hidden';
|
357
|
else
|
358
|
document.getElementById('myid_data').style.visibility = 'visible';
|
359
|
}
|
360
|
|
361
|
function peeridsel_change() {
|
362
|
index = document.iform.peerid_type.selectedIndex;
|
363
|
value = document.iform.peerid_type.options[index].value;
|
364
|
if (value == 'peeraddress')
|
365
|
document.getElementById('peerid_data').style.visibility = 'hidden';
|
366
|
else
|
367
|
document.getElementById('peerid_data').style.visibility = 'visible';
|
368
|
}
|
369
|
|
370
|
function methodsel_change() {
|
371
|
index = document.iform.authentication_method.selectedIndex;
|
372
|
value = document.iform.authentication_method.options[index].value;
|
373
|
|
374
|
switch (value) {
|
375
|
case 'hybrid_rsa_server':
|
376
|
document.getElementById('opt_psk').style.display = 'none';
|
377
|
document.getElementById('opt_peerid').style.display = '';
|
378
|
document.getElementById('opt_cert').style.display = '';
|
379
|
document.getElementById('opt_ca').style.display = '';
|
380
|
break;
|
381
|
case 'xauth_rsa_server':
|
382
|
case 'rsasig':
|
383
|
document.getElementById('opt_psk').style.display = 'none';
|
384
|
document.getElementById('opt_peerid').style.display = '';
|
385
|
document.getElementById('opt_cert').style.display = '';
|
386
|
document.getElementById('opt_ca').style.display = '';
|
387
|
break;
|
388
|
<?php if ($pconfig['mobile']) { ?>
|
389
|
case 'pre_shared_key':
|
390
|
document.getElementById('opt_psk').style.display = 'none';
|
391
|
document.getElementById('opt_peerid').style.display = 'none';
|
392
|
document.getElementById('opt_cert').style.display = 'none';
|
393
|
document.getElementById('opt_ca').style.display = 'none';
|
394
|
break;
|
395
|
<?php } ?>
|
396
|
default: /* psk modes*/
|
397
|
document.getElementById('opt_psk').style.display = '';
|
398
|
document.getElementById('opt_peerid').style.display = '';
|
399
|
document.getElementById('opt_cert').style.display = 'none';
|
400
|
document.getElementById('opt_ca').style.display = 'none';
|
401
|
break;
|
402
|
}
|
403
|
}
|
404
|
|
405
|
/* PHP generated java script for variable length keys */
|
406
|
function ealgosel_change(bits) {
|
407
|
switch (document.iform.ealgo.selectedIndex) {
|
408
|
<?php
|
409
|
$i = 0;
|
410
|
foreach ($p1_ealgos as $algo => $algodata) {
|
411
|
if (is_array($algodata['keysel'])) {
|
412
|
echo " case {$i}:\n";
|
413
|
echo " document.iform.ealgo_keylen.style.visibility = 'visible';\n";
|
414
|
echo " document.iform.ealgo_keylen.options.length = 0;\n";
|
415
|
// echo " document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( 'auto', 'auto' );\n";
|
416
|
|
417
|
$key_hi = $algodata['keysel']['hi'];
|
418
|
$key_lo = $algodata['keysel']['lo'];
|
419
|
$key_step = $algodata['keysel']['step'];
|
420
|
|
421
|
for ($keylen = $key_hi; $keylen >= $key_lo; $keylen -= $key_step)
|
422
|
echo " document.iform.ealgo_keylen.options[document.iform.ealgo_keylen.options.length] = new Option( '{$keylen} bits', '{$keylen}' );\n";
|
423
|
echo " break;\n";
|
424
|
} else {
|
425
|
echo " case {$i}:\n";
|
426
|
echo " document.iform.ealgo_keylen.style.visibility = 'hidden';\n";
|
427
|
echo " document.iform.ealgo_keylen.options.length = 0;\n";
|
428
|
echo " break;\n";
|
429
|
}
|
430
|
$i++;
|
431
|
}
|
432
|
?>
|
433
|
}
|
434
|
|
435
|
if( bits )
|
436
|
document.iform.ealgo_keylen.value = bits;
|
437
|
}
|
438
|
|
439
|
function dpdchkbox_change() {
|
440
|
if( document.iform.dpd_enable.checked )
|
441
|
document.getElementById('opt_dpd').style.display = '';
|
442
|
else
|
443
|
document.getElementById('opt_dpd').style.display = 'none';
|
444
|
|
445
|
if (!document.iform.dpd_delay.value)
|
446
|
document.iform.dpd_delay.value = "10";
|
447
|
|
448
|
if (!document.iform.dpd_maxfail.value)
|
449
|
document.iform.dpd_maxfail.value = "5";
|
450
|
}
|
451
|
|
452
|
//-->
|
453
|
</script>
|
454
|
|
455
|
<form action="vpn_ipsec_phase1.php" method="post" name="iform" id="iform">
|
456
|
|
457
|
<?php
|
458
|
if ($input_errors)
|
459
|
print_input_errors($input_errors);
|
460
|
?>
|
461
|
|
462
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
463
|
<tr class="tabnavtbl">
|
464
|
<td id="tabnav">
|
465
|
<?php
|
466
|
$tab_array = array();
|
467
|
$tab_array[0] = array(gettext("Tunnels"), true, "vpn_ipsec.php");
|
468
|
$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
|
469
|
$tab_array[2] = array(gettext("Pre-shared keys"), false, "vpn_ipsec_keys.php");
|
470
|
display_top_tabs($tab_array);
|
471
|
?>
|
472
|
</td>
|
473
|
</tr>
|
474
|
<tr>
|
475
|
<td id="mainarea">
|
476
|
<div class="tabcont">
|
477
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
478
|
<tr>
|
479
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
|
480
|
</tr>
|
481
|
<tr>
|
482
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
|
483
|
<td width="78%" class="vtable">
|
484
|
<input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
|
485
|
<strong><?=gettext("Disable this phase1 entry"); ?></strong><br>
|
486
|
<span class="vexpl">
|
487
|
<?=gettext("Set this option to disable this phase1 without " .
|
488
|
"removing it from the list"); ?>.
|
489
|
</span>
|
490
|
</td>
|
491
|
</tr>
|
492
|
<tr>
|
493
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
|
494
|
<td width="78%" class="vtable">
|
495
|
<select name="interface" class="formselect">
|
496
|
<?php
|
497
|
$interfaces = get_configured_interface_with_descr();
|
498
|
$carplist = get_configured_carp_interface_list();
|
499
|
foreach ($carplist as $cif => $carpip)
|
500
|
$interfaces[$cif] = strtoupper($cif) . " ({$carpip})";
|
501
|
foreach ($interfaces as $iface => $ifacename):
|
502
|
?>
|
503
|
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
|
504
|
<?=htmlspecialchars($ifacename);?>
|
505
|
</option>
|
506
|
<?php endforeach; ?>
|
507
|
</select>
|
508
|
<br>
|
509
|
<span class="vexpl"><?=gettext("Select the interface for the local endpoint of this phase1 entry"); ?>.</span>
|
510
|
</td>
|
511
|
</tr>
|
512
|
|
513
|
<?php if (!$pconfig['mobile']): ?>
|
514
|
|
515
|
<tr>
|
516
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Remote gateway"); ?></td>
|
517
|
<td width="78%" class="vtable">
|
518
|
<?=$mandfldhtml;?><input name="remotegw" type="text" class="formfld unknown" id="remotegw" size="20" value="<?=$pconfig['remotegw'];?>">
|
519
|
<br>
|
520
|
<?=gettext("Enter the public IP address or host name of the remote gateway"); ?>
|
521
|
</td>
|
522
|
</tr>
|
523
|
|
524
|
<?php endif; ?>
|
525
|
|
526
|
<tr>
|
527
|
<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
|
528
|
<td width="78%" class="vtable">
|
529
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
|
530
|
<br>
|
531
|
<span class="vexpl">
|
532
|
<?=gettext("You may enter a description here " .
|
533
|
"for your reference (not parsed)"); ?>.
|
534
|
</span>
|
535
|
</td>
|
536
|
</tr>
|
537
|
<tr>
|
538
|
<td colspan="2" class="list" height="12"></td>
|
539
|
</tr>
|
540
|
<tr>
|
541
|
<td colspan="2" valign="top" class="listtopic">
|
542
|
<?=gettext("Phase 1 proposal (Authentication)"); ?>
|
543
|
</td>
|
544
|
</tr>
|
545
|
<tr>
|
546
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication method"); ?></td>
|
547
|
<td width="78%" class="vtable">
|
548
|
<select name="authentication_method" class="formselect" onChange="methodsel_change()">
|
549
|
<?php
|
550
|
foreach ($p1_authentication_methods as $method_type => $method_params):
|
551
|
if (!$pconfig['mobile'] && $method_params['mobile'])
|
552
|
continue;
|
553
|
?>
|
554
|
<option value="<?=$method_type;?>" <?php if ($method_type == $pconfig['authentication_method']) echo "selected"; ?>>
|
555
|
<?=htmlspecialchars($method_params['name']);?>
|
556
|
</option>
|
557
|
<?php endforeach; ?>
|
558
|
</select>
|
559
|
<br>
|
560
|
<span class="vexpl">
|
561
|
<?=gettext("Must match the setting chosen on the remote side"); ?>.
|
562
|
</span>
|
563
|
</td>
|
564
|
</tr>
|
565
|
<tr>
|
566
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Negotiation mode"); ?></td>
|
567
|
<td width="78%" class="vtable">
|
568
|
<select name="mode" class="formselect">
|
569
|
<?php
|
570
|
$modes = array(gettext("main"),gettext("aggressive"));
|
571
|
foreach ($modes as $mode):
|
572
|
?>
|
573
|
<option value="<?=$mode;?>" <?php if ($mode == $pconfig['mode']) echo "selected"; ?>>
|
574
|
<?=htmlspecialchars($mode);?>
|
575
|
</option>
|
576
|
<?php endforeach; ?>
|
577
|
</select> <br> <span class="vexpl"><?=gettext("Aggressive is more flexible, but less secure"); ?>.</span>
|
578
|
</td>
|
579
|
</tr>
|
580
|
<tr>
|
581
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("My identifier"); ?></td>
|
582
|
<td width="78%" class="vtable">
|
583
|
<select name="myid_type" class="formselect" onChange="myidsel_change()">
|
584
|
<?php foreach ($my_identifier_list as $id_type => $id_params): ?>
|
585
|
<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['myid_type']) echo "selected"; ?>>
|
586
|
<?=htmlspecialchars($id_params['desc']);?>
|
587
|
</option>
|
588
|
<?php endforeach; ?>
|
589
|
</select>
|
590
|
<input name="myid_data" type="text" class="formfld unknown" id="myid_data" size="30" value="<?=$pconfig['myid_data'];?>">
|
591
|
</td>
|
592
|
</tr>
|
593
|
<tr id="opt_peerid">
|
594
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer identifier"); ?></td>
|
595
|
<td width="78%" class="vtable">
|
596
|
<select name="peerid_type" class="formselect" onChange="peeridsel_change()">
|
597
|
<?php
|
598
|
foreach ($peer_identifier_list as $id_type => $id_params):
|
599
|
if ($pconfig['mobile'] && !$id_params['mobile'])
|
600
|
continue;
|
601
|
?>
|
602
|
<option value="<?=$id_type;?>" <?php if ($id_type == $pconfig['peerid_type']) echo "selected"; ?>>
|
603
|
<?=htmlspecialchars($id_params['desc']);?>
|
604
|
</option>
|
605
|
<?php endforeach; ?>
|
606
|
</select>
|
607
|
<input name="peerid_data" type="text" class="formfld unknown" id="peerid_data" size="30" value="<?=$pconfig['peerid_data'];?>">
|
608
|
<?php if ($pconfig['mobile']) { ?>
|
609
|
<br/><br/><?=gettext("NOTE: This is known as the \"group\" setting on some VPN client implementations"); ?>.
|
610
|
<?php } ?>
|
611
|
</td>
|
612
|
</tr>
|
613
|
<tr id="opt_psk">
|
614
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Pre-Shared Key"); ?></td>
|
615
|
<td width="78%" class="vtable">
|
616
|
<?=$mandfldhtml;?>
|
617
|
<input name="pskey" type="text" class="formfld unknown" id="pskey" size="40" value="<?=htmlspecialchars($pconfig['pskey']);?>">
|
618
|
<span class="vexpl">
|
619
|
<br>
|
620
|
<?=gettext("Input your pre-shared key string"); ?>.
|
621
|
</span>
|
622
|
</td>
|
623
|
</tr>
|
624
|
<tr id="proposal_check">
|
625
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Proposal Checking"); ?></td>
|
626
|
<td width="78%" class="vtable">
|
627
|
<select name="proposal_check" class="formselect">
|
628
|
<option value="" <?php if (empty($pconfig['proposal_check'])) echo "selected"; ?>>Default</option>
|
629
|
<option value="obey" <?php if ($pconfig['proposal_check'] == "obey") echo "selected"; ?>>Obey</option>
|
630
|
<option value="strict" <?php if ($pconfig['proposal_check'] == "strict") echo "selected"; ?>>Strict</option>
|
631
|
<option value="claim" <?php if ($pconfig['proposal_check'] == "claim") echo "selected"; ?>>Claim</option>
|
632
|
<option value="exact" <?php if ($pconfig['proposal_check'] == "exact") echo "selected"; ?>>Exact</option>
|
633
|
</select>
|
634
|
<br>
|
635
|
<span class="vexpl">
|
636
|
<?=gettext("Specifies the action of lifetime length, key length, and PFS of the phase 2 selection on the responder side, and the action of lifetime check in phase 1."); ?>
|
637
|
</span>
|
638
|
</td>
|
639
|
</tr>
|
640
|
<tr>
|
641
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
|
642
|
<td width="78%" class="vtable">
|
643
|
<select name="ealgo" class="formselect" onChange="ealgosel_change()">
|
644
|
<?php
|
645
|
foreach ($p1_ealgos as $algo => $algodata):
|
646
|
$selected = '';
|
647
|
if ($algo == $pconfig['ealgo']['name'])
|
648
|
$selected = ' selected';
|
649
|
?>
|
650
|
<option value="<?=$algo;?>"<?=$selected?>>
|
651
|
<?=htmlspecialchars($algodata['name']);?>
|
652
|
</option>
|
653
|
<?php endforeach; ?>
|
654
|
</select>
|
655
|
<select name="ealgo_keylen" width="30" class="formselect">
|
656
|
</select>
|
657
|
</td>
|
658
|
</tr>
|
659
|
<tr>
|
660
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Hash algorithm"); ?></td>
|
661
|
<td width="78%" class="vtable">
|
662
|
<select name="halgo" class="formselect">
|
663
|
<?php foreach ($p1_halgos as $algo => $algoname): ?>
|
664
|
<option value="<?=$algo;?>" <?php if ($algo == $pconfig['halgo']) echo "selected"; ?>>
|
665
|
<?=htmlspecialchars($algoname);?>
|
666
|
</option>
|
667
|
<?php endforeach; ?>
|
668
|
</select>
|
669
|
<br>
|
670
|
<span class="vexpl">
|
671
|
<?=gettext("Must match the setting chosen on the remote side"); ?>.
|
672
|
</span>
|
673
|
</td>
|
674
|
</tr>
|
675
|
<tr>
|
676
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("DH key group"); ?></td>
|
677
|
<td width="78%" class="vtable">
|
678
|
<select name="dhgroup" class="formselect">
|
679
|
<?php $keygroups = explode(" ", "1 2 5"); foreach ($keygroups as $keygroup): ?>
|
680
|
<option value="<?=$keygroup;?>" <?php if ($keygroup == $pconfig['dhgroup']) echo "selected"; ?>>
|
681
|
<?=htmlspecialchars($keygroup);?>
|
682
|
</option>
|
683
|
<?php endforeach; ?>
|
684
|
</select>
|
685
|
<br>
|
686
|
<span class="vexpl">
|
687
|
<em><?=gettext("1 = 768 bit, 2 = 1024 bit, 5 = 1536 bit"); ?></em>
|
688
|
<br>
|
689
|
<?=gettext("Must match the setting chosen on the remote side"); ?>.
|
690
|
</span>
|
691
|
</td>
|
692
|
</tr>
|
693
|
<tr>
|
694
|
<td width="22%" valign="top" class="vncell"><?=gettext("Lifetime"); ?></td>
|
695
|
<td width="78%" class="vtable">
|
696
|
<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="20" value="<?=$pconfig['lifetime'];?>">
|
697
|
<?=gettext("seconds"); ?>
|
698
|
</td>
|
699
|
</tr>
|
700
|
<tr id="opt_cert">
|
701
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate"); ?></td>
|
702
|
<td width="78%" class="vtable">
|
703
|
<select name='certref' class="formselect">
|
704
|
<?php
|
705
|
foreach ($config['system']['cert'] as $cert):
|
706
|
$selected = "";
|
707
|
if ($pconfig['certref'] == $cert['refid'])
|
708
|
$selected = "selected";
|
709
|
?>
|
710
|
<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
|
711
|
<?php endforeach; ?>
|
712
|
</select>
|
713
|
<br>
|
714
|
<span class="vexpl">
|
715
|
<?=gettext("Select a certificate previously configured in the Certificate Manager"); ?>.
|
716
|
</span>
|
717
|
</td>
|
718
|
</tr>
|
719
|
<tr id="opt_ca">
|
720
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("My Certificate Authority"); ?></td>
|
721
|
<td width="78%" class="vtable">
|
722
|
<select name='caref' class="formselect">
|
723
|
<?php
|
724
|
foreach ($config['system']['ca'] as $ca):
|
725
|
$selected = "";
|
726
|
if ($pconfig['caref'] == $ca['refid'])
|
727
|
$selected = "selected";
|
728
|
?>
|
729
|
<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['name'];?></option>
|
730
|
<?php endforeach; ?>
|
731
|
</select>
|
732
|
<br>
|
733
|
<span class="vexpl">
|
734
|
<?=gettext("Select a certificate authority previously configured in the Certificate Manager"); ?>.
|
735
|
</span>
|
736
|
</td>
|
737
|
</tr>
|
738
|
<tr>
|
739
|
<td colspan="2" class="list" height="12"></td>
|
740
|
</tr>
|
741
|
<tr>
|
742
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced Options"); ?></td>
|
743
|
</tr>
|
744
|
<tr>
|
745
|
<td width="22%" valign="top" class="vncell"><?=gettext("NAT Traversal"); ?></td>
|
746
|
<td width="78%" class="vtable">
|
747
|
<select name="nat_traversal" class="formselect">
|
748
|
<option value="off" <?php if ($pconfig['nat_traversal'] == "off") echo "selected"; ?>><?=gettext("Disable"); ?></option>
|
749
|
<option value="on" <?php if ($pconfig['nat_traversal'] == "on") echo "selected"; ?>><?=gettext("Enable"); ?></option>
|
750
|
<option value="force" <?php if ($pconfig['nat_traversal'] == "force") echo "selected"; ?>><?=gettext("Force"); ?></option>
|
751
|
</select>
|
752
|
<br/>
|
753
|
<span class="vexpl">
|
754
|
<?=gettext("Set this option to enable the use of NAT-T (i.e. the encapsulation of ESP in UDP packets) if needed, " .
|
755
|
"which can help with clients that are behind restrictive firewalls"); ?>.
|
756
|
</span>
|
757
|
</td>
|
758
|
</tr>
|
759
|
<tr>
|
760
|
<td width="22%" valign="top" class="vncell"><?=gettext("Dead Peer Detection"); ?></td>
|
761
|
<td width="78%" class="vtable">
|
762
|
<input name="dpd_enable" type="checkbox" id="dpd_enable" value="yes" <?php if (isset($pconfig['dpd_enable'])) echo "checked"; ?> onClick="dpdchkbox_change()">
|
763
|
<?=gettext("Enable DPD"); ?><br>
|
764
|
<div id="opt_dpd">
|
765
|
<br>
|
766
|
<input name="dpd_delay" type="text" class="formfld unknown" id="dpd_delay" size="5" value="<?=$pconfig['dpd_delay'];?>">
|
767
|
<?=gettext("seconds"); ?><br>
|
768
|
<span class="vexpl">
|
769
|
<?=gettext("Delay between requesting peer acknowledgement"); ?>.
|
770
|
</span><br>
|
771
|
<br>
|
772
|
<input name="dpd_maxfail" type="text" class="formfld unknown" id="dpd_maxfail" size="5" value="<?=$pconfig['dpd_maxfail'];?>">
|
773
|
<?=gettext("retries"); ?><br>
|
774
|
<span class="vexpl">
|
775
|
<?=gettext("Number of consecutive failures allowed before disconnect"); ?>.
|
776
|
</span>
|
777
|
<br>
|
778
|
</div>
|
779
|
</td>
|
780
|
</tr>
|
781
|
<tr>
|
782
|
<td width="22%" valign="top"> </td>
|
783
|
<td width="78%">
|
784
|
<?php if (isset($p1index) && $a_phase1[$p1index]): ?>
|
785
|
<input name="p1index" type="hidden" value="<?=$p1index;?>">
|
786
|
<?php endif; ?>
|
787
|
<?php if ($pconfig['mobile']): ?>
|
788
|
<input name="mobile" type="hidden" value="true">
|
789
|
<?php endif; ?>
|
790
|
<input name="ikeid" type="hidden" value="<?=$pconfig['ikeid'];?>">
|
791
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>">
|
792
|
</td>
|
793
|
</tr>
|
794
|
</table>
|
795
|
</div>
|
796
|
</td>
|
797
|
</tr>
|
798
|
</table>
|
799
|
</form>
|
800
|
|
801
|
<script lannguage="JavaScript">
|
802
|
<!--
|
803
|
<?php
|
804
|
/* determine if we should init the key length */
|
805
|
$keyset = '';
|
806
|
if (isset($pconfig['ealgo']['keylen']))
|
807
|
if (is_numeric($pconfig['ealgo']['keylen']))
|
808
|
$keyset = $pconfig['ealgo']['keylen'];
|
809
|
?>
|
810
|
myidsel_change();
|
811
|
peeridsel_change();
|
812
|
methodsel_change();
|
813
|
ealgosel_change(<?=$keyset;?>);
|
814
|
dpdchkbox_change();
|
815
|
//-->
|
816
|
</script>
|
817
|
<?php include("fend.inc"); ?>
|
818
|
</body>
|
819
|
</html>
|