Project

General

Profile

Download (4.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
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
$ipsec_logfile = "{$g['varlog_path']}/ipsec.log";
37

    
38
/* Create array with all IPSEC tunnel descriptions */
39
$search = array();
40
$replace = array();
41
if(is_array($config['ipsec']['tunnel']))
42
	foreach($config['ipsec']['tunnel'] as $tunnel) {
43
		if(!is_ipaddr($tunnel['remote-gateway']))
44
			$tunnel['remote-gateway'] = resolve_retry($tunnel['remote-gateway']);
45

    
46
		$gateway = "{$tunnel['remote-gateway']}";
47
		$search[] = "/(racoon: )([A-Z:].*?)({$gateway}\[[0-9].+\]|{$gateway})(.*)/i";
48
		$replace[] = "$1<strong>[{$tunnel['descr']}]</strong>: $2$3$4";
49
	}
50
/* collect all our own ip addresses */
51
exec("/sbin/ifconfig|/usr/bin/awk '/inet / {print $2}'", $ip_address_list);
52
foreach($ip_address_list as $address) {
53
	$search[] = "/(racoon: )([A-Z:].*?)({$address}\[[0-9].+\])(.*isakmp.*)/i";
54
	$replace[] = "$1<strong>[Self]</strong>: $2$3$4";
55
}
56

    
57
$nentries = $config['syslog']['nentries'];
58
if (!$nentries)
59
	$nentries = 50;
60

    
61
if ($_POST['clear']) {
62
	exec("killall syslogd");
63
	exec("/usr/sbin/clog -i -s 262144 {$ipsec_logfile}");
64
	system_syslogd_start();
65
}
66

    
67
$ipsec_logarr = return_clog($ipsec_logfile, $nentries);
68

    
69
$pgtitle = "Diagnostics: System logs: IPSEC VPN";
70
include("head.inc");
71

    
72
?>
73
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
74
<?php include("fbegin.inc"); ?>
75
<p class="pgtitle"><?=$pgtitle?></p>
76
<table width="100%" border="0" cellpadding="0" cellspacing="0">
77
 	<tr>
78
		<td>
79
<?php
80
	$tab_array = array();
81
	$tab_array[] = array("System", false, "diag_logs.php");
82
	$tab_array[] = array("Firewall", false, "diag_logs_filter.php");
83
	$tab_array[] = array("DHCP", false, "diag_logs_dhcp.php");
84
	$tab_array[] = array("Portal Auth", false, "diag_logs_auth.php");
85
	$tab_array[] = array("IPsec VPN", true, "diag_logs_ipsec.php");
86
	$tab_array[] = array("PPTP VPN", false, "diag_logs_vpn.php");
87
	$tab_array[] = array("Load Balancer", false, "diag_logs_slbd.php");
88
	$tab_array[] = array("OpenVPN", false, "diag_logs_openvpn.php");
89
	$tab_array[] = array("OpenNTPD", false, "diag_logs_ntpd.php");
90
	$tab_array[] = array("Settings", false, "diag_logs_settings.php");
91
	display_top_tabs($tab_array);
92
?>
93
  		</td>
94
	</tr>
95
	<tr>
96
    	<td>
97
			<div id="mainarea">
98
			<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
99
		  		<tr>
100
					<td colspan="2" class="listtopic">Last <?=$nentries;?> IPSEC log entries</td>
101
		  		</tr>
102
				<?php
103
				foreach($ipsec_logarr as $logent){
104
					foreach($search as $string) {
105
						if(preg_match($string, $logent))
106
							$match = true;
107
					}
108
					if(isset($match)) {
109
						$logent = preg_replace($search, $replace, $logent);
110
					} else {
111
						$searchs = "/(racoon: )([A-Z:].*?)([0-9].+\.[0-9].+.[0-9].+.[0-9].+\[[0-9].+\])(.*)/i";
112
						$replaces = "$1<strong><font color=red>[Unknown Gateway/Dynamic]</font></strong>: $2$3$4";
113
						$logent = preg_replace($searchs, $replaces, $logent);
114
					}
115
					$logent = preg_split("/\s+/", $logent, 6);
116
					echo "<tr valign=\"top\">\n";
117
					$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
118
					echo "<td class=\"listlr\" nowrap>" . $entry_date_time  . "</td>\n";
119
					echo "<td class=\"listr\">" . $logent[4] . " " . $logent[5] . "</td>\n";
120
					echo "</tr>\n";
121
				}
122
				?>
123
				<tr>
124
					<td>
125
						<br>
126
						<form action="diag_logs_ipsec.php" method="post">
127
						<input name="clear" type="submit" class="formbtn" value="Clear log">
128
						</form>
129
					</td>
130
				</tr>
131
			</table>
132
			</div>
133
		</td>
134
	</tr>
135
</table>
136
<?php include("fend.inc"); ?>
137
</body>
138
</html>
(18-18/175)