Project

General

Profile

Download (4.74 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
/* Create array with all IPSEC tunnel descriptions */
39
$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 929d48cb Scott Ullrich
	exec("killall syslogd");
60 963d5343 Bill Marquette
	exec("/usr/sbin/clog -i -s 262144 {$ipsec_logfile}");
61 18330d38 Scott Ullrich
	system_syslogd_start();
62 32887d33 Scott Ullrich
}
63
64 eb3a6710 Seth Mos
$ipsec_logarr = return_clog($ipsec_logfile, $nentries);
65
66 d88c6a9f Scott Ullrich
$pgtitle = array("Status","System logs","IPSEC VPN");
67 b63695db Scott Ullrich
include("head.inc");
68 32887d33 Scott Ullrich
69 b63695db Scott Ullrich
?>
70 32887d33 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
71
<?php include("fbegin.inc"); ?>
72
<table width="100%" border="0" cellpadding="0" cellspacing="0">
73 0913a099 Erik Kristensen
 	<tr>
74
		<td>
75 b63695db Scott Ullrich
<?php
76
	$tab_array = array();
77 9972f533 Bill Marquette
	$tab_array[] = array("System", false, "diag_logs.php");
78
	$tab_array[] = array("Firewall", false, "diag_logs_filter.php");
79
	$tab_array[] = array("DHCP", false, "diag_logs_dhcp.php");
80
	$tab_array[] = array("Portal Auth", false, "diag_logs_auth.php");
81
	$tab_array[] = array("IPSEC VPN", true, "diag_logs_ipsec.php");
82
	$tab_array[] = array("PPTP VPN", false, "diag_logs_vpn.php");
83 ba0a9384 Scott Ullrich
	$tab_array[] = array("Load Balancer", false, "diag_logs_slbd.php");
84 03491df0 Scott Ullrich
	$tab_array[] = array("OpenVPN", false, "diag_logs_openvpn.php");
85 18330d38 Scott Ullrich
	$tab_array[] = array("OpenNTPD", false, "diag_logs_ntpd.php");
86 9972f533 Bill Marquette
	$tab_array[] = array("Settings", false, "diag_logs_settings.php");
87 b63695db Scott Ullrich
	display_top_tabs($tab_array);
88
?>
89 0913a099 Erik Kristensen
  		</td>
90
	</tr>
91
	<tr>
92
    	<td>
93
			<div id="mainarea">
94
			<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
95
		  		<tr>
96
					<td colspan="2" class="listtopic">Last <?=$nentries;?> IPSEC log entries</td>
97
		  		</tr>
98 4a2e189b Seth Mos
				<?php
99
				foreach($ipsec_logarr as $logent){
100 eb3a6710 Seth Mos
					foreach($search as $string) {
101
						if(preg_match($string, $logent))
102
							$match = true;
103
					}
104
					if(isset($match)) {
105
						$logent = preg_replace($search, $replace, $logent);
106
					} else {
107
						$searchs = "/(racoon: )([A-Z:].*?)([0-9].+\.[0-9].+.[0-9].+.[0-9].+\[[0-9].+\])(.*)/i";
108
						$replaces = "$1<strong><font color=red>[Unknown Gateway/Dynamic]</font></strong>: $2$3$4";
109
						$logent = preg_replace($searchs, $replaces, $logent);
110
					}
111 4a2e189b Seth Mos
					$logent = preg_split("/\s+/", $logent, 6);
112
					echo "<tr valign=\"top\">\n";
113
					$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
114
					echo "<td class=\"listlr\" nowrap>" . $entry_date_time  . "</td>\n";
115
					echo "<td class=\"listr\">" . $logent[4] . " " . $logent[5] . "</td>\n";
116
					echo "</tr>\n";
117
				}
118
				?>
119 0913a099 Erik Kristensen
				<tr>
120
					<td>
121
						<br>
122 1a2da578 Scott Ullrich
						<form action="diag_logs_ipsec.php" method="post">
123 0913a099 Erik Kristensen
						<input name="clear" type="submit" class="formbtn" value="Clear log">
124
						</form>
125
					</td>
126
				</tr>
127
			</table>
128
			</div>
129
		</td>
130
	</tr>
131 32887d33 Scott Ullrich
</table>
132
<?php include("fend.inc"); ?>
133 555d3758 Scott Ullrich
<meta http-equiv="refresh" content="60;url=<?php print $_SERVER['SCRIPT_NAME']; ?>">
134 32887d33 Scott Ullrich
</body>
135
</html>