From 723507231566b61750e32284b49acdae0d0162d3 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Tue, 2 Apr 2024 00:34:42 +0200 Subject: luci-mod-network: add DHCPv6 NTP server config helper to interfaces Appears under DHCPv6-service when set to 'server' or 'hybrid'. Option 'ntp' is serviced by odhcpd. It sends a DHCPv6 NTP Server option 56 for each 'ntp' list entry. Once uci loads the system section, it provides suggestion presets of system configured upstream NTP servers, and the LAN IP(v6) of the router which are then statically configured by the user. It would make more sense if odhcpd fetches them directly. Alas, it does not (yet). Signed-off-by: Paul Donald --- .../resources/view/network/interfaces.js | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'modules/luci-mod-network/htdocs/luci-static') diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js index fd7487b3de..b826ccb094 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js @@ -502,7 +502,8 @@ return view.extend({ s.load = function() { return Promise.all([ network.getNetworks(), - firewall.getZones() + firewall.getZones(), + uci.load('system') ]).then(L.bind(function(data) { this.networks = data[0]; this.zones = data[1]; @@ -988,6 +989,27 @@ return view.extend({ so.depends('dhcpv6', 'server'); so.depends({ dhcpv6: 'hybrid', master: '0' }); + //This is a DHCPv6 specific odhcpd setting + so = ss.taboption('ipv6', form.DynamicList, 'ntp', _('NTP Servers'), + _('DHCPv6 option 56. %s.', 'DHCPv6 option 56. RFC5908 link').format('RFC5908').format('https://www.rfc-editor.org/rfc/rfc5908#section-4')); + so.datatype = 'host(0)'; + for(var x of uci.get('system', 'ntp', 'server') || '') { + so.value(x); + } + var lan_net = this.networks.filter(function(n) { return n.getName() == 'lan' })[0]; + // If ntpd is set up, suggest our IP(v6) also + if(uci.get('system', 'ntp', 'enable_server')) { + lan_net.getIPAddrs().forEach(function(i4) { + so.value(i4.split('/')[0]); + }); + lan_net.getIP6Addrs().forEach(function(i6) { + so.value(i6.split('/')[0]); + }); + } + so.optional = true; + so.rmempty = true; + so.depends('dhcpv6', 'server'); + so.depends({ dhcpv6: 'hybrid', master: '0' }); so = ss.taboption('ipv6', cbiRichListValue, 'ndp', _('NDP-Proxy'), _('Configures the operation mode of the NDP proxy service on this interface.')); -- cgit v1.2.3