Project

General

Profile

Download (4.77 KB) Statistics
| Branch: | Tag: | Revision:
1 32887d33 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 32887d33 Scott Ullrich
/*
4
	diag_logs.php
5
	Copyright (C) 2004 Scott Ullrich
6
	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
require("guiconfig.inc");
35
36 bc7f52e2 Colin Smith
$ipsec_logfile = "{$g['varlog_path']}/ipsec.log";
37 4a2e189b Seth Mos
38 0f266b2e Chris Buechler
/* Create array with all IPsec tunnel descriptions */
39 4a2e189b Seth Mos
$search = array();
40
$replace = array();
41 7fad5151 Scott Ullrich
if(is_array($config['ipsec']['tunnel']))
42
	foreach($config['ipsec']['tunnel'] as $tunnel) {
43
		$gateway = "{$tunnel['remote-gateway']}";
44
		$search[] = "/(racoon: )([A-Z:].*?)({$gateway}\[[0-9].+\]|{$gateway})(.*)/i";
45
		$replace[] = "$1<strong>[{$tunnel['descr']}]</strong>: $2$3$4";
46
	}
47 eb3a6710 Seth Mos
/* collect all our own ip addresses */
48
exec("/sbin/ifconfig|/usr/bin/awk '/inet / {print $2}'", $ip_address_list);
49
foreach($ip_address_list as $address) {
50
	$search[] = "/(racoon: )([A-Z:].*?)({$address}\[[0-9].+\])(.*isakmp.*)/i";
51
	$replace[] = "$1<strong>[Self]</strong>: $2$3$4";
52
}
53 963d5343 Bill Marquette
54 32887d33 Scott Ullrich
$nentries = $config['syslog']['nentries'];
55
if (!$nentries)
56
	$nentries = 50;
57
58
if ($_POST['clear']) {
59 74772f9f Scott Ullrich
	if(isset($config['system']['disablesyslogclog'])) {
60
		unlink($ipsec_logfile);
61
		touch($ipsec_logfile);
62
	} else {
63
		exec("killall syslogd");
64
		exec("/usr/sbin/clog -i -s 262144 {$ipsec_logfile}");
65
		system_syslogd_start();
66
	}
67 32887d33 Scott Ullrich
}
68
69 eb3a6710 Seth Mos
$ipsec_logarr = return_clog($ipsec_logfile, $nentries);
70
71 69e108df Chris Buechler
$pgtitle = array("Status","System logs","IPsec VPN");
72 b63695db Scott Ullrich
include("head.inc");
73 32887d33 Scott Ullrich
74 b63695db Scott Ullrich
?>
75 32887d33 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
76
<?php include("fbegin.inc"); ?>
77
<table width="100%" border="0" cellpadding="0" cellspacing="0">
78 0913a099 Erik Kristensen
 	<tr>
79
		<td>
80 b63695db Scott Ullrich
<?php
81
	$tab_array = array();
82 9972f533 Bill Marquette
	$tab_array[] = array("System", false, "diag_logs.php");
83
	$tab_array[] = array("Firewall", false, "diag_logs_filter.php");
84
	$tab_array[] = array("DHCP", false, "diag_logs_dhcp.php");
85
	$tab_array[] = array("Portal Auth", false, "diag_logs_auth.php");
86 0f266b2e Chris Buechler
	$tab_array[] = array("IPsec VPN", true, "diag_logs_ipsec.php");
87 9972f533 Bill Marquette
	$tab_array[] = array("PPTP VPN", false, "diag_logs_vpn.php");
88 ba0a9384 Scott Ullrich
	$tab_array[] = array("Load Balancer", false, "diag_logs_slbd.php");
89 03491df0 Scott Ullrich
	$tab_array[] = array("OpenVPN", false, "diag_logs_openvpn.php");
90 18330d38 Scott Ullrich
	$tab_array[] = array("OpenNTPD", false, "diag_logs_ntpd.php");
91 9972f533 Bill Marquette
	$tab_array[] = array("Settings", false, "diag_logs_settings.php");
92 b63695db Scott Ullrich
	display_top_tabs($tab_array);
93
?>
94 0913a099 Erik Kristensen
  		</td>
95
	</tr>
96
	<tr>
97
    	<td>
98
			<div id="mainarea">
99
			<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
100
		  		<tr>
101 69e108df Chris Buechler
					<td colspan="2" class="listtopic">Last <?=$nentries;?> IPsec log entries</td>
102 0913a099 Erik Kristensen
		  		</tr>
103 4a2e189b Seth Mos
				<?php
104
				foreach($ipsec_logarr as $logent){
105 eb3a6710 Seth Mos
					foreach($search as $string) {
106
						if(preg_match($string, $logent))
107
							$match = true;
108
					}
109
					if(isset($match)) {
110
						$logent = preg_replace($search, $replace, $logent);
111
					} else {
112
						$searchs = "/(racoon: )([A-Z:].*?)([0-9].+\.[0-9].+.[0-9].+.[0-9].+\[[0-9].+\])(.*)/i";
113
						$replaces = "$1<strong><font color=red>[Unknown Gateway/Dynamic]</font></strong>: $2$3$4";
114
						$logent = preg_replace($searchs, $replaces, $logent);
115
					}
116 4a2e189b Seth Mos
					$logent = preg_split("/\s+/", $logent, 6);
117
					echo "<tr valign=\"top\">\n";
118
					$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
119
					echo "<td class=\"listlr\" nowrap>" . $entry_date_time  . "</td>\n";
120
					echo "<td class=\"listr\">" . $logent[4] . " " . $logent[5] . "</td>\n";
121
					echo "</tr>\n";
122
				}
123
				?>
124 0913a099 Erik Kristensen
				<tr>
125
					<td>
126
						<br>
127 1a2da578 Scott Ullrich
						<form action="diag_logs_ipsec.php" method="post">
128 0913a099 Erik Kristensen
						<input name="clear" type="submit" class="formbtn" value="Clear log">
129
						</form>
130
					</td>
131
				</tr>
132
			</table>
133
			</div>
134
		</td>
135
	</tr>
136 32887d33 Scott Ullrich
</table>
137
<?php include("fend.inc"); ?>
138
</body>
139
</html>