1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/*
|
4
|
diag_logs_vpn.php
|
5
|
part of m0n0wall (http://m0n0.ch/wall)
|
6
|
|
7
|
Copyright (C) 2003-2006 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
|
/*
|
33
|
pfSense_BUILDER_BINARIES: /usr/sbin/fifolog_reader /usr/local/sbin/clog
|
34
|
pfSense_MODULE: vpn
|
35
|
*/
|
36
|
|
37
|
##|+PRIV
|
38
|
##|*IDENT=page-diagnostics-logs-pptpvpn
|
39
|
##|*NAME=Diagnostics: Logs: VPN page
|
40
|
##|*DESCR=Allow access to the 'Diagnostics: Logs: VPN' page.
|
41
|
##|*MATCH=diag_logs_vpn.php*
|
42
|
##|-PRIV
|
43
|
|
44
|
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN"));
|
45
|
require("guiconfig.inc");
|
46
|
require_once("vpn.inc");
|
47
|
|
48
|
$nentries = $config['syslog']['nentries'];
|
49
|
if (!$nentries)
|
50
|
$nentries = 50;
|
51
|
|
52
|
if (htmlspecialchars($_POST['vpntype']))
|
53
|
$vpntype = htmlspecialchars($_POST['vpntype']);
|
54
|
elseif (htmlspecialchars($_GET['vpntype']))
|
55
|
$vpntype = htmlspecialchars($_GET['vpntype']);
|
56
|
else
|
57
|
$vpntype = "pptp";
|
58
|
|
59
|
if (htmlspecialchars($_POST['mode']))
|
60
|
$mode = htmlspecialchars($_POST['mode']);
|
61
|
elseif (htmlspecialchars($_GET['mode']))
|
62
|
$mode = htmlspecialchars($_GET['mode']);
|
63
|
else
|
64
|
$mode = "login";
|
65
|
|
66
|
switch ($vpntype) {
|
67
|
case 'pptp':
|
68
|
$logname = "pptps";
|
69
|
break;
|
70
|
case 'poes':
|
71
|
$logname = "poes";
|
72
|
break;
|
73
|
case 'l2tp':
|
74
|
$logname = "l2tps";
|
75
|
break;
|
76
|
}
|
77
|
|
78
|
if ($_POST['clear']) {
|
79
|
if ($mode != "raw")
|
80
|
clear_log_file("/var/log/vpn.log");
|
81
|
else
|
82
|
clear_log_file("/var/log/{$logname}.log");
|
83
|
}
|
84
|
|
85
|
function dump_clog_vpn($logfile, $tail) {
|
86
|
global $g, $config, $vpntype;
|
87
|
|
88
|
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
|
89
|
|
90
|
$logarr = "";
|
91
|
|
92
|
if(isset($config['system']['usefifolog']))
|
93
|
exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr);
|
94
|
else
|
95
|
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr);
|
96
|
|
97
|
foreach ($logarr as $logent) {
|
98
|
$logent = preg_split("/\s+/", $logent, 6);
|
99
|
$llent = explode(",", $logent[5]);
|
100
|
$iftype = substr($llent[1], 0, 4);
|
101
|
if ($iftype != $vpntype)
|
102
|
continue;
|
103
|
echo "<tr>\n";
|
104
|
echo "<td class=\"listlr nowrap\">" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
|
105
|
|
106
|
if ($llent[0] == "login")
|
107
|
echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" title=\"login\" alt=\"in\" /></td>\n";
|
108
|
else
|
109
|
echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_out.gif\" width=\"11\" height=\"11\" title=\"logout\" alt=\"out\" /></td>\n";
|
110
|
|
111
|
echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
|
112
|
echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . " </td>\n";
|
113
|
echo "</tr>\n";
|
114
|
}
|
115
|
}
|
116
|
|
117
|
include("head.inc");
|
118
|
|
119
|
?>
|
120
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
121
|
<?php include("fbegin.inc"); ?>
|
122
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="logs vpn">
|
123
|
<tr><td class="tabnavtbl">
|
124
|
<?php
|
125
|
$tab_array = array();
|
126
|
$tab_array[] = array(gettext("System"), false, "diag_logs.php");
|
127
|
$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
|
128
|
$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
|
129
|
$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
|
130
|
$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
|
131
|
$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
|
132
|
$tab_array[] = array(gettext("VPN"), true, "diag_logs_vpn.php");
|
133
|
$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
|
134
|
$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
|
135
|
$tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php");
|
136
|
$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
|
137
|
display_top_tabs($tab_array);
|
138
|
?>
|
139
|
</td></tr>
|
140
|
<tr><td class="tabnavtbl">
|
141
|
<?php
|
142
|
$tab_array = array();
|
143
|
$tab_array[] = array(gettext("PPTP Logins"),
|
144
|
(($vpntype == "pptp") && ($mode != "raw")),
|
145
|
"/diag_logs_vpn.php?vpntype=pptp");
|
146
|
$tab_array[] = array(gettext("PPTP Raw"),
|
147
|
(($vpntype == "pptp") && ($mode == "raw")),
|
148
|
"/diag_logs_vpn.php?vpntype=pptp&mode=raw");
|
149
|
$tab_array[] = array(gettext("PPPoE Logins"),
|
150
|
(($vpntype == "poes") && ($mode != "raw")),
|
151
|
"/diag_logs_vpn.php?vpntype=poes");
|
152
|
$tab_array[] = array(gettext("PPPoE Raw"),
|
153
|
(($vpntype == "poes") && ($mode == "raw")),
|
154
|
"/diag_logs_vpn.php?vpntype=poes&mode=raw");
|
155
|
$tab_array[] = array(gettext("L2TP Logins"),
|
156
|
(($vpntype == "l2tp") && ($mode != "raw")),
|
157
|
"/diag_logs_vpn.php?vpntype=l2tp");
|
158
|
$tab_array[] = array(gettext("L2TP Raw"),
|
159
|
(($vpntype == "l2tp") && ($mode == "raw")),
|
160
|
"/diag_logs_vpn.php?vpntype=l2tp&mode=raw");
|
161
|
display_top_tabs($tab_array);
|
162
|
?>
|
163
|
</td></tr>
|
164
|
<tr>
|
165
|
<td class="tabcont">
|
166
|
<form action="diag_logs_vpn.php" method="post">
|
167
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
|
168
|
<tr>
|
169
|
<td colspan="4" class="listtopic">
|
170
|
<?php printf(gettext('Last %1$s %2$s VPN log entries'),$nentries,$vpns[$vpntype]);?></td>
|
171
|
</tr>
|
172
|
<?php if ($mode != "raw"): ?>
|
173
|
<tr>
|
174
|
<td class="listhdrr"><?=gettext("Time");?></td>
|
175
|
<td class="listhdrr"><?=gettext("Action");?></td>
|
176
|
<td class="listhdrr"><?=gettext("User");?></td>
|
177
|
<td class="listhdrr"><?=gettext("IP address");?></td>
|
178
|
</tr>
|
179
|
<?php dump_clog_vpn("/var/log/vpn.log", $nentries); ?>
|
180
|
<?php else:
|
181
|
dump_clog("/var/log/{$logname}.log", $nentries);
|
182
|
endif; ?>
|
183
|
</table>
|
184
|
<br />
|
185
|
<input type="hidden" name="vpntype" id="vpntype" value="<?=$vpntype;?>" />
|
186
|
<input type="hidden" name="mode" id="mode" value="<?=$mode;?>" />
|
187
|
<input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>" />
|
188
|
</form>
|
189
|
</td>
|
190
|
</tr>
|
191
|
</table>
|
192
|
<?php include("fend.inc"); ?>
|
193
|
</body>
|
194
|
</html>
|