luci-base: network.js: implement Protocol.getGateway6Addr() 3231/head 3232/head
authorJo-Philipp Wich <jo@mein.io>
Tue, 22 Oct 2019 20:38:09 +0000 (22:38 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 22 Oct 2019 20:38:29 +0000 (22:38 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/network.js

index c5b0c3027d30bc0d9ddd1cfb61ec4fa0f75c8f47..5fa6167b27484522f282aa4853545228568b2895 100644 (file)
@@ -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.
         *