Commit 504c0762 authored by Franco Fichtner's avatar Franco Fichtner

ipsec: fix crash reports

parent 307d9238
...@@ -72,27 +72,33 @@ if (isset($config['ipsec']['phase1'])) { ...@@ -72,27 +72,33 @@ if (isset($config['ipsec']['phase1'])) {
} }
$ipsec_leases = json_decode(configd_run("ipsec list leases"), true); $ipsec_leases = json_decode(configd_run("ipsec list leases"), true);
if ($ipsec_leases == null) {
$ipsec_leases = array();
}
// parse configured tunnels
$ipsec_status = json_decode(configd_run("ipsec list status"), true); $ipsec_status = json_decode(configd_run("ipsec list status"), true);
if ($ipsec_status == null) {
$ipsec_status = array();
}
// parse configured tunnels
$activetunnels = 0; $activetunnels = 0;
if ($ipsec_status != null) {
foreach ($ipsec_status as $status_key => $status_value) { foreach ($ipsec_status as $status_key => $status_value) {
if (isset($status_value['children'])) { if (isset($status_value['children'])) {
foreach($status_value['children'] as $child_status_key => $child_status_value) { foreach($status_value['children'] as $child_status_key => $child_status_value) {
$ipsec_tunnels[$child_status_key] = array('active' => false, $ipsec_tunnels[$child_status_key] = array('active' => false,
'local-addrs' => $status_value['local-addrs'], 'local-addrs' => $status_value['local-addrs'],
'remote-addrs' => $status_value['remote-addrs'], 'remote-addrs' => $status_value['remote-addrs'],
); );
$ipsec_tunnels[$child_status_key]['local-ts'] = implode(',', $child_status_value['local-ts']); $ipsec_tunnels[$child_status_key]['local-ts'] = implode(',', $child_status_value['local-ts']);
$ipsec_tunnels[$child_status_key]['remote-ts'] = implode(',', $child_status_value['remote-ts']); $ipsec_tunnels[$child_status_key]['remote-ts'] = implode(',', $child_status_value['remote-ts']);
} }
} }
foreach ($status_value['sas'] as $sas_key => $sas_value) { foreach ($status_value['sas'] as $sas_key => $sas_value) {
foreach ($sas_value['child-sas'] as $child_sa_key => $child_sa_value) { foreach ($sas_value['child-sas'] as $child_sa_key => $child_sa_value) {
$ipsec_tunnels[$child_sa_key]['active'] = true; $ipsec_tunnels[$child_sa_key]['active'] = true;
$activetunnels++; $activetunnels++;
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment