diff options
Diffstat (limited to 'usr/local/www/diag_states_summary.php')
-rw-r--r-- | usr/local/www/diag_states_summary.php | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/usr/local/www/diag_states_summary.php b/usr/local/www/diag_states_summary.php index e5ca55e..37c4243 100644 --- a/usr/local/www/diag_states_summary.php +++ b/usr/local/www/diag_states_summary.php @@ -82,36 +82,25 @@ if(count($states) > 0) { /* Handle IPv6 */ $parts = explode(":", $srcinfo); - $partcount = count($parts) -1; - $partsip = $parts; - if($partcount == 1) { - array_pop($partsip); + $partcount = count($parts); + if ($partcount <= 2) { + $srcip = trim($parts[0]); + $srcport = trim($parts[1]); } else { - $srcip = trim(preg_replace("/\[[0-9]+\]/i", "", implode(":", $partsip))); + preg_match("/([0-9a-f:]+)(\[([0-9]+)\])?/i", $srcinfo, $matches); + $srcip = $matches[1]; + $srcport = trim($matches[3]); } - if($partcount > 1) { - preg_match("/\[[0-9]+\]/i", $parts[$partcount], $matches); - $srcport = $matches[0]; - // $srcport = trim($parts[$partcount]); - } else { - $srcport = trim($parts[$partcount]); - } - - + $parts = explode(":", $dstinfo); - $partsip = $parts; - $partcount = count($parts) -1; - if($partcount == 1) { - array_pop($partsip); - } else { - $dstip = trim(preg_replace("/\[[0-9]+\]/i", "", implode(":", $partsip))); - } - if($partcount > 1) { - preg_match("/\[[0-9]+\]/i", $parts[$partcount], $matches); - $dstport = $matches[0]; - // $dstport = trim($parts[$partcount]); + $partcount = count($parts); + if ($partcount <= 2) { + $dstip = trim($parts[0]); + $dstport = trim($parts[1]); } else { - $dstport = trim($parts[$partcount]); + preg_match("/([0-9a-f:]+)(\[([0-9]+)\])?/i", $dstinfo, $matches); + $dstip = $matches[1]; + $dstport = trim($matches[3]); } addipinfo($srcipinfo, $srcip, $proto, $srcport, $dstport); |