Revision 23601b9a
Added by Sjon Hortensius over 10 years ago
usr/local/www/diag_routes.php | ||
---|---|---|
31 | 31 |
*/ |
32 | 32 |
|
33 | 33 |
/* |
34 |
pfSense_BUILDER_BINARIES: /usr/bin/netstat
|
|
34 |
pfSense_BUILDER_BINARIES: /usr/bin/netstat |
|
35 | 35 |
pfSense_MODULE: routing |
36 | 36 |
*/ |
37 | 37 |
##|+PRIV |
... | ... | |
77 | 77 |
|
78 | 78 |
include('head.inc'); |
79 | 79 |
|
80 |
?> |
|
81 |
|
|
82 |
<script type="text/javascript"> |
|
83 |
//<![CDATA[ |
|
84 |
|
|
85 |
function update_routes(section) { |
|
86 |
var url = "diag_routes.php"; |
|
87 |
var limit = jQuery('#limit option:selected').text(); |
|
88 |
var filter = jQuery('#filter').val(); |
|
89 |
var params = "isAjax=true&limit=" + limit + "&filter=" + filter; |
|
90 |
|
|
91 |
if (jQuery('#resolve').is(':checked')) |
|
92 |
params += "&resolve=true"; |
|
93 |
if (section == "IPv6") |
|
94 |
params += "&IPv6=true"; |
|
95 |
|
|
96 |
jQuery.ajax( |
|
97 |
url, |
|
98 |
{ |
|
99 |
type: 'post', |
|
100 |
data: params, |
|
101 |
complete: update_routes_callback |
|
102 |
}); |
|
103 |
} |
|
104 |
|
|
105 |
function update_routes_callback(transport) { |
|
106 |
// First line contains section |
|
107 |
var responseTextArr = transport.responseText.split("\n"); |
|
108 |
var section = responseTextArr.shift(); |
|
109 |
var tbody = ''; |
|
110 |
var field = ''; |
|
111 |
var elements = 8; |
|
112 |
var tr_class = ''; |
|
113 |
|
|
114 |
var thead = '<tr class="info"><th class="listtopic" colspan="' + elements + '">' + section + '<\/th><\/tr>' + "\n"; |
|
115 |
|
|
116 |
for (var i = 0; i < responseTextArr.length; i++) { |
|
117 |
if (responseTextArr[i] == "") |
|
118 |
continue; |
|
119 |
var tmp = ''; |
|
120 |
if (i == 0) { |
|
121 |
tr_class = 'listhdrr'; |
|
122 |
tmp += '<tr class="sortableHeaderRowIdentifier">' + "\n"; |
|
123 |
} else { |
|
124 |
tr_class = 'listlr'; |
|
125 |
tmp += '<tr>' + "\n"; |
|
126 |
} |
|
127 |
var j = 0; |
|
128 |
var entry = responseTextArr[i].split(" "); |
|
129 |
for (var k = 0; k < entry.length; k++) { |
|
130 |
if (entry[k] == "") |
|
131 |
continue; |
|
132 |
if (i == 0 && j == (elements - 1)) |
|
133 |
tr_class = 'listhdr'; |
|
134 |
tmp += '<td class="' + tr_class + '">' + entry[k] + '<\/td>' + "\n"; |
|
135 |
if (i > 0) |
|
136 |
tr_class = 'listr'; |
|
137 |
j++; |
|
138 |
} |
|
139 |
|
|
140 |
tmp += '<td class="listr"> <\/td>' + "\n"; |
|
141 |
|
|
142 |
if (i == 0) |
|
143 |
thead += tmp; |
|
144 |
else |
|
145 |
tbody += tmp; |
|
146 |
} |
|
147 |
|
|
148 |
jQuery('#' + section + ' > thead').html(thead); |
|
149 |
jQuery('#' + section + ' > tbody').html(tbody); |
|
150 |
} |
|
151 |
|
|
152 |
//]]> |
|
153 |
</script> |
|
154 |
|
|
155 |
<script type="text/javascript"> |
|
156 |
//<![CDATA[ |
|
157 |
|
|
158 |
function update_all_routes() { |
|
159 |
update_routes("IPv4"); |
|
160 |
update_routes("IPv6"); |
|
161 |
} |
|
162 |
|
|
163 |
setTimeout('update_all_routes()', 5000); |
|
164 |
|
|
165 |
//]]> |
|
166 |
</script> |
|
167 |
|
|
168 |
<?php |
|
169 |
|
|
170 | 80 |
require('classes/Form.class.php'); |
171 | 81 |
|
172 | 82 |
$form = new Form(new Form_Button( |
173 |
'', |
|
174 |
'' |
|
83 |
'update', |
|
84 |
'Update' |
|
85 |
)); |
|
86 |
$form->addGlobal(new Form_Input( |
|
87 |
'isAjax', |
|
88 |
null, |
|
89 |
'hidden', |
|
90 |
1 |
|
175 | 91 |
)); |
176 |
|
|
177 | 92 |
$section = new Form_Section('Traceroute'); |
178 | 93 |
|
179 | 94 |
$section->addInput(new Form_Checkbox( |
180 | 95 |
'resolve', |
96 |
'Resolve names', |
|
181 | 97 |
'Enable', |
182 |
'', |
|
183 | 98 |
$resolve |
184 |
))->setHelp('Enabling name resolution may cause the query should take longer. You can stop it at any time by clicking the Stop button in your browser.');
|
|
185 |
|
|
99 |
))->setHelp('Enabling name resolution may cause the query should take longer.'.
|
|
100 |
' You can stop it at any time by clicking the Stop button in your browser.'); |
|
186 | 101 |
|
102 |
$validLimits = array('10', '50', '100', '200', '500', '1000', 'all'); |
|
187 | 103 |
$section->addInput(new Form_Select( |
188 | 104 |
'limit', |
189 | 105 |
'Rows to display', |
190 | 106 |
$limit, |
191 |
array_combine(array("10", "50", "100", "200", "500", "1000", gettext("all")), array("10", "50", "100", "200", "500", "1000", gettext("all")))
|
|
107 |
array_combine($validLimits, $validLimits)
|
|
192 | 108 |
)); |
193 | 109 |
|
194 | 110 |
$section->addInput(new Form_Input( |
195 | 111 |
'filter', |
196 | 112 |
'Filter', |
197 | 113 |
'text', |
198 |
$host, |
|
199 |
['placeholder' => ''] |
|
114 |
$host |
|
200 | 115 |
))->setHelp('Use a regular expression to filter IP address or hostnames'); |
201 | 116 |
|
202 | 117 |
$form->add($section); |
203 |
|
|
204 | 118 |
print $form; |
205 |
|
|
206 | 119 |
?> |
120 |
<script> |
|
121 |
function update_routes(section) { |
|
122 |
$.ajax( |
|
123 |
'/diag_routes.php', |
|
124 |
{ |
|
125 |
type: 'post', |
|
126 |
data: $(document.forms[0]).serialize() +'&'+ section +'=true', |
|
127 |
success: update_routes_callback, |
|
128 |
}); |
|
129 |
} |
|
207 | 130 |
|
208 |
<input type="button" class="btn btn-default" name="update" onclick="update_all_routes();" value="<?=gettext("Update"); ?>" /><br /><br /> |
|
209 |
|
|
210 |
<table class="table table-striped table-compact" id="IPv4"> |
|
211 |
<thead> |
|
212 |
<tr> |
|
213 |
<th>IPv4</th> |
|
214 |
</tr> |
|
215 |
</thead> |
|
216 |
<tbody> |
|
217 |
<tr> |
|
218 |
<td class="listhdrr"><?=gettext("Gathering data, please wait...")?></td> |
|
219 |
</tr> |
|
220 |
</tbody> |
|
221 |
</table> |
|
222 |
|
|
223 |
<table table class="table table-striped table-compact" id="IPv6"> |
|
224 |
<thead> |
|
225 |
<tr> |
|
226 |
<th>IPv6</th> |
|
227 |
</tr> |
|
228 |
</thead> |
|
229 |
<tbody> |
|
230 |
<tr> |
|
231 |
<td class="listhdrr"><?=gettext("Gathering data, please wait...")?></td> |
|
232 |
</tr> |
|
233 |
</tbody> |
|
234 |
</table> |
|
131 |
function update_routes_callback(html) { |
|
132 |
// First line contains section |
|
133 |
var responseTextArr = html.split("\n"); |
|
134 |
var section = responseTextArr.shift(); |
|
135 |
var tbody = ''; |
|
136 |
var field = ''; |
|
137 |
var tr_class = ''; |
|
138 |
var thead = '<tr>'; |
|
139 |
|
|
140 |
for (var i = 0; i < responseTextArr.length; i++) { |
|
141 |
if (responseTextArr[i] == "") |
|
142 |
continue; |
|
143 |
var tmp = '<tr>'; |
|
144 |
var j = 0; |
|
145 |
var entry = responseTextArr[i].split(" "); |
|
146 |
for (var k = 0; k < entry.length; k++) { |
|
147 |
if (entry[k] == "") |
|
148 |
continue; |
|
149 |
if (i == 0) |
|
150 |
tmp += '<th>' + entry[k] + '<\/th>'; |
|
151 |
else |
|
152 |
tmp += '<td>' + entry[k] + '<\/td>'; |
|
153 |
j++; |
|
154 |
} |
|
155 |
|
|
156 |
tmp += '<td><\/td>'; |
|
157 |
|
|
158 |
if (i == 0) |
|
159 |
thead += tmp; |
|
160 |
else |
|
161 |
tbody += tmp; |
|
162 |
} |
|
163 |
|
|
164 |
$('#' + section + ' > thead').html(thead); |
|
165 |
$('#' + section + ' > tbody').html(tbody); |
|
166 |
} |
|
167 |
|
|
168 |
function update_all_routes() { |
|
169 |
update_routes("IPv4"); |
|
170 |
update_routes("IPv6"); |
|
171 |
} |
|
172 |
|
|
173 |
events.push(function(){ |
|
174 |
setInterval('update_all_routes()', 5000); |
|
175 |
update_all_routes(); |
|
176 |
|
|
177 |
$(document.forms[0]).on('submit', function(e){ |
|
178 |
update_all_routes(); |
|
179 |
|
|
180 |
e.preventDefault(); |
|
181 |
}); |
|
182 |
}); |
|
183 |
</script> |
|
184 |
|
|
185 |
<div class="panel panel-default"> |
|
186 |
<div class="panel-heading">IPv4 Routes</div> |
|
187 |
<div class="panel panel-body"> |
|
188 |
<table class="table table-striped table-compact" id="IPv4"> |
|
189 |
<thead> |
|
190 |
<!-- filled by xhr --> |
|
191 |
</thead> |
|
192 |
<tbody> |
|
193 |
<tr> |
|
194 |
<td><?=gettext("Gathering data, please wait...")?></td> |
|
195 |
</tr> |
|
196 |
</tbody> |
|
197 |
</table> |
|
198 |
</div> |
|
199 |
</div> |
|
235 | 200 |
|
201 |
<div class="panel panel-default"> |
|
202 |
<div class="panel-heading">IPv6 Routes</div> |
|
203 |
<div class="panel panel-body"> |
|
204 |
<table class="table table-striped table-compact" id="IPv6"> |
|
205 |
<thead> |
|
206 |
<!-- filled by xhr --> |
|
207 |
</thead> |
|
208 |
<tbody> |
|
209 |
<tr> |
|
210 |
<td><?=gettext("Gathering data, please wait...")?></td> |
|
211 |
</tr> |
|
212 |
</tbody> |
|
213 |
</table> |
|
214 |
</div> |
|
236 | 215 |
</div> |
237 | 216 |
|
238 |
<?php include("foot.inc"); ?>
|
|
217 |
<?php include("foot.inc"); |
Also available in: Unified diff
Completed diag_routes, add panels, fix generated tables
refs #91