Project

General

Profile

Download (6.81 KB) Statistics
| Branch: | Tag: | Revision:
1 5d98aeb1 Scott Ullrich
#!/usr/local/bin/php
2 18330d38 Scott Ullrich
<?php
3 5b237745 Scott Ullrich
/*
4
	diag_logs_vpn.php
5 5d98aeb1 Scott Ullrich
	part of m0n0wall (http://m0n0.ch/wall)
6 18330d38 Scott Ullrich
7 5d98aeb1 Scott Ullrich
	Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
8 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 5b237745 Scott Ullrich
	All rights reserved.
10 18330d38 Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 18330d38 Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 18330d38 Scott Ullrich
17 5b237745 Scott Ullrich
	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 18330d38 Scott Ullrich
21 5b237745 Scott Ullrich
	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 13d193c2 Scott Ullrich
/*	
34 2a50fd8a Renato Botelho
	pfSense_BUILDER_BINARIES:	/usr/sbin/fifolog_reader	/usr/local/sbin/clog
35 13d193c2 Scott Ullrich
	pfSense_MODULE:	vpn
36
*/
37
38 6b07c15a Matthew Grooms
##|+PRIV
39
##|*IDENT=page-diagnostics-logs-pptpvpn
40 328efaba Ermal
##|*NAME=Diagnostics: Logs: VPN page
41
##|*DESCR=Allow access to the 'Diagnostics: Logs: VPN' page.
42 6b07c15a Matthew Grooms
##|*MATCH=diag_logs_vpn.php*
43
##|-PRIV
44
45 77f43ea4 Renato Botelho
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN"));
46 5b237745 Scott Ullrich
require("guiconfig.inc");
47 483e6de8 Scott Ullrich
require_once("vpn.inc");
48 5b237745 Scott Ullrich
49
$nentries = $config['syslog']['nentries'];
50
if (!$nentries)
51
	$nentries = 50;
52
53 43a68abc jim-p
if (htmlspecialchars($_POST['vpntype']))
54
	$vpntype = htmlspecialchars($_POST['vpntype']);
55
elseif (htmlspecialchars($_GET['vpntype']))
56
	$vpntype = htmlspecialchars($_GET['vpntype']);
57
else
58
	$vpntype = "pptp";
59
60
if (htmlspecialchars($_POST['mode']))
61
	$mode = htmlspecialchars($_POST['mode']);
62
elseif (htmlspecialchars($_GET['mode']))
63
	$mode = htmlspecialchars($_GET['mode']);
64
else
65
	$mode = "login";
66
67
switch ($vpntype) {
68
	case 'pptp':
69
		$logname = "pptps";
70
		break;
71
	case 'poes':
72
		$logname = "poes";
73
		break;
74
	case 'l2tp':
75
		$logname = "l2tps";
76
		break;
77
}
78 328efaba Ermal
79 43a68abc jim-p
if ($_POST['clear']) {
80
	if ($mode != "raw")
81
		clear_log_file("/var/log/vpn.log");
82
	else
83
		clear_log_file("/var/log/{$logname}.log");
84
}
85 5d98aeb1 Scott Ullrich
86
function dump_clog_vpn($logfile, $tail) {
87 14905d9f jim-p
	global $g, $config, $vpntype;
88 5d98aeb1 Scott Ullrich
89
	$sor = isset($config['syslog']['reverse']) ? "-r" : "";
90
91 ba8ee067 Scott Ullrich
	$logarr = "";
92 568f30c2 Scott Ullrich
	
93
	if(isset($config['system']['usefifolog'])) 
94 d31ca336 Renato Botelho
		exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr);
95 568f30c2 Scott Ullrich
	else 
96 2a50fd8a Renato Botelho
		exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr);
97 18330d38 Scott Ullrich
98 5d98aeb1 Scott Ullrich
	foreach ($logarr as $logent) {
99
		$logent = preg_split("/\s+/", $logent, 6);
100
		$llent = explode(",", $logent[5]);
101 874e5f2c jim-p
		$iftype = substr($llent[1], 0, 4);
102
		if ($iftype != $vpntype)
103 14905d9f jim-p
			continue;
104 5d98aeb1 Scott Ullrich
		echo "<tr>\n";
105 e3762a2a Colin Fleming
		echo "<td class=\"listlr nowrap\">" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
106 18330d38 Scott Ullrich
107 874e5f2c jim-p
		if ($llent[0] == "login")
108 e3762a2a Colin Fleming
			echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" title=\"login\" alt=\"in\" /></td>\n";
109 5d98aeb1 Scott Ullrich
		else
110 e3762a2a Colin Fleming
			echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_out.gif\" width=\"11\" height=\"11\" title=\"logout\" alt=\"out\" /></td>\n";
111 18330d38 Scott Ullrich
112 874e5f2c jim-p
		echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
113
		echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</td>\n";
114 5d98aeb1 Scott Ullrich
		echo "</tr>\n";
115
	}
