Projet

Général

Profil

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

univnautes / usr / local / www / diag_dump_states_sources.php @ 0fab7eb1

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
	function removeSource(srcip, dstip) {
76
		var busy = function(index,icon) {
77
			jQuery(icon).bind("onclick","");
78
			jQuery(icon).attr('src',jQuery(icon).attr('src').replace("\.gif", "_d.gif"));
79
			jQuery(icon).css("cursor","wait");
80
		}
81

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

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

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

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

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

    
120
<!-- Start of tab content -->
121

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

    
159
		// 192.168.20.2 -> 216.252.56.1 ( states 10, connections 0, rate 0.0/0s )
160

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

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

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

    
200
<!-- End of tab content -->
201

    
202
		</div>
203
	</td>
204
  </tr>
205
</table>
206

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