1 |
958420c5
|
jim-p
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
vpn_ipsec_keys.php
|
4 |
|
|
part of m0n0wall (http://m0n0.ch/wall)
|
5 |
29aef6c4
|
Jim Thompson
|
part of pfSense
|
6 |
765b79f9
|
Sander van Leeuwen
|
|
7 |
958420c5
|
jim-p
|
Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
|
8 |
ed2d1343
|
Renato Botelho
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
9 |
958420c5
|
jim-p
|
All rights reserved.
|
10 |
765b79f9
|
Sander van Leeuwen
|
|
11 |
958420c5
|
jim-p
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
765b79f9
|
Sander van Leeuwen
|
|
14 |
958420c5
|
jim-p
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
765b79f9
|
Sander van Leeuwen
|
|
17 |
958420c5
|
jim-p
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
765b79f9
|
Sander van Leeuwen
|
|
21 |
958420c5
|
jim-p
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
##|+PRIV
|
34 |
|
|
##|*IDENT=page-vpn-ipsec-listkeys
|
35 |
|
|
##|*NAME=VPN: IPsec: Pre-Shared Keys List
|
36 |
|
|
##|*DESCR=Allow access to the 'VPN: IPsec: Pre-Shared Keys List' page.
|
37 |
|
|
##|*MATCH=vpn_ipsec_keys.php*
|
38 |
|
|
##|-PRIV
|
39 |
|
|
|
40 |
|
|
require("functions.inc");
|
41 |
|
|
require("guiconfig.inc");
|
42 |
|
|
require_once("ipsec.inc");
|
43 |
|
|
require_once("vpn.inc");
|
44 |
ad970c21
|
Renato Botelho
|
require_once("filter.inc");
|
45 |
958420c5
|
jim-p
|
|
46 |
|
|
if (!is_array($config['ipsec']['mobilekey'])) {
|
47 |
|
|
$config['ipsec']['mobilekey'] = array();
|
48 |
|
|
}
|
49 |
|
|
ipsec_mobilekey_sort();
|
50 |
|
|
$a_secret = &$config['ipsec']['mobilekey'];
|
51 |
|
|
|
52 |
66a72c9f
|
jim-p
|
$userkeys = array();
|
53 |
|
|
foreach ($config['system']['user'] as $id => $user) {
|
54 |
b039f099
|
jim-p
|
if (!empty($user['ipsecpsk'])) {
|
55 |
10e2acb5
|
Ermal LUÇI
|
$userkeys[] = array('ident' => $user['name'], 'type' => 'PSK', 'pre-shared-key' => $user['ipsecpsk'], 'id' => $id);;
|
56 |
66a72c9f
|
jim-p
|
}
|
57 |
|
|
}
|
58 |
|
|
|
59 |
b446562b
|
Renato Botelho
|
if (isset($_POST['apply'])) {
|
60 |
|
|
$retval = vpn_ipsec_configure();
|
61 |
|
|
/* reload the filter in the background */
|
62 |
|
|
filter_configure();
|
63 |
|
|
$savemsg = get_std_save_message($retval);
|
64 |
|
|
if (is_subsystem_dirty('ipsec'))
|
65 |
|
|
clear_subsystem_dirty('ipsec');
|
66 |
130a84c5
|
Ermal
|
}
|
67 |
66a72c9f
|
jim-p
|
|
68 |
958420c5
|
jim-p
|
if ($_GET['act'] == "del") {
|
69 |
|
|
if ($a_secret[$_GET['id']]) {
|
70 |
|
|
unset($a_secret[$_GET['id']]);
|
71 |
171b0468
|
Rafael Lucas
|
write_config(gettext("Deleted IPsec Pre-Shared Key"));
|
72 |
958420c5
|
jim-p
|
mark_subsystem_dirty('ipsec');
|
73 |
|
|
header("Location: vpn_ipsec_keys.php");
|
74 |
|
|
exit;
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
|
78 |
76b89c84
|
Carlos Eduardo Ramos
|
$pgtitle = gettext("VPN: IPsec: Keys");
|
79 |
b32dd0a6
|
jim-p
|
$shortcut_section = "ipsec";
|
80 |
6deedfde
|
jim-p
|
|
81 |
958420c5
|
jim-p
|
include("head.inc");
|
82 |
|
|
|
83 |
|
|
?>
|
84 |
|
|
|
85 |
765b79f9
|
Sander van Leeuwen
|
<?php
|
86 |
958420c5
|
jim-p
|
if ($savemsg)
|
87 |
|
|
print_info_box($savemsg);
|
88 |
|
|
if (is_subsystem_dirty('ipsec'))
|
89 |
8cd558b6
|
ayvis
|
print_info_box_np(gettext("The IPsec tunnel configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));
|
90 |
958420c5
|
jim-p
|
|
91 |
|
|
?>
|
92 |
5f85a1f2
|
Sander van Leeuwen
|
|
93 |
958420c5
|
jim-p
|
<?php
|
94 |
|
|
$tab_array = array();
|
95 |
76b89c84
|
Carlos Eduardo Ramos
|
$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
|
96 |
|
|
$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
|
97 |
2a2b247b
|
jim-p
|
$tab_array[2] = array(gettext("Pre-Shared Keys"), true, "vpn_ipsec_keys.php");
|
98 |
71172088
|
jim-p
|
$tab_array[3] = array(gettext("Advanced Settings"), false, "vpn_ipsec_settings.php");
|
99 |
5f85a1f2
|
Sander van Leeuwen
|
display_top_tabs($tab_array, false, 'pills');
|
100 |
958420c5
|
jim-p
|
?>
|
101 |
5f85a1f2
|
Sander van Leeuwen
|
|
102 |
|
|
<div class="table-responsive">
|
103 |
|
|
<table class="table table-striped table-hover">
|
104 |
|
|
<thead>
|
105 |
|
|
<tr>
|
106 |
|
|
<th><?=gettext("Identifier"); ?></th>
|
107 |
|
|
<th><?=gettext("Type"); ?></th>
|
108 |
|
|
<th><?=gettext("Pre-Shared Key"); ?></th>
|
109 |
|
|
<th></th>
|
110 |
|
|
</tr>
|
111 |
|
|
</thead>
|
112 |
|
|
|
113 |
|
|
<tbody>
|
114 |
|
|
<?php $i = 0; foreach ($userkeys as $secretent): ?>
|
115 |
|
|
<tr>
|
116 |
|
|
<td>
|
117 |
|
|
<?php
|
118 |
|
|
if ($secretent['ident'] == 'allusers')
|
119 |
|
|
echo gettext("ANY USER");
|
120 |
|
|
else
|
121 |
|
|
echo htmlspecialchars($secretent['ident']);
|
122 |
|
|
?>
|
123 |
|
|
</td>
|
124 |
|
|
<td>
|
125 |
|
|
<?php
|
126 |
|
|
if (empty($secretent['type']))
|
127 |
|
|
echo 'PSK';
|
128 |
|
|
else
|
129 |
|
|
echo htmlspecialchars($secretent['type']);
|
130 |
|
|
?>
|
131 |
|
|
</td>
|
132 |
|
|
<td>
|
133 |
|
|
<?=htmlspecialchars($secretent['pre-shared-key'])?>
|
134 |
|
|
</td>
|
135 |
|
|
<td>
|
136 |
765b79f9
|
Sander van Leeuwen
|
<a class="btn btn-primary btn-xs" href="system_usermanager.php?act=edit&userid=<?=$secretent['id']?>">edit user</a>
|
137 |
5f85a1f2
|
Sander van Leeuwen
|
</td>
|
138 |
|
|
</tr>
|
139 |
|
|
<?php $i++; endforeach; ?>
|
140 |
|
|
|
141 |
|
|
<?php $i = 0; foreach ($a_secret as $secretent): ?>
|
142 |
|
|
<tr>
|
143 |
|
|
<td>
|
144 |
|
|
<?=htmlspecialchars($secretent['ident'])?>
|
145 |
|
|
</td>
|
146 |
|
|
<td>
|
147 |
|
|
<?php
|
148 |
|
|
if (empty($secretent['type']))
|
149 |
|
|
echo 'PSK';
|
150 |
|
|
else
|
151 |
|
|
echo htmlspecialchars($secretent['type']);
|
152 |
|
|
?>
|
153 |
|
|
</td>
|
154 |
|
|
<td>
|
155 |
|
|
<?=htmlspecialchars($secretent['pre-shared-key'])?>
|
156 |
|
|
</td>
|
157 |
|
|
<td>
|
158 |
|
|
<a class="btn btn-primary btn-xs" href="vpn_ipsec_keys_edit.php?id=<?=$i?>">edit key</a>
|
159 |
|
|
<a class="btn btn-danger btn-xs" href="vpn_ipsec_keys.php?act=del&id=<?=$i?>" onclick="return confirm('<?=gettext("Do you really want to delete this Pre-Shared Key?"); ?>')">delete key</a>
|
160 |
|
|
</td>
|
161 |
|
|
</tr>
|
162 |
|
|
<?php $i++; endforeach; ?>
|
163 |
|
|
</tbody>
|
164 |
|
|
</table>
|
165 |
|
|
</div>
|
166 |
|
|
|
167 |
765b79f9
|
Sander van Leeuwen
|
<nav class="action-buttons">
|
168 |
|
|
<a class="btn btn-success" href="vpn_ipsec_keys_edit.php"><?=gettext("add key")?></a>
|
169 |
|
|
</nav>
|
170 |
5f85a1f2
|
Sander van Leeuwen
|
|
171 |
|
|
<div class="alert alert-info">
|
172 |
|
|
<strong><?=gettext("Note"); ?>:</strong><br />
|
173 |
|
|
<?=gettext("PSK for any user can be set by using an identifier of any/ANY")?>
|
174 |
|
|
</div>
|
175 |
|
|
|
176 |
|
|
<?php include("foot.inc"); ?>
|