116 5b237745 Scott Ullrich
}
117
118 b63695db Scott Ullrich
include("head.inc");
119
120 5b237745 Scott Ullrich
?>
121
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
122
<?php include("fbegin.inc"); ?>
123 e3762a2a Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="logs vpn">
124 5d98aeb1 Scott Ullrich
  <tr><td class="tabnavtbl">
125 b63695db Scott Ullrich
<?php
126 0a5d0b7b sbeaver
127
$tab_array = array();
128
$tab_array[] = array(gettext("System"), false, "diag_logs.php");
129
$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
130
$tab_array[] = array(gettext("DHCP"), false, "diag_logs.php?logfile=dhcpd");
131
$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs.php?logfile=portalauth");
132
$tab_array[] = array(gettext("IPsec"), false, "diag_logs.php?logfile=ipsec");
133
$tab_array[] = array(gettext("PPP"), false, "diag_logs.php?logfile=ppp");
134
$tab_array[] = array(gettext("VPN"), true, "diag_logs_vpn.php");
135
$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs.php?logfile=relayd");
136
$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs.php?logfile=openvpn");
137
$tab_array[] = array(gettext("NTP"), false, "diag_logs.php?logfile=ntpd");
138
$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
139
display_top_tabs($tab_array);
140 b2b61308 jim-p
?>
141
  </td></tr>
142
  <tr><td class="tabnavtbl">
143
<?php
144
	$tab_array = array();
145
	$tab_array[] = array(gettext("PPTP Logins"),
146
				(($vpntype == "pptp") && ($mode != "raw")),
147
				"/diag_logs_vpn.php?vpntype=pptp");
148
	$tab_array[] = array(gettext("PPTP Raw"),
149
				(($vpntype == "pptp") && ($mode == "raw")),
150 e3762a2a Colin Fleming
				"/diag_logs_vpn.php?vpntype=pptp&amp;mode=raw");
151 b2b61308 jim-p
	$tab_array[] = array(gettext("PPPoE Logins"),
152
				(($vpntype == "poes") && ($mode != "raw")),
153
				"/diag_logs_vpn.php?vpntype=poes");
154
	$tab_array[] = array(gettext("PPPoE Raw"),
155
				(($vpntype == "poes") && ($mode == "raw")),
156 e3762a2a Colin Fleming
				"/diag_logs_vpn.php?vpntype=poes&amp;mode=raw");
157 b2b61308 jim-p
	$tab_array[] = array(gettext("L2TP Logins"),
158
				(($vpntype == "l2tp") && ($mode != "raw")),
159
				"/diag_logs_vpn.php?vpntype=l2tp");
160
	$tab_array[] = array(gettext("L2TP Raw"),
161
				(($vpntype == "l2tp") && ($mode == "raw")),
162 e3762a2a Colin Fleming
				"/diag_logs_vpn.php?vpntype=l2tp&amp;mode=raw");
163 b2b61308 jim-p
	display_top_tabs($tab_array);
164 b63695db Scott Ullrich
?>
165 5b237745 Scott Ullrich
  </td></tr>
166
  <tr>
167 5d98aeb1 Scott Ullrich
    <td class="tabcont">
168 b2b61308 jim-p
	<form action="diag_logs_vpn.php" method="post">
169 e3762a2a Colin Fleming
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
170 b2b61308 jim-p
		<tr>
171
		<td colspan="4" class="listtopic">
172
			<?php printf(gettext('Last %1$s %2$s VPN log entries'),$nentries,$vpns[$vpntype]);?></td>
173
		</tr>
174
		<?php if ($mode != "raw"): ?>
175
		<tr>
176
			<td class="listhdrr"><?=gettext("Time");?></td>
177
			<td class="listhdrr"><?=gettext("Action");?></td>
178
			<td class="listhdrr"><?=gettext("User");?></td>
179
			<td class="listhdrr"><?=gettext("IP address");?></td>
180
		</tr>
181 14905d9f jim-p
			<?php dump_clog_vpn("/var/log/vpn.log", $nentries); ?>
182 a6607b5f jim-p
		<?php else: 
183
			dump_clog("/var/log/{$logname}.log", $nentries);
184
		      endif; ?>
185 b2b61308 jim-p
	</table>
186
	<br />
187 e3762a2a Colin Fleming
	<input type="hidden" name="vpntype" id="vpntype" value="<?=$vpntype;?>" />
188
	<input type="hidden" name="mode" id="mode" value="<?=$mode;?>" />
189
	<input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>" />
190 b2b61308 jim-p
	</form>
191 5b237745 Scott Ullrich
	</td>
192
  </tr>
193
</table>
194
<?php include("fend.inc"); ?>
195 e3762a2a Colin Fleming
</body>
196 d31ca336 Renato Botelho
</html>