Projet

Général

Profil

Télécharger (5,97 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / diag_logs_ipsec.php @ c1229525

1
<?php
2
/* $Id$ */
3
/*
4
	diag_logs.php
5
	Copyright (C) 2004-2009 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
/*	
35
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig	/usr/bin/awk	
36
	pfSense_MODULE:	ipsec
37
*/
38

    
39
##|+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
require("guiconfig.inc");
47
require("ipsec.inc");
48

    
49
$ipsec_logfile = "{$g['varlog_path']}/ipsec.log";
50

    
51
/* Create array with all IPsec tunnel descriptions */
52
$search = array();
53
$replace = array();
54
if(is_array($config['ipsec']['phase1']))
55
	foreach($config['ipsec']['phase1'] as $ph1ent) {
56
		$gateway = ipsec_get_phase1_dst($ph1ent);
57
		if(!is_ipaddr($gateway))
58
			continue;
59
		$search[] = "/(racoon: )(INFO[:].*?)({$gateway}\[[0-9].+\]|{$gateway})(.*)/i";
60
		$search[] = "/(racoon: )(\[{$gateway}\]|{$gateway})(.*)/i";
61
		$replace[] = "$1<strong>[{$ph1ent['descr']}]</strong>: $2$3$4";
62
		$replace[] = "$1<strong>[{$ph1ent['descr']}]</strong>: $2$3$4";
63
	}
64
/* collect all our own ip addresses */
65
exec("/sbin/ifconfig | /usr/bin/awk '/inet/ {print $2}'", $ip_address_list);
66
foreach($ip_address_list as $address) {
67
	$search[] = "/(racoon: )(INFO[:].*?)({$address}\[[0-9].+\])/i";
68
	$search[] = "/(racoon: )(\[{$address}\]|{$address})(.*)/i";
69
	$replace[] = "$1<strong>[Self]</strong>: $2$3$4";
70
	$replace[] = "$1<strong>[Self]</strong>: $2$3$4";
71
}
72

    
73
$search[] = "/(time up waiting for phase1)/i";
74
$search[] = "/(failed to pre-process ph1 packet)/i";
75
$search[] = "/(failed to pre-process ph2 packet)/i";
76
$search[] = "/(no proposal chosen)/i";
77
$replace[] = "$1 <strong>[Remote Side not responding]</strong>";
78
$replace[] = "$1 <strong>[Check Phase 1 settings, lifetime, algorithm]</strong>";
79
$replace[] = "$1 <strong>[Check Phase 2 settings, networks]</strong>";
80
$replace[] = "$1 <strong>[Check Phase 2 settings, algorithm]</strong>";
81

    
82
$nentries = $config['syslog']['nentries'];
83
if (!$nentries)
84
	$nentries = 50;
85

    
86
if ($_POST['clear']) 
87
	clear_log_file($ipsec_logfile);
88

    
89
$ipsec_logarr = return_clog($ipsec_logfile, $nentries);
90

    
91
$pgtitle = array(gettext("Status"),gettext("System logs"),gettext("IPsec VPN"));
92
$shortcut_section = "ipsec";
93
include("head.inc");
94

    
95
?>
96
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
97
<?php include("fbegin.inc"); ?>
98
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="logs ipsec">
99
 	<tr>
100
		<td>
101
<?php
102
	$tab_array = array();
103
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
104
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
105
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
106
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
107
	$tab_array[] = array(gettext("IPsec"), true, "diag_logs_ipsec.php");
108
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
109
	$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
110
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
111
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
112
	$tab_array[] = array(gettext("NTP"), false, "diag_logs_ntpd.php");
113
	$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
114
	display_top_tabs($tab_array);
115
?>
116
  		</td>
117
	</tr>
118
	<tr>
119
    	<td>
120
			<div id="mainarea">
121
			<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area">
122
		  		<tr>
123
					<td colspan="2" class="listtopic"><?php printf(gettext("Last %s  IPsec log entries"),$nentries);?></td>
124
		  		</tr>
125
				<?php
126
				foreach($ipsec_logarr as $logent){
127
					$logent = htmlspecialchars($logent);
128
					foreach($search as $string) {
129
						if(preg_match($string, $logent))
130
							$match = true;
131
					}
132
					if(isset($match)) {
133
						$logent = preg_replace($search, $replace, $logent);
134
					} else {
135
						$searchs = "/(racoon: )([A-Z:].*?)([0-9].+\.[0-9].+.[0-9].+.[0-9].+\[[0-9].+\])(.*)/i";
136
						$replaces = "$1<strong><font color=\"red\">[".gettext("Unknown Gateway/Dynamic")."]</font></strong>: $2$3$4";
137
						$logent = preg_replace($searchs, $replaces, $logent);
138
					}
139
					$logent = preg_split("/\s+/", $logent, 6);
140
					echo "<tr valign=\"top\">\n";
141
					$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
142
					echo "<td class=\"listlr nowrap\">" . $entry_date_time  . "</td>\n";
143
					echo "<td class=\"listr\">" . $logent[4] . " " . $logent[5] . "</td>\n";
144
					echo "</tr>\n";
145
				}
146
				?>
147
				<tr>
148
					<td>
149
						<br />
150
						<form action="diag_logs_ipsec.php" method="post">
151
						<input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>" />
152
						</form>
153
					</td>
154
				</tr>
155
			</table>
156
			</div>
157
		</td>
158
	</tr>
159
</table>
160
<?php include("fend.inc"); ?>
161
</body>
162
</html>
(25-25/254)