Projet

Général

Profil

Télécharger (6,34 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / diag_dump_states_sources.php @ 1b244d38

1
<?php
2
/*
3
	diag_dump_states.php
4
	Copyright (C) 2005-2009 Scott Ullrich
5
	Copyright (C) 2005 Colin Smith
6
	All rights reserved.
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10

    
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13

    
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17

    
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
/*
31
	pfSense_BUILDER_BINARIES:	/sbin/pfctl	
32
	pfSense_MODULE:	filter
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-diagnostics-showstates
37
##|*NAME=Diagnostics: Show States page
38
##|*DESCR=Allow access to the 'Diagnostics: Show States' page.
39
##|*MATCH=diag_dump_states.php*
40
##|-PRIV
41

    
42
require_once("guiconfig.inc");
43

    
44
/* handle AJAX operations */
45
if($_GET['action']) {
46
	if($_GET['action'] == "remove") {
47
		if (is_ipaddr($_GET['srcip']) and is_ipaddr($_GET['dstip'])) {
48
			$retval = mwexec("/sbin/pfctl -K " . escapeshellarg($_GET['srcip']) . " -K " . escapeshellarg($_GET['dstip']));
49
			echo htmlentities("|{$_GET['srcip']}|{$_GET['dstip']}|{$retval}|");
50
		} else {
51
			echo gettext("invalid input");
52
		}
53
		exit;
54
	}
55
}
56

    
57
/* get our states */
58
if($_GET['filter']) {
59
	exec("/sbin/pfctl -s Sources | grep " . escapeshellarg(htmlspecialchars($_GET['filter'])), $sources);
60
}
61
else {
62
	exec("/sbin/pfctl -s Sources", $sources);
63
}
64

    
65
$pgtitle = array(gettext("Diagnostics"),gettext("Show Source Tracking"));
66
include("head.inc");
67

    
68
?>
69

    
70
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?=$jsevents["body"]["onload"];?>">
71
<?php include("fbegin.inc"); ?>
72
<form action="diag_dump_states_sources.php" method="get" name="iform">
73

    
74
<script type="text/javascript">
75
//<![CDATA[
76
	function removeSource(srcip, dstip) {
77
		var busy = function(index,icon) {
78
			jQuery(icon).bind("onclick","");
79
			jQuery(icon).attr('src',jQuery(icon).attr('src').replace("\.gif", "_d.gif"));
80
			jQuery(icon).css("cursor","wait");
81
		}
82

    
83
		jQuery('img[name="i:' + srcip + ":" + dstip + '"]').each(busy);
84

    
85
		jQuery.ajax(
86
			"<?=$_SERVER['SCRIPT_NAME'];?>" +
87
				"?action=remove&srcip=" + srcip + "&dstip=" + dstip,
88
			{ type: "get", complete: removeComplete }
89
		);
90
	}
91

    
92
	function removeComplete(req) {
93
		var values = req.responseText.split("|");
94
		if(values[3] != "0") {
95
			alert('<?=gettext("An error occurred.");?>');
96
			return;
97
		}
98

    
99
		jQuery('tr[name="r:' + values[1] + ":" + values[2] + '"]').each(
100
			function(index,row) { jQuery(row).fadeOut(1000); }
101
		);
102
	}
103
//]]>
104
</script>
105

    
106
<table width="100%" border="0" cellpadding="0" cellspacing="0">
107
	<tr>
108
		<td>
109
		<?php
110
			$tab_array = array();
111
			$tab_array[] = array(gettext("States"), false, "diag_dump_states.php");
112
			$tab_array[] = array(gettext("Source Tracking"), true, "diag_dump_states_sources.php");
113
			$tab_array[] = array(gettext("Reset States"), false, "diag_resetstate.php");
114
			display_top_tabs($tab_array);
115
		?>
116
		</td>
117
	</tr>
118
	<tr>
119
		<td>
120
			<div id="mainarea">
121

    
122
<!-- Start of tab content -->
123

    
124
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
125
	<tr>
126
		<td>
127
			<form action="<?=$_SERVER['SCRIPT_NAME'];?>" method="get">
128
			<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
129
				<tr>
130
					<td>&nbsp;</td>
131
					<td style="font-weight:bold;" align="right">
132
						<?=gettext("Filter expression:");?>
133
						<input type="text" name="filter" class="formfld search" value="<?=htmlspecialchars($_GET['filter']);?>" size="30" />
134
						<input type="submit" class="formbtn" value="<?=gettext("Filter");?>" />
135
					</td>
136
				</tr>
137
			</table>
138
			</form>
139
		</td>
140
	</tr>
141
	<tr>
142
		<td>
143
			<table class="tabcont sortable" width="100%" border="0" cellspacing="0" cellpadding="0">
144
				<thead>
145
				<tr>
146
					<th class="listhdrr" width="40%"><?=gettext("Source -> Destination");?></th>
147
					<th class="listhdrr" width="15%"><?=gettext("# States");?></th>
148
					<th class="listhdrr" width="15%"><?=gettext("# Connections");?></th>
149
					<th class="listhdr" width="15%"><?=gettext("Rate");?></th>
150
					<th class="list sort_ignore" width="1%"></th>
151
				</tr>
152
				</thead>
153
				<tbody>
154
<?php
155
$row = 0;
156
if(count($sources) > 0) {
157
	foreach($sources as $line) {
158
		if($row >= 1000)
159
			break;
160

    
161
		// 192.168.20.2 -> 216.252.56.1 ( states 10, connections 0, rate 0.0/0s )
162

    
163
		$source_split = "";
164
		preg_match("/(.*)\s\(\sstates\s(.*),\sconnections\s(.*),\srate\s(.*)\s\)/", $line, $source_split);
165
		list($all, $info, $numstates, $numconnections, $rate) = $source_split;
166

    
167
		$source_split = "";
168
		preg_match("/(.*)\s\<?-\>?\s(.*)/", $info, $source_split);
169
		list($all, $srcip, $dstip) = $source_split;
170

    
171
		?>
172
		<tr valign='top' name='r:<?php echo "{$srcip}:{$dstip}" ?>'>
173
				<td class='listlr'><?php echo $info;?></td>
174
				<td class='listr'><?php echo $numstates;?></td>
175
				<td class='listr'><?php echo $numconnections;?></td>
176
				<td class='listr'><?php echo $rate;?></td>
177
				<td class='list'>
178
				<img src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif' height='17' width='17' border='0'
179
					onclick="removeSource(<?php echo "'{$srcip}', '{$dstip}'"; ?>);" style='cursor:pointer;'
180
					name='i:<?php echo "{$srcip}:{$dstip}"; ?>'
181
					title='<?php echo gettext("Remove all source tracking entries from") . " {$srcip} " . gettext("to") . " {$dstip}";?>' alt='' />
182
				</td>
183
			  </tr>
184
		<?php
185
		$row++;
186
	}
187
}
188
else {
189
	echo "<tr>
190
			<td class='list' colspan='5' align='center' valign='top'>
191
			  " . gettext("No source tracking entries were found.") . "
192
			</td>
193
		  </tr>";
194
}
195
?>
196
			</tbody>
197
			</table>
198
		</td>
199
	</tr>
200
</table>
201

    
202
<!-- End of tab content -->
203

    
204
		</div>
205
	</td>
206
  </tr>
207
</table>
208

    
209
<?php require("fend.inc"); ?>
210
</body>
211
</html>
(12-12/254)