From dc70f9ec236e60ad4ea4a9b727f86e3eed2892c0 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 27 Jun 2024 20:34:02 +0200 Subject: [PATCH] luci-mod-network: Add Set Tags (via Match (Option+Value)) tab. This regards the confusingly named 'match' entries. Signed-off-by: Paul Donald --- .../resources/view/network/dhcp.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 600759da2b93..15ea0eb8dc02 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -325,6 +325,16 @@ return view.extend({ tagcodestring:'tag', tag_named_ov_string: 'option(6):<opt-name>,[<value>[,<value>]]', + //match tags + dhcp_option_code: 'option(6)', + dhcp_optioncolon_code: 'option(6):', + dhcp_option_client_arch: 'option:client-arch,6', + dhcp_value_code: ',value', + tag_match_code_name: 'match', + tag_match_option_syntax: '<option number>|option:<option name>[,<value>]', + tag_name_efi_ia32: 'efi-ia32', + wildcard_code: '*', + }; function customi18n(template, values) { @@ -391,6 +401,7 @@ return view.extend({ s.tab('matchtags', _('Match Tags')); s.tab('vc', _('VC')); s.tab('uc', _('UC')); + s.tab('settags', _('Set Tags')); s.taboption('filteropts', form.Flag, 'domainneeded', _('Domain required'), @@ -1275,6 +1286,41 @@ return view.extend({ so.rmempty = false; so.optional = true; + o = s.taboption('settags', form.SectionValue, '__settags__', form.TableSection, 'match', null, + customi18n( _('Encountering chosen DHCP {dhcp_option_code}s (or also its {dhcp_value_code}) from clients triggers dnsmasq to set alphanumeric {tagcodestring}s.')) + '
' + + customi18n( _('In other words: "{tag_match_code_name} these {dhcp_option_code}s to set this {tagcodestring}" or "These {dhcp_option_code}s set this {tagcodestring}".')) + '
' + + customi18n( _('Internally, these configuration entries are called {tag_match_code_name}.')) + '
' + + customi18n( _('Matching option syntax: {tag_match_option_syntax}.')) + ' ' + + customi18n( _('Prefix named (IPv6) options with {dhcp_optioncolon_code}.')) + ' ' + + customi18n( _('Wildcards ({wildcard_code}) allowed.')) + '

' + + customi18n( _('Match {dhcp_option_client_arch}, Tag {tag_name_efi_ia32}, sets tag {tag_name_efi_ia32}')) + ' ' + + _('when number %s appears in the list of architectures sent by the client in option %s.').format('6', '93') + '
' + + customi18n( _('Use the %s Button to add a new {tag_match_code_name}.').format(_('Add'))) ); + ss = o.subsection; + ss.addremove = true; + ss.anonymous = true; + ss.sortable = true; + ss.nodescriptions = true; + ss.modaltitle = _('Edit Match'); + ss.rowcolors = true; + + so = ss.option(form.Value, 'match', _('Match this client option(+value)...')); + so.rmempty = false; + so.optional = false; + so.placeholder = '61,8c:80:90:01:02:03'; + + so = ss.option(form.Value, 'networkid', _('...to Set this Tag')); + so.rmempty = false; + so.optional = false; + so.placeholder = 'myuniqueclientid' + + so = ss.option(form.Flag, 'force', + _('Force'), + _('Send options to clients that did not request them.')); + so.rmempty = false; + so.optional = true; + + o = s.taboption('leases', CBILeaseStatus, '__status__'); if (has_dhcpv6)