1
|
<?php
|
2
|
/*
|
3
|
$Id$
|
4
|
Copyright (C) 2013-2014 Electric Sheep Fencing, LP
|
5
|
|
6
|
Copyright 2007 Scott Dale
|
7
|
Part of pfSense widgets (https://www.pfsense.org)
|
8
|
originally based on m0n0wall (http://m0n0.ch/wall)
|
9
|
|
10
|
Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
|
11
|
and Jonathan Watt <jwatt@jwatt.org>.
|
12
|
All rights reserved.
|
13
|
|
14
|
Redistribution and use in source and binary forms, with or without
|
15
|
modification, are permitted provided that the following conditions are met:
|
16
|
|
17
|
1. Redistributions of source code must retain the above copyright notice,
|
18
|
this list of conditions and the following disclaimer.
|
19
|
|
20
|
2. Redistributions in binary form must reproduce the above copyright
|
21
|
notice, this list of conditions and the following disclaimer in the
|
22
|
documentation and/or other materials provided with the distribution.
|
23
|
|
24
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
25
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
26
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
27
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
28
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
29
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
30
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
31
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
32
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33
|
POSSIBILITY OF SUCH DAMAGE.
|
34
|
*/
|
35
|
|
36
|
$nocsrf = true;
|
37
|
|
38
|
require_once("guiconfig.inc");
|
39
|
require_once("functions.inc");
|
40
|
require_once("ipsec.inc");
|
41
|
|
42
|
if (isset($config['ipsec']['phase1'])){?>
|
43
|
<div> </div>
|
44
|
<?php
|
45
|
$tab_array = array();
|
46
|
$tab_array[0] = array("Overview", true, "ipsec-Overview");
|
47
|
$tab_array[1] = array("Tunnels", false, "ipsec-tunnel");
|
48
|
$tab_array[2] = array("Mobile", false, "ipsec-mobile");
|
49
|
display_widget_tabs($tab_array);
|
50
|
|
51
|
$spd = ipsec_dump_spd();
|
52
|
$sad = ipsec_dump_sad();
|
53
|
$mobile = ipsec_dump_mobile();
|
54
|
$ipsec_status = ipsec_smp_dump_status();
|
55
|
|
56
|
$activecounter = 0;
|
57
|
$inactivecounter = 0;
|
58
|
|
59
|
$ipsec_detail_array = array();
|
60
|
foreach ($config['ipsec']['phase2'] as $ph2ent){
|
61
|
if ($ph2ent['remoteid']['type'] == "mobile")
|
62
|
continue;
|
63
|
ipsec_lookup_phase1($ph2ent,$ph1ent);
|
64
|
$ipsecstatus = false;
|
65
|
|
66
|
$tun_disabled = "false";
|
67
|
$foundsrc = false;
|
68
|
$founddst = false;
|
69
|
|
70
|
if (isset($ph1ent['disabled']) || isset($ph2ent['disabled'])) {
|
71
|
$tun_disabled = "true";
|
72
|
continue;
|
73
|
}
|
74
|
|
75
|
if (is_array($ipsec_status['query']) &&
|
76
|
is_array($ipsec_status['query']['ikesalist']) &&
|
77
|
is_array($ipsec_status['query']['ikesalist']['ikesa']) &&
|
78
|
ipsec_phase1_status($ipsec_status['query']['ikesalist']['ikesa'], $ph1ent['ikeid'])) {
|
79
|
/* tunnel is up */
|
80
|
$iconfn = "true";
|
81
|
$activecounter++;
|
82
|
} else {
|
83
|
/* tunnel is down */
|
84
|
$iconfn = "false";
|
85
|
$inactivecounter++;
|
86
|
}
|
87
|
|
88
|
$ipsec_detail_array[] = array('src' => convert_friendly_interface_to_friendly_descr($ph1ent['interface']),
|
89
|
'dest' => $ph1ent['remote-gateway'],
|
90
|
'remote-subnet' => ipsec_idinfo_to_text($ph2ent['remoteid']),
|
91
|
'descr' => $ph2ent['descr'],
|
92
|
'status' => $iconfn,
|
93
|
'disabled' => $tun_disabled);
|
94
|
}
|
95
|
}
|
96
|
|
97
|
if (isset($config['ipsec']['phase2'])){ ?>
|
98
|
|
99
|
<div id="ipsec-Overview" style="display:block;background-color:#EEEEEE;">
|
100
|
<div>
|
101
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="heading">
|
102
|
<tr>
|
103
|
<td class="listhdrr nowrap">Active Tunnels</td>
|
104
|
<td class="listhdrr nowrap">Inactive Tunnels</td>
|
105
|
<td class="listhdrr nowrap">Mobile Users</td>
|
106
|
</tr>
|
107
|
<tr>
|
108
|
<td class="listlr"><?php echo $activecounter; ?></td>
|
109
|
<td class="listr"><?php echo $inactivecounter; ?></td>
|
110
|
<td class="listr"><?php if (is_array($mobile['pool'])) echo htmlspecialchars($mobile['pool'][0]['usage']); else echo 0; ?></td>
|
111
|
</tr>
|
112
|
</table>
|
113
|
</div>
|
114
|
</div>
|
115
|
|
116
|
<div id="ipsec-tunnel" style="display:none;background-color:#EEEEEE;">
|
117
|
<div style="padding: 10px">
|
118
|
<div style="display:table-row;">
|
119
|
<div class="widgetsubheader" style="display:table-cell;width:40px">Source</div>
|
120
|
<div class="widgetsubheader" style="display:table-cell;width:100px">Destination</div>
|
121
|
<div class="widgetsubheader" style="display:table-cell;width:90px">Description</div>
|
122
|
<div class="widgetsubheader" style="display:table-cell;width:30px">Status</div>
|
123
|
</div>
|
124
|
<div style="max-height:105px;overflow:auto;">
|
125
|
<?php
|
126
|
foreach ($ipsec_detail_array as $ipsec) :
|
127
|
|
128
|
if ($ipsec['disabled'] == "true"){
|
129
|
$spans = "<span class=\"gray\">";
|
130
|
$spane = "</span>";
|
131
|
}
|
132
|
else {
|
133
|
$spans = $spane = "";
|
134
|
}
|
135
|
|
136
|
?>
|
137
|
|
138
|
<div style="display:table-row;">
|
139
|
<div class="listlr" style="display:table-cell;width:39px">
|
140
|
<?php echo $spans;?>
|
141
|
<?php echo htmlspecialchars($ipsec['src']);?>
|
142
|
<?php echo $spane;?>
|
143
|
</div>
|
144
|
<div class="listr" style="display:table-cell;width:100px"><?php echo $spans;?>
|
145
|
<?php echo $ipsec['remote-subnet'];?>
|
146
|
<br />
|
147
|
(<?php echo htmlspecialchars($ipsec['dest']);?>)<?php echo $spane;?>
|
148
|
</div>
|
149
|
<div class="listr" style="display:table-cell;width:90px"><?php echo $spans;?><?php echo htmlspecialchars($ipsec['descr']);?><?php echo $spane;?></div>
|
150
|
<div class="listr" style="display:table-cell;width:37px" align="center"><?php echo $spans;?>
|
151
|
<?php
|
152
|
|
153
|
if($ipsec['status'] == "true") {
|
154
|
/* tunnel is up */
|
155
|
$iconfn = "interface_up";
|
156
|
} else {
|
157
|
/* tunnel is down */
|
158
|
$iconfn = "interface_down";
|
159
|
}
|
160
|
|
161
|
echo "<img src ='/themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif' alt='Tunnel status' width='11' height='11' />";
|
162
|
|
163
|
?><?php echo $spane;?></div>
|
164
|
</div>
|
165
|
<?php endforeach; ?>
|
166
|
</div>
|
167
|
</div>
|
168
|
</div>
|
169
|
<div id="ipsec-mobile" style="display:none;background-color:#EEEEEE;">
|
170
|
<div style="padding: 10px">
|
171
|
<div style="display:table-row;">
|
172
|
<div class="widgetsubheader" style="display:table-cell;width:140px">User</div>
|
173
|
<div class="widgetsubheader" style="display:table-cell;width:130px">IP</div>
|
174
|
<div class="widgetsubheader" style="display:table-cell;width:30px">Status</div>
|
175
|
</div>
|
176
|
<div style="max-height:105px;overflow:auto;">
|
177
|
<?php
|
178
|
if (is_array($mobile['pool'])):
|
179
|
foreach ($mobile['pool'] as $pool):
|
180
|
if (is_array($pool['lease'])):
|
181
|
foreach ($pool['lease'] as $muser) : ?>
|
182
|
<div style="display:table-row;">
|
183
|
<div class="listlr" style="display:table-cell;width:139px">
|
184
|
<?php echo htmlspecialchars($muser['id']);?><br />
|
185
|
</div>
|
186
|
<div class="listr" style="display:table-cell;width:130px">
|
187
|
<?php echo htmlspecialchars($muser['host']);?><br />
|
188
|
</div>
|
189
|
<div class="listr" style="display:table-cell;width:30px">
|
190
|
<?php echo htmlspecialchars($muser['status']);?><br/>
|
191
|
</div>
|
192
|
</div>
|
193
|
<?php
|
194
|
endforeach;
|
195
|
endif;
|
196
|
endforeach;
|
197
|
endif;
|
198
|
?>
|
199
|
</div>
|
200
|
</div>
|
201
|
</div>
|
202
|
<?php //end ipsec tunnel
|
203
|
}//end if tunnels are configured, else show code below
|
204
|
else { ?>
|
205
|
<div style="display:block">
|
206
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="note">
|
207
|
<tr>
|
208
|
<td colspan="4">
|
209
|
<span class="vexpl">
|
210
|
<span class="red">
|
211
|
<strong>
|
212
|
Note: There are no configured IPsec Tunnels<br />
|
213
|
</strong>
|
214
|
</span>
|
215
|
You can configure your IPsec
|
216
|
<a href="vpn_ipsec.php">here</a>.
|
217
|
</span>
|
218
|
</td>
|
219
|
</tr>
|
220
|
</table>
|
221
|
</div>
|
222
|
<?php } ?>
|