From 8512e90a92ae19cfae7ebf829cd9f37fc538b26c Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Fri, 30 Oct 2015 12:26:17 -0500 Subject: Make IPsec status page retrieve status with VICI instead of SMP --- usr/local/www/diag_ipsec.php | 224 ++++++++++++++++++++++--------------------- 1 file changed, 117 insertions(+), 107 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/diag_ipsec.php b/usr/local/www/diag_ipsec.php index 460a23d..e1fbfdf 100644 --- a/usr/local/www/diag_ipsec.php +++ b/usr/local/www/diag_ipsec.php @@ -89,7 +89,7 @@ if (!is_array($config['ipsec']['phase1'])) $a_phase1 = &$config['ipsec']['phase1']; -$status = ipsec_smp_dump_status(); +$status = pfSense_ipsec_list_sa(); ?> @@ -131,9 +131,9 @@ $status = ipsec_smp_dump_status(); $ikesa): - $con_id = substr($ikesa['peerconfig'], 3); + if (is_array($status)) { + foreach ($status as $ikeid => $ikesa) { + $con_id = substr($ikeid, 3); if ($ikesa['version'] == 1) { $ph1idx = substr($con_id, 0, strrpos(substr($con_id, 0, -1), '00')); $ipsecconnected[$ph1idx] = $ph1idx; @@ -141,12 +141,13 @@ $status = ipsec_smp_dump_status(); $ipsecconnected[$con_id] = $ph1idx = $con_id; } - if (ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ikesa['id'])) + if ($ikesa['state'] == "ESTABLISHED") { $icon = "pass"; - elseif (!isset($config['ipsec']['enable'])) + } elseif (!isset($config['ipsec']['enable'])) { $icon = "block"; - else + } else { $icon = "reject"; + } ?> @@ -156,71 +157,67 @@ $status = ipsec_smp_dump_status(); ' . + gettext('Port: ') . htmlspecialchars($ikesa['local-port']); + } else { echo gettext("Unknown"); - else { - if (!empty($ikesa['local']['address'])) - echo htmlspecialchars($ikesa['local']['address']) . '
' . - gettext('Port: ') . htmlspecialchars($ikesa['local']['port']); - else - echo gettext("Unknown"); - if ($ikesa['local']['port'] == '4500') - echo " NAT-T"; } + if ($ikesa['local-port'] == '4500') { + echo " NAT-T"; + } + ?> {$identity}"; + $identity = ""; + if (!empty($ikesa['remote-id'])) { + if ($ikesa['remote-id'] == '%any') { + $identity = 'Any identifier'; } else { - if (empty($identity)) - echo gettext("Unknown"); - else - echo $identity; + $identity = htmlspecialchars($ikesa['remote-id']); } } + if (!empty($ikesa['remote-xauth-id'])) { + echo htmlspecialchars($ikesa['remote-xauth-id']); + echo "
{$identity}"; + } elseif (!empty($ikesa['remote-eap-id'])) { + echo htmlspecialchars($ikesa['remote-eap-id']); + echo "
{$identity}"; + } else { + if (empty($identity)) + echo gettext("Unknown"); + else + echo $identity; + } + ?> ' . + gettext('Port: ') . htmlspecialchars($ikesa['remote-port']); + } else { echo gettext("Unknown"); - else { - if (!empty($ikesa['remote']['address'])) - echo htmlspecialchars($ikesa['remote']['address']) . '
' . - gettext('Port: ') . htmlspecialchars($ikesa['remote']['port']); - else - echo gettext("Unknown"); - if ($ikesa['remote']['port'] == '4500') - echo " NAT-T"; + } + if ($ikesa['remote-port'] == '4500') { + echo " NAT-T"; } ?> @@ -228,35 +225,39 @@ $status = ipsec_smp_dump_status(); IKEv
"; - echo htmlspecialchars($ikesa['intalg']); + echo htmlspecialchars($ikesa['integ-alg']); echo "
"; - echo htmlspecialchars($ikesa['prfalg']); + echo htmlspecialchars($ikesa['prf-alg']); echo "
"; - echo htmlspecialchars($ikesa['dhgroup']); + echo htmlspecialchars($ikesa['dh-group']); ?>
-
-
+
+
@@ -264,18 +265,18 @@ $status = ipsec_smp_dump_status();
<?php title= border="0"/> - + <?php title= border="0"/>
@@ -284,7 +285,7 @@ $status = ipsec_smp_dump_status(); @@ -304,78 +305,85 @@ $status = ipsec_smp_dump_status(); $childsa) { ?> "; - else + } + } else { echo gettext("Unknown"); + } ?> " . gettext("Remote: ") . htmlspecialchars($childsa['remote']['spi']); + if (isset($childsa['spi-in'])) { + echo gettext("Local: ") . htmlspecialchars($childsa['spi-in']); + } + if (is_array($childsa['spi-out'])) { + echo "
" . gettext("Remote: ") . htmlspecialchars($childsa['spi-out']); + } ?> "; - else + } + } else { echo gettext("Unknown"); + } ?> " . gettext("Life: ") . htmlspecialchars($childsa['lifetime']); - echo "
" . gettext("Install: ") .htmlspecialchars($childsa['installtime']); + echo gettext("Rekey: ") . htmlspecialchars($childsa['rekey-time']) . gettext(" seconds"); + echo "
" . gettext("Life: ") . htmlspecialchars($childsa['life-time']) . gettext(" seconds"); + echo "
" . gettext("Install: ") .htmlspecialchars($childsa['install-time']) . gettext(" seconds"); ?> "; - echo htmlspecialchars($childsa['intalg']); + echo htmlspecialchars($childsa['integ-alg']); echo "
"; - if (!empty($childsa['prfalg'])) { - echo htmlspecialchars($childsa['prfalg']); + if (!empty($childsa['prf-alg'])) { + echo htmlspecialchars($childsa['prf-alg']); echo "
"; } - if (!empty($childsa['dhgroup'])) { - echo htmlspecialchars($childsa['dhgroup']); + if (!empty($childsa['dh-group'])) { + echo htmlspecialchars($childsa['dh-group']); echo "
"; } if (!empty($childsa['esn'])) { echo htmlspecialchars($childsa['esn']); echo "
"; } - echo gettext("IPComp: ") . htmlspecialchars($childsa['ipcomp']); + echo gettext("IPComp: "); + if (!empty($childsa['cpi-in']) || !empty($childsa['cpi-out'])) { + echo htmlspecialchars($childsa['cpi-in']) . " " . htmlspecialchars($childsa['cpi-out']); + } else { + echo gettext("none"); + } ?> "; - echo gettext("Packets-In: ") . htmlspecialchars($childsa['packetsin']); + echo gettext("Packets-In: ") . htmlspecialchars($childsa['packets-in']); echo "
"; - echo gettext("Bytes-Out: ") . htmlspecialchars($childsa['bytesout']); + echo gettext("Bytes-Out: ") . htmlspecialchars($childsa['bytes-out']); echo "
"; - echo gettext("Packets-Out: ") . htmlspecialchars($childsa['packetsout']); + echo gettext("Packets-Out: ") . htmlspecialchars($childsa['packets-out']); ?> @@ -390,8 +398,8 @@ $status = ipsec_smp_dump_status(); @@ -399,19 +407,21 @@ $status = ipsec_smp_dump_status(); @@ -462,7 +472,7 @@ $status = ipsec_smp_dump_status();
@@ -475,7 +485,7 @@ $status = ipsec_smp_dump_status();
@@ -491,7 +501,7 @@ $status = ipsec_smp_dump_status();
@@ -499,7 +509,7 @@ $status = ipsec_smp_dump_status(); -- cgit v1.1