From 199428a9c3fdff57f80afaeb33be615a37bb3f81 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 22 Oct 2019 22:38:09 +0200 Subject: luci-base: network.js: implement Protocol.getGateway6Addr() Signed-off-by: Jo-Philipp Wich --- .../htdocs/luci-static/resources/network.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules/luci-base/htdocs') diff --git a/modules/luci-base/htdocs/luci-static/resources/network.js b/modules/luci-base/htdocs/luci-static/resources/network.js index c5b0c3027d..5fa6167b27 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. * -- cgit v1.2.3