Skip to content

Commit

Permalink
feat(client): classify Routing Rule fields
Browse files Browse the repository at this point in the history
  • Loading branch information
muink committed Jul 24, 2024
1 parent fd2e569 commit 8426212
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions htdocs/luci-static/resources/view/homeproxy/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,17 +432,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], 'routing_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 || ip_cidr || ip_is_private)</code> &&<br/>' +
'<code>(port || port_range)</code> &&<br/>' +
Expand All @@ -455,97 +461,97 @@ 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'),
_('4 or 6. Not limited if empty.'));
so.value('4', _('IPv4'));
so.value('6', _('IPv6'));
so.value('', _('Both'));
so.modalonly = true;

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('stun', _('STUN'));

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.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, '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.rmempty = false;
so.modalonly = true;

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

so = ss.option(form.Flag, 'ip_is_private', _('Private IP'),
so = ss.taboption('field_host', form.Flag, 'ip_is_private', _('Private IP'),
_('Match private IP.'));
so.default = so.disabled;
so.rmempty = false;
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, '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, '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 @@ -561,18 +567,18 @@ return view.extend({
}
so.modalonly = true;

so = ss.option(form.Flag, 'rule_set_ipcidr_match_source', _('Match source IP via rule set'),
so = ss.taboption('field_other', form.Flag, 'rule_set_ipcidr_match_source', _('Match source IP via rule set'),
_('Make IP CIDR in rule set used to match the source IP.'));
so.default = so.disabled;
so.rmempty = false;
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.ListValue, 'outbound', _('Outbound'),
so = ss.taboption('field_other', form.ListValue, 'outbound', _('Outbound'),
_('Tag of the target outbound.'));
so.load = function(section_id) {
delete this.keylist;
Expand Down

0 comments on commit 8426212

Please sign in to comment.