Project

General

Profile

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