Project

General

Profile

Download (5.13 KB) Statistics
| Branch: | Tag: | Revision:
1 32887d33 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 32887d33 Scott Ullrich
/*
4
	diag_logs.php
5 13d193c2 Scott Ullrich
	Copyright (C) 2004-2009 Scott Ullrich
6 32887d33 Scott Ullrich
	All rights reserved.
7
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
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 13d193c2 Scott Ullrich
/*	
35
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig	/usr/bin/awk	
36
	pfSense_MODULE:	ipsec
37
*/
38
39 6b07c15a Matthew Grooms
##|+PRIV
40
##|*IDENT=page-status-systemlogs-ipsecvpn
41
##|*NAME=Status: System logs: IPsec VPN page
42
##|*DESCR=Allow access to the 'Status: System logs: IPsec VPN' page.
43
##|*MATCH=diag_logs_ipsec.php*
44
##|-PRIV
45
46 32887d33 Scott Ullrich
require("guiconfig.inc");
47 483e6de8 Scott Ullrich
require("ipsec.inc");
48 32887d33 Scott Ullrich
49 bc7f52e2 Colin Smith
$ipsec_logfile = "{$g['varlog_path']}/ipsec.log";
50 4a2e189b Seth Mos
51 0f266b2e Chris Buechler
/* Create array with all IPsec tunnel descriptions */
52 4a2e189b Seth Mos
$search = array();
53
$replace = array();
54 a93e56c5 Matthew Grooms
if(is_array($config['ipsec']['phase1']))
55
	foreach($config['ipsec']['phase1'] as $ph1ent) {
56 d09641af Seth Mos
		$gateway = ipsec_get_phase1_dst($ph1ent);
57 7fad5151 Scott Ullrich
		$search[] = "/(racoon: )([A-Z:].*?)({$gateway}\[[0-9].+\]|{$gateway})(.*)/i";
58 a93e56c5 Matthew Grooms
		$replace[] = "$1<strong>[{$ph1ent['descr']}]</strong>: $2$3$4";
59 7fad5151 Scott Ullrich
	}
60 eb3a6710 Seth Mos
/* collect all our own ip addresses */
61 13d193c2 Scott Ullrich
exec("/sbin/ifconfig | /usr/bin/awk '/inet / {print $2}'", $ip_address_list);
62 eb3a6710 Seth Mos
foreach($ip_address_list as $address) {
63
	$search[] = "/(racoon: )([A-Z:].*?)({$address}\[[0-9].+\])(.*isakmp.*)/i";
64
	$replace[] = "$1<strong>[Self]</strong>: $2$3$4";
65
}
66 963d5343 Bill Marquette
67 32887d33 Scott Ullrich
$nentries = $config['syslog']['nentries'];
68
if (!$nentries)
69
	$nentries = 50;
70
71 d6abaa18 Scott Ullrich
if ($_POST['clear']) 
72
	clear_log_file($ipsec_logfile);
73 32887d33 Scott Ullrich
74 eb3a6710 Seth Mos
$ipsec_logarr = return_clog($ipsec_logfile, $nentries);
75
76 f8ec8de4 Renato Botelho
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("IPsec VPN"));
77 b63695db Scott Ullrich
include("head.inc");
78 32887d33 Scott Ullrich
79 b63695db Scott Ullrich
?>
80 32887d33 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
81
<?php include("fbegin.inc"); ?>
82
<table width="100%" border="0" cellpadding="0" cellspacing="0">
83 0913a099 Erik Kristensen
 	<tr>
84
		<td>
85 b63695db Scott Ullrich
<?php
86
	$tab_array = array();
87 f8ec8de4 Renato Botelho
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
88
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
89
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
90
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
91
	$tab_array[] = array(gettext("IPsec"), true, "diag_logs_ipsec.php");
92
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
93
	$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
94
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
95
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
96
	$tab_array[] = array(gettext("OpenNTPD"), false, "diag_logs_ntpd.php");
97
	$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
98 b63695db Scott Ullrich
	display_top_tabs($tab_array);
99
?>
100 0913a099 Erik Kristensen
  		</td>
101
	</tr>
102
	<tr>
103
    	<td>
104
			<div id="mainarea">
105
			<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
106
		  		<tr>
107 f8ec8de4 Renato Botelho
					<td colspan="2" class="listtopic"><?php printf(gettext("Last %s  IPsec log entries"),$nentries);?></td>
108 0913a099 Erik Kristensen
		  		</tr>
109 4a2e189b Seth Mos
				<?php
110
				foreach($ipsec_logarr as $logent){
111 eb3a6710 Seth Mos
					foreach($search as $string) {
112
						if(preg_match($string, $logent))
113
							$match = true;
114
					}
115
					if(isset($match)) {
116
						$logent = preg_replace($search, $replace, $logent);
117
					} else {
118
						$searchs = "/(racoon: )([A-Z:].*?)([0-9].+\.[0-9].+.[0-9].+.[0-9].+\[[0-9].+\])(.*)/i";
119 f8ec8de4 Renato Botelho
						$replaces = "$1<strong><font color=red>[".gettext("Unknown Gateway/Dynamic")."]</font></strong>: $2$3$4";
120 eb3a6710 Seth Mos
						$logent = preg_replace($searchs, $replaces, $logent);
121
					}
122 4a2e189b Seth Mos
					$logent = preg_split("/\s+/", $logent, 6);
123
					echo "<tr valign=\"top\">\n";
124
					$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
125
					echo "<td class=\"listlr\" nowrap>" . $entry_date_time  . "</td>\n";
126
					echo "<td class=\"listr\">" . $logent[4] . " " . $logent[5] . "</td>\n";
127
					echo "</tr>\n";
128
				}
129
				?>
130 0913a099 Erik Kristensen
				<tr>
131
					<td>
132
						<br>
133 1a2da578 Scott Ullrich
						<form action="diag_logs_ipsec.php" method="post">
134 2b315054 Carlos Eduardo Ramos
						<input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>">
135 0913a099 Erik Kristensen
						</form>
136
					</td>
137
				</tr>
138
			</table>
139
			</div>
140
		</td>
141
	</tr>
142 32887d33 Scott Ullrich
</table>
143
<?php include("fend.inc"); ?>
144
</body>
145
</html>