261 |
261 |
}
|
262 |
262 |
|
263 |
263 |
// Determine if firewall rules are defined
|
264 |
|
$pfb_packets = pfSense_get_pf_rules();
|
265 |
264 |
if (isset($config['filter']['rule'])) {
|
266 |
|
foreach ($config['filter']['rule'] as $rule) {
|
|
265 |
$tracked_rules = array();
|
267 |
266 |
|
|
267 |
// Get the relevant pfB rules
|
|
268 |
foreach ($config['filter']['rule'] as $rule) {
|
268 |
269 |
if (strpos($rule['descr'], 'pfB_DNSBL_Ping') !== FALSE || strpos($rule['descr'], 'pfB_DNSBL_Permit') !== FALSE) {
|
269 |
270 |
continue;
|
270 |
271 |
}
|
271 |
272 |
|
272 |
|
if (isset($rule['source']['address']) && stripos($rule['source']['address'], 'pfb_') !== FALSE) {
|
273 |
|
foreach ($pfb_packets as $pkey => $prule) {
|
274 |
|
if ($rule['tracker'] == $prule['tracker']) {
|
275 |
|
if (!isset($pfb_table[$rule['source']['address']]['packets'])) {
|
276 |
|
$pfb_table[$rule['source']['address']]['packets'] = 0;
|
277 |
|
}
|
278 |
|
if (isset($prule['packets']) && $prule['packets'] > 0) {
|
279 |
|
$pfb_table[$rule['source']['address']]['packets'] += $prule['packets'];
|
280 |
|
}
|
281 |
|
unset($pfb_packets[$pkey]);
|
282 |
|
break;
|
283 |
|
}
|
284 |
|
}
|
|
273 |
$tracked_rules[$rule['tracker']] = array('packets' => 0);
|
285 |
274 |
|
|
275 |
if (isset($rule['source']['address']) && stripos($rule['source']['address'], 'pfb_') !== FALSE) {
|
|
276 |
$tracked_rules[$rule['tracker']]['source'] = $rule['source']['address'];
|
286 |
277 |
if (!isset($rule['disabled'])) {
|
287 |
278 |
$pfb_table[$rule['source']['address']]['img'] = $pfb['up'];
|
288 |
279 |
$pfb_table[$rule['source']['address']]['rule'] += 1;
|
|
280 |
if (!isset($pfb_table[$rule['source']['address']]['packets'])) {
|
|
281 |
$pfb_table[$rule['source']['address']]['packets'] = 0;
|
|
282 |
}
|
289 |
283 |
$pfb_table[$rule['source']['address']]['type'] = ucfirst($rule['type']) ?: 'unknown';
|
290 |
284 |
}
|
291 |
285 |
}
|
|
286 |
|
292 |
287 |
if (isset($rule['destination']['address']) && stripos($rule['destination']['address'], 'pfb_') !== FALSE) {
|
293 |
|
foreach ($pfb_packets as $pkey => $prule) {
|
294 |
|
if ($rule['tracker'] == $prule['tracker']) {
|
295 |
|
if (!isset($pfb_table[$rule['destination']['address']]['packets'])) {
|
296 |
|
$pfb_table[$rule['destination']['address']]['packets'] = 0;
|
297 |
|
}
|
298 |
|
if (isset($prule['packets']) && $prule['packets'] > 0) {
|
299 |
|
$pfb_table[$rule['destination']['address']]['packets'] += $prule['packets'];
|
300 |
|
}
|
301 |
|
unset($pfb_packets[$pkey]);
|
302 |
|
break;
|
303 |
|
}
|
304 |
|
}
|
305 |
|
|
|
288 |
$tracked_rules[$rule['tracker']]['destination'] = $rule['destination']['address'];
|
306 |
289 |
if (!isset($rule['disabled'])) {
|
307 |
290 |
$pfb_table[$rule['destination']['address']]['img'] = $pfb['up'];
|
308 |
291 |
$pfb_table[$rule['destination']['address']]['rule'] += 1;
|
|
292 |
if (!isset($pfb_table[$rule['destination']['address']]['packets'])) {
|
|
293 |
$pfb_table[$rule['destination']['address']]['packets'] = 0;
|
|
294 |
}
|
309 |
295 |
$pfb_table[$rule['destination']['address']]['type'] = ucfirst($rule['type']) ?: 'unknown';
|
310 |
296 |
}
|
311 |
297 |
}
|
312 |
298 |
}
|
|
299 |
|
|
300 |
// Get the packet count for each pfB rule
|
|
301 |
if (!empty($tracked_rules)) {
|
|
302 |
foreach (pfSense_get_pf_rules() as $prule) {
|
|
303 |
$prule_id = $prule['tracker'];
|
|
304 |
if (isset($tracked_rules[$prule_id])) {
|
|
305 |
if (isset($prule['packets']) && $prule['packets'] > 0) {
|
|
306 |
if (isset($tracked_rules[$prule_id]['source'])) {
|
|
307 |
$pfb_table[$tracked_rules[$prule_id]['source']]['packets'] += $prule['packets'];
|
|
308 |
}
|
|
309 |
if (isset($tracked_rules[$prule_id]['destination'])) {
|
|
310 |
$pfb_table[$tracked_rules[$prule_id]['destination']]['packets'] += $prule['packets'];
|
|
311 |
}
|
|
312 |
}
|
|
313 |
}
|
|
314 |
}
|
|
315 |
}
|
313 |
316 |
}
|
314 |
317 |
|
315 |
318 |
// Collect pfB Alias ID for popup
|