From: Jo-Philipp Wich Date: Tue, 22 Oct 2019 20:38:09 +0000 (+0200) Subject: luci-base: network.js: implement Protocol.getGateway6Addr() X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=199428a9c3fdff57f80afaeb33be615a37bb3f81;p=oweals%2Fluci.git luci-base: network.js: implement Protocol.getGateway6Addr() Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js index c5b0c3027..5fa6167b2 100644 --- a/modules/luci-base/htdocs/luci-static/resources/network.js +++ b/modules/luci-base/htdocs/luci-static/resources/network.js @@ -2158,6 +2158,27 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { return rv; }, + /** + * Query the gateway (nexthop) of the IPv6 default route associated with + * this logical interface. + * + * @returns {string} + * Returns a string containing the IPv6 nexthop address of the associated + * default route or `null` if no default route was found. + */ + getGateway6Addr: function() { + var routes = this._ubus('route'); + + if (Array.isArray(routes)) + for (var i = 0; i < routes.length; i++) + if (typeof(routes[i]) == 'object' && + routes[i].target == '::' && + routes[i].mask == 0) + return routes[i].nexthop; + + return null; + }, + /** * Query the IPv6 DNS servers associated with the logical interface. *