Skip to content

Commit

Permalink
feat(client): classify DNS Rule fields
Browse files Browse the repository at this point in the history
  • Loading branch information
muink committed Jul 27, 2024
1 parent 33bf382 commit 6478327
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions htdocs/luci-static/resources/view/homeproxy/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,17 +758,23 @@ return view.extend({
ss.sectiontitle = L.bind(hp.loadDefaultLabel, this, data[0]);
ss.renderSectionAdd = L.bind(hp.renderSectionAdd, this, ss);

so = ss.option(form.Value, 'label', _('Label'));
ss.tab('field_other', _('Other Fields'));
ss.tab('field_host', _('Host Fields'));
ss.tab('field_port', _('Port Fields'));
ss.tab('field_source_ip', _('SRC-IP Fields'));
ss.tab('field_source_port', _('SRC-Port Fields'));

so = ss.taboption('field_other', form.Value, 'label', _('Label'));
so.load = L.bind(hp.loadDefaultLabel, this, data[0]);
so.validate = L.bind(hp.validateUniqueValue, this, data[0], 'dns_rule', 'label');
so.modalonly = true;

so = ss.option(form.Flag, 'enabled', _('Enable'));
so = ss.taboption('field_other', form.Flag, 'enabled', _('Enable'));
so.default = so.enabled;
so.rmempty = false;
so.editable = true;

so = ss.option(form.ListValue, 'mode', _('Mode'),
so = ss.taboption('field_other', form.ListValue, 'mode', _('Mode'),
_('The default rule uses the following matching logic:<br/>' +
'<code>(domain || domain_suffix || domain_keyword || domain_regex)</code> &&<br/>' +
'<code>(port || port_range)</code> &&<br/>' +
Expand All @@ -781,99 +787,99 @@ return view.extend({
so.rmempty = false;
so.readonly = true;

so = ss.option(form.ListValue, 'ip_version', _('IP version'));
so = ss.taboption('field_other', form.ListValue, 'ip_version', _('IP version'));
so.value('4', _('IPv4'));
so.value('6', _('IPv6'));
so.value('', _('Both'));
so.modalonly = true;

so = ss.option(form.DynamicList, 'query_type', _('Query type'),
so = ss.taboption('field_other', form.DynamicList, 'query_type', _('Query type'),
_('Match query type.'));
so.modalonly = true;

so = ss.option(form.ListValue, 'network', _('Network'));
so = ss.taboption('field_other', form.ListValue, 'network', _('Network'));
so.value('tcp', _('TCP'));
so.value('udp', _('UDP'));
so.value('', _('Both'));

so = ss.option(form.MultiValue, 'protocol', _('Protocol'),
so = ss.taboption('field_other', form.MultiValue, 'protocol', _('Protocol'),
_('Sniffed protocol, see <a target="_blank" href="https://sing-box.sagernet.org/configuration/route/sniff/">Sniff</a> for details.'));
so.value('http', _('HTTP'));
so.value('tls', _('TLS'));
so.value('quic', _('QUIC'));
so.value('dns', _('DNS'));
so.value('stun', _('STUN'));

so = ss.option(form.DynamicList, 'domain', _('Domain name'),
so = ss.taboption('field_host', form.DynamicList, 'domain', _('Domain name'),
_('Match full domain.'));
so.datatype = 'hostname';
so.modalonly = true;

so = ss.option(form.DynamicList, 'domain_suffix', _('Domain suffix'),
so = ss.taboption('field_host', form.DynamicList, 'domain_suffix', _('Domain suffix'),
_('Match domain suffix.'));
so.modalonly = true;

so = ss.option(form.DynamicList, 'domain_keyword', _('Domain keyword'),
so = ss.taboption('field_host', form.DynamicList, 'domain_keyword', _('Domain keyword'),
_('Match domain using keyword.'));
so.modalonly = true;

so = ss.option(form.DynamicList, 'domain_regex', _('Domain regex'),
so = ss.taboption('field_host', form.DynamicList, 'domain_regex', _('Domain regex'),
_('Match domain using regular expression.'));
so.modalonly = true;

so = ss.option(form.DynamicList, 'port', _('Port'),
so = ss.taboption('field_port', form.DynamicList, 'port', _('Port'),
_('Match port.'));
so.datatype = 'port';
so.modalonly = true;

so = ss.option(form.DynamicList, 'port_range', _('Port range'),
so = ss.taboption('field_port', form.DynamicList, 'port_range', _('Port range'),
_('Match port range. Format as START:/:END/START:END.'));
so.validate = validatePortRange;
so.modalonly = true;

so = ss.option(form.DynamicList, 'source_ip_cidr', _('Source IP CIDR'),
so = ss.taboption('field_source_ip', form.DynamicList, 'source_ip_cidr', _('Source IP CIDR'),
_('Match source IP CIDR.'));
so.datatype = 'or(cidr, ipaddr)';
so.modalonly = true;

so = ss.option(form.Flag, 'source_ip_is_private', _('Private source IP'),
so = ss.taboption('field_source_ip', form.Flag, 'source_ip_is_private', _('Private source IP'),
_('Match private source IP.'));
so.default = so.disabled;
so.modalonly = true;

so = ss.option(form.DynamicList, 'ip_cidr', _('IP CIDR'),
so = ss.taboption('field_other', form.DynamicList, 'ip_cidr', _('IP CIDR'),
_('Match IP CIDR with query response.'));
so.datatype = 'or(cidr, ipaddr)';
so.modalonly = true;

so = ss.option(form.Flag, 'ip_is_private', _('Private IP'),
so = ss.taboption('field_other', form.Flag, 'ip_is_private', _('Private IP'),
_('Match private IP with query response.'));
so.default = so.disabled;
so.modalonly = true;

so = ss.option(form.DynamicList, 'source_port', _('Source port'),
so = ss.taboption('field_source_port', form.DynamicList, 'source_port', _('Source port'),
_('Match source port.'));
so.datatype = 'port';
so.modalonly = true;

so = ss.option(form.DynamicList, 'source_port_range', _('Source port range'),
so = ss.taboption('field_source_port', form.DynamicList, 'source_port_range', _('Source port range'),
_('Match source port range. Format as START:/:END/START:END.'));
so.validate = validatePortRange;
so.modalonly = true;

so = ss.option(form.DynamicList, 'process_name', _('Process name'),
so = ss.taboption('field_other', form.DynamicList, 'process_name', _('Process name'),
_('Match process name.'));
so.modalonly = true;

so = ss.option(form.DynamicList, 'process_path', _('Process path'),
so = ss.taboption('field_other', form.DynamicList, 'process_path', _('Process path'),
_('Match process path.'));
so.modalonly = true;

so = ss.option(form.DynamicList, 'user', _('User'),
so = ss.taboption('field_other', form.DynamicList, 'user', _('User'),
_('Match user name.'));
so.modalonly = true;

so = ss.option(form.MultiValue, 'rule_set', _('Rule set'),
so = ss.taboption('field_other', form.MultiValue, 'rule_set', _('Rule set'),
_('Match rule set.'));
so.load = function(section_id) {
delete this.keylist;
Expand All @@ -889,17 +895,17 @@ return view.extend({
}
so.modalonly = true;

so = ss.option(form.Flag, 'rule_set_ipcidr_match_source', _('Rule set IP CIDR as source IP'),
so = ss.taboption('field_other', form.Flag, 'rule_set_ipcidr_match_source', _('Rule set IP CIDR as source IP'),
_('Make <code>ipcidr</code> in rule sets match the source IP.'));
so.default = so.disabled;
so.modalonly = true;

so = ss.option(form.Flag, 'invert', _('Invert'),
so = ss.taboption('field_other', form.Flag, 'invert', _('Invert'),
_('Invert match result.'));
so.default = so.disabled;
so.modalonly = true;

so = ss.option(form.MultiValue, 'outbound', _('Outbound'),
so = ss.taboption('field_other', form.MultiValue, 'outbound', _('Outbound'),
_('Match outbound.'));
so.load = function(section_id) {
delete this.keylist;
Expand All @@ -917,7 +923,7 @@ return view.extend({
}
so.modalonly = true;

so = ss.option(form.ListValue, 'server', _('Server'),
so = ss.taboption('field_other', form.ListValue, 'server', _('Server'),
_('Tag of the target dns server.'));
so.load = function(section_id) {
delete this.keylist;
Expand All @@ -936,17 +942,17 @@ return view.extend({
so.rmempty = false;
so.editable = true;

so = ss.option(form.Flag, 'dns_disable_cache', _('Disable dns cache'),
so = ss.taboption('field_other', form.Flag, 'dns_disable_cache', _('Disable dns cache'),
_('Disable cache and save cache in this query.'));
so.default = so.disabled;
so.modalonly = true;

so = ss.option(form.Value, 'rewrite_ttl', _('Rewrite TTL'),
so = ss.taboption('field_other', form.Value, 'rewrite_ttl', _('Rewrite TTL'),
_('Rewrite TTL in DNS responses.'));
so.datatype = 'uinteger';
so.modalonly = true;

so = ss.option(form.Value, 'client_subnet', _('EDNS Client subnet'),
so = ss.taboption('field_other', form.Value, 'client_subnet', _('EDNS Client subnet'),
_('Append a <code>edns0-subnet</code> OPT extra record with the specified IP prefix to every query by default.<br/>' +
'If value is an IP address instead of prefix, <code>/32</code> or <code>/128</code> will be appended automatically.'));
so.datatype = 'or(cidr, ipaddr)';
Expand Down

0 comments on commit 6478327

Please sign in to comment.