Révision c245a846
Ajouté par jim-p il y a plus de 9 ans
usr/local/www/diag_states_summary.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
/* |
3 | 3 |
diag_states_summary.php |
4 |
Copyright (C) 2010 Jim Pingle |
|
4 |
Copyright (C) 2010-2014 Jim Pingle
|
|
5 | 5 |
|
6 | 6 |
Portions borrowed from diag_dump_states.php: |
7 | 7 |
Copyright (C) 2005-2009 Scott Ullrich |
... | ... | |
64 | 64 |
if(count($states) > 0) { |
65 | 65 |
foreach($states as $line) { |
66 | 66 |
$line_split = preg_split("/\s+/", $line); |
67 |
$type = array_shift($line_split);
|
|
67 |
$iface = array_shift($line_split);
|
|
68 | 68 |
$proto = array_shift($line_split); |
69 | 69 |
$state = array_pop($line_split); |
70 | 70 |
$info = implode(" ", $line_split); |
71 | 71 |
|
72 |
/* Handle NAT cases |
|
73 |
Replaces an external IP + NAT by the internal IP */ |
|
74 |
if (strpos($info, ') ->') !== FALSE) { |
|
75 |
/* Outbound NAT */ |
|
76 |
$info = preg_replace('/(\S+) \((\S+)\)/U', "$2", $info); |
|
77 |
} elseif (strpos($info, ') <-') !== FALSE) { |
|
78 |
/* Inbound NAT/Port Forward */ |
|
79 |
$info = preg_replace('/(\S+) \((\S+)\)/U', "$1", $info); |
|
80 |
} |
|
81 |
|
|
72 | 82 |
/* break up info and extract $srcip and $dstip */ |
73 | 83 |
$ends = preg_split("/\<?-\>?/", $info); |
74 | 84 |
|
... | ... | |
82 | 92 |
|
83 | 93 |
/* Handle IPv6 */ |
84 | 94 |
$parts = explode(":", $srcinfo); |
85 |
$partcount = count($parts);
|
|
95 |
$partcount = count($parts); |
|
86 | 96 |
if ($partcount <= 2) { |
87 | 97 |
$srcip = trim($parts[0]); |
88 | 98 |
$srcport = trim($parts[1]); |
... | ... | |
91 | 101 |
$srcip = $matches[1]; |
92 | 102 |
$srcport = trim($matches[3]); |
93 | 103 |
} |
94 |
|
|
104 |
|
|
95 | 105 |
$parts = explode(":", $dstinfo); |
96 |
$partcount = count($parts);
|
|
106 |
$partcount = count($parts); |
|
97 | 107 |
if ($partcount <= 2) { |
98 | 108 |
$dstip = trim($parts[0]); |
99 | 109 |
$dstport = trim($parts[1]); |
Formats disponibles : Unified diff
Adjust states summary for new pfctl -ss output. Fixes #2121