1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
diag_ipsec.php
|
5
|
Copyright (C) 2004-2009 Scott Ullrich
|
6
|
Copyright (C) 2008 Shrew Soft Inc <mgrooms@shrew.net>.
|
7
|
All rights reserved.
|
8
|
|
9
|
Parts of this code was originally based on vpn_ipsec_sad.php
|
10
|
Copyright (C) 2003-2004 Manuel Kasper
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
|
34
|
/*
|
35
|
pfSense_MODULE: ipsec
|
36
|
*/
|
37
|
|
38
|
##|+PRIV
|
39
|
##|*IDENT=page-status-ipsec
|
40
|
##|*NAME=Status: IPsec page
|
41
|
##|*DESCR=Allow access to the 'Status: IPsec' page.
|
42
|
##|*MATCH=diag_ipsec.php*
|
43
|
##|-PRIV
|
44
|
|
45
|
|
46
|
global $g;
|
47
|
|
48
|
$pgtitle = array(gettext("Status"),gettext("IPsec"));
|
49
|
|
50
|
require("guiconfig.inc");
|
51
|
include("head.inc");
|
52
|
require("ipsec.inc");
|
53
|
|
54
|
if ($_GET['act'] == "connect") {
|
55
|
if (is_ipaddr($_GET['remoteid']) && is_ipaddr($_GET['source'])) {
|
56
|
exec("/sbin/ping -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
|
57
|
}
|
58
|
}
|
59
|
|
60
|
if (!is_array($config['ipsec']['phase2']))
|
61
|
$config['ipsec']['phase2'] = array();
|
62
|
|
63
|
$a_phase2 = &$config['ipsec']['phase2'];
|
64
|
|
65
|
$spd = ipsec_dump_spd();
|
66
|
$sad = ipsec_dump_sad();
|
67
|
|
68
|
?>
|
69
|
|
70
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
|
71
|
<?php include("fbegin.inc"); ?>
|
72
|
<div id="inputerrors"></div>
|
73
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
74
|
<tr>
|
75
|
<td>
|
76
|
<?php
|
77
|
$tab_array = array();
|
78
|
$tab_array[0] = array(gettext("Overview"), true, "diag_ipsec.php");
|
79
|
$tab_array[1] = array(gettext("SAD"), false, "diag_ipsec_sad.php");
|
80
|
$tab_array[2] = array(gettext("SPD"), false, "diag_ipsec_spd.php");
|
81
|
$tab_array[3] = array(gettext("Logs"), false, "diag_logs_ipsec.php");
|
82
|
display_top_tabs($tab_array);
|
83
|
?>
|
84
|
</td>
|
85
|
</tr>
|
86
|
<tr>
|
87
|
<td>
|
88
|
<div id="mainarea">
|
89
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable">
|
90
|
<tr>
|
91
|
<td nowrap class="listhdrr"><?=gettext("Local IP");?></td>
|
92
|
<td nowrap class="listhdrr"><?=gettext("Remote IP");?></a></td>
|
93
|
<td nowrap class="listhdrr"><?=gettext("Local Network");?></td>
|
94
|
<td nowrap class="listhdrr"><?=gettext("Remote Network");?></a></td>
|
95
|
<td nowrap class="listhdrr"><?=gettext("Description");?></a></td>
|
96
|
<td nowrap class="listhdrr"><?=gettext("Status");?></td>
|
97
|
</tr>
|
98
|
<?php
|
99
|
foreach ($a_phase2 as $ph2ent) {
|
100
|
ipsec_lookup_phase1($ph2ent,$ph1ent);
|
101
|
if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) {
|
102
|
if(ipsec_phase2_status($spd,$sad,$ph1ent,$ph2ent))
|
103
|
$icon = "pass";
|
104
|
elseif(!isset($config['ipsec']['enable']))
|
105
|
$icon = "block";
|
106
|
else
|
107
|
$icon = "reject";
|
108
|
?>
|
109
|
<tr>
|
110
|
<td class="listlr">
|
111
|
<?=htmlspecialchars(ipsec_get_phase1_src($ph1ent));?>
|
112
|
</td>
|
113
|
<td class="listr">
|
114
|
<?=htmlspecialchars($ph1ent['remote-gateway']);?>
|
115
|
</td>
|
116
|
<td class="listr">
|
117
|
<?php echo ipsec_idinfo_to_text($ph2ent['localid']); ?>
|
118
|
</td>
|
119
|
<td class="listr">
|
120
|
<?php echo ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
|
121
|
</td>
|
122
|
<td class="listr"><?=htmlspecialchars($ph2ent['descr']);?></td>
|
123
|
<td class="listr">
|
124
|
<center>
|
125
|
<img src ="/themes/<?=$g['theme']?>/images/icons/icon_<?=$icon?>.gif">
|
126
|
</center>
|
127
|
</td>
|
128
|
<td class="list">
|
129
|
<?php
|
130
|
$source = "";
|
131
|
if ($ph2ent['localid']['type'] == 'lan') {
|
132
|
$source = get_interface_ip('lan');
|
133
|
} else {
|
134
|
$source = get_interface_ip(find_ip_interface($ph2ent['localid']['address']));
|
135
|
}
|
136
|
|
137
|
?>
|
138
|
<?php if (($ph2ent['remoteid']['type'] != "mobile") && ($icon != "pass") && ($source != "")): ?>
|
139
|
<center>
|
140
|
<a href="diag_ipsec.php?act=connect&remoteid=<?= $ph2ent['remoteid']['address'] ?>&source=<?= $source ?>">
|
141
|
<img src ="/themes/<?=$g['theme']?>/images/icons/icon_service_start.gif" alt="Connect VPN" title="Connect VPN" border="0">
|
142
|
</a>
|
143
|
</center>
|
144
|
<?php else: ?>
|
145
|
|
146
|
<?php endif; ?>
|
147
|
</td>
|
148
|
</tr>
|
149
|
<?php
|
150
|
}
|
151
|
}
|
152
|
?>
|
153
|
</table>
|
154
|
</div>
|
155
|
</td>
|
156
|
</tr>
|
157
|
</table>
|
158
|
|
159
|
<p/>
|
160
|
|
161
|
<span class="vexpl">
|
162
|
<span class="red">
|
163
|
<strong><?=gettext("Note:");?><br /></strong>
|
164
|
</span>
|
165
|
<?=gettext("You can configure your IPsec");?>
|
166
|
<a href="vpn_ipsec.php">here</a>.
|
167
|
</span>
|
168
|
|
169
|
<?php include("fend.inc"); ?>
|
170
|
</body>
|
171
|
</html>
|