From b121d075f44dca1256e2c840387349bcf23fa3d7 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 11 Apr 2019 13:28:46 +0200 Subject: [PATCH] Routing, gateways, widget api call ditch return_gateways_array() usage and don't try to resolve addresses twice. for https://github.com/opnsense/core/issues/2279 --- src/www/widgets/api/plugins/gateway.inc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/www/widgets/api/plugins/gateway.inc b/src/www/widgets/api/plugins/gateway.inc index 21d5f421a..d53b480b2 100644 --- a/src/www/widgets/api/plugins/gateway.inc +++ b/src/www/widgets/api/plugins/gateway.inc @@ -33,10 +33,10 @@ function gateway_api() { $result = array(); $gateways_status = return_gateways_status(); - foreach (return_gateways_array() as $gname => $gw) { + foreach ((new \OPNsense\Routing\Gateways(legacy_interfaces_details()))->gatewaysIndexedByName() as $gname => $gw) { $gatewayItem = array('name' => $gname); + $gatewayItem['address'] = !empty($gw['gateway']) ? $gw['gateway'] : "~"; if (!empty($gateways_status[$gname])) { - $gatewayItem['address'] = lookup_gateway_ip_by_name($gname); $gatewayItem['status'] = strtolower($gateways_status[$gname]['status']); $gatewayItem['loss'] = $gateways_status[$gname]['loss']; $gatewayItem['delay'] = $gateways_status[$gname]['delay']; @@ -62,7 +62,6 @@ function gateway_api() break; } } else { - $gatewayItem['address'] = '~'; $gatewayItem['status'] = '~'; $gatewayItem['status_translated'] = gettext('Unknown'); $gatewayItem['loss'] = '~';