Skip to content

Commit

Permalink
refactor: drop compatibility with sb 1.9 and earliar
Browse files Browse the repository at this point in the history
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
  • Loading branch information
1715173329 committed Dec 21, 2024
1 parent 6f8ab87 commit a6f5aca
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 57 deletions.
70 changes: 27 additions & 43 deletions htdocs/luci-static/resources/view/homeproxy/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,31 +480,25 @@ return view.extend({

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.'));
if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0)
so.value('bittorrent', _('BitTorrent'));
so.value('bittorrent', _('BitTorrent'));
so.value('dns', _('DNS'));
if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0)
so.value('dtls', _('DTLS'));
so.value('dtls', _('DTLS'));
so.value('http', _('HTTP'));
so.value('quic', _('QUIC'));
if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0) {
so.value('rdp', _('RDP'));
so.value('ssh', _('SSH'));
}
so.value('rdp', _('RDP'));
so.value('ssh', _('SSH'));
so.value('stun', _('STUN'));
so.value('tls', _('TLS'));

if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0) {
so = ss.taboption('field_other', form.Value, 'client', _('Client'),
_('Sniffed client type (QUIC client type or SSH client name).'));
so.value('chromium', _('Chromium / Cronet'));
so.value('firefox', _('Firefox / uquic firefox'));
so.value('quic-go', _('quic-go / uquic chrome'));
so.value('safari', _('Safari / Apple Network API'));
so.depends('protocol', 'quic');
so.depends('protocol', 'ssh');
so.modalonly = true;
}
so = ss.taboption('field_other', form.Value, 'client', _('Client'),
_('Sniffed client type (QUIC client type or SSH client name).'));
so.value('chromium', _('Chromium / Cronet'));
so.value('firefox', _('Firefox / uquic firefox'));
so.value('quic-go', _('quic-go / uquic chrome'));
so.value('safari', _('Safari / Apple Network API'));
so.depends('protocol', 'quic');
so.depends('protocol', 'ssh');
so.modalonly = true;

so = ss.taboption('field_other', form.ListValue, 'network', _('Network'));
so.value('tcp', _('TCP'));
Expand Down Expand Up @@ -578,11 +572,9 @@ return view.extend({
_('Match process path.'));
so.modalonly = true;

if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0) {
so = ss.taboption('field_other', form.DynamicList, 'process_path_regex', _('Process path (regex)'),
_('Match process path using regular expression.'));
so.modalonly = true;
}
so = ss.taboption('field_other', form.DynamicList, 'process_path_regex', _('Process path (regex)'),
_('Match process path using regular expression.'));
so.modalonly = true;

so = ss.taboption('field_other', form.DynamicList, 'user', _('User'),
_('Match user name.'));
Expand Down Expand Up @@ -846,16 +838,12 @@ return view.extend({

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.'));
if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0) {
so.value('bittorrent', _('BitTorrent'));
so.value('dtls', _('DTLS'));
}
so.value('bittorrent', _('BitTorrent'));
so.value('dtls', _('DTLS'));
so.value('http', _('HTTP'));
so.value('quic', _('QUIC'));
if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0) {
so.value('rdp', _('RDP'));
so.value('ssh', _('SSH'));
}
so.value('rdp', _('RDP'));
so.value('ssh', _('SSH'));
so.value('stun', _('STUN'));
so.value('tls', _('TLS'));

Expand Down Expand Up @@ -924,11 +912,9 @@ return view.extend({
_('Match process path.'));
so.modalonly = true;

if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0) {
so = ss.taboption('field_other', form.DynamicList, 'process_path_regex', _('Process path (regex)'),
_('Match process path using regular expression.'));
so.modalonly = true;
}
so = ss.taboption('field_other', form.DynamicList, 'process_path_regex', _('Process path (regex)'),
_('Match process path using regular expression.'));
so.modalonly = true;

so = ss.taboption('field_other', form.DynamicList, 'user', _('User'),
_('Match user name.'));
Expand All @@ -955,12 +941,10 @@ return view.extend({
so.default = so.disabled;
so.modalonly = true;

if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) >= 0) {
so = ss.taboption('field_other', form.Flag, 'rule_set_ip_cidr_accept_empty', _('Accept empty query response'),
_('Make IP CIDR in rule-sets accept empty query response.'));
so.default = so.disabled;
so.modalonly = true;
}
so = ss.taboption('field_other', form.Flag, 'rule_set_ip_cidr_accept_empty', _('Accept empty query response'),
_('Make IP CIDR in rule-sets accept empty query response.'));
so.default = so.disabled;
so.modalonly = true;

so = ss.taboption('field_other', form.Flag, 'invert', _('Invert'),
_('Invert match result.'));
Expand Down
7 changes: 0 additions & 7 deletions htdocs/luci-static/resources/view/homeproxy/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,13 +1072,6 @@ function renderNodeSettings(section, data, features, main_node, routing_mode) {
o.value('360');
o.value('android');
o.value('chrome');
if (features.version.localeCompare('1.10.0', undefined, { numeric: true, sensitivity: 'base' }) < 0) {
o.value('chrome_psk');
o.value('chrome_psk_shuffle');
o.value('chrome_padding_psk_shuffle');
o.value('chrome_pq');
o.value('chrome_pq_psk');
}
o.value('edge');
o.value('firefox');
o.value('ios');
Expand Down
10 changes: 3 additions & 7 deletions root/etc/homeproxy/scripts/generate_client.uc
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ if (!isEmpty(main_node)) {
user: cfg.user,
rule_set: get_ruleset(cfg.rule_set),
/* rule_set_ipcidr_match_source is deprecated in sing-box 1.10.0 */
rule_set_ipcidr_match_source: (features.version < '1.10.0' && cfg.rule_set_ip_cidr_match_source === '1') || null,
rule_set_ip_cidr_match_source: (features.version >= '1.10.0' && cfg.rule_set_ip_cidr_match_source === '1') || null,
rule_set_ip_cidr_match_source: (cfg.rule_set_ip_cidr_match_source === '1') || null,
invert: (cfg.invert === '1') || null,
outbound: get_outbound(cfg.outbound),
server: get_resolver(cfg.server),
Expand Down Expand Up @@ -530,9 +529,7 @@ if (match(proxy_mode, /tun/))

interface_name: tun_name,
/* inet4_address and inet6_address are deprecated in sing-box 1.10.0 */
inet4_address: (features.version < '1.10.0') ? tun_addr4 : null,
inet6_address: (features.version < '1.10.0' && ipv6_support === '1') ? tun_addr6 : null,
address: (features.version >= '1.10.0') ? ((ipv6_support === '1') ? [tun_addr4, tun_addr6] : [tun_addr4]) : null,
address: (ipv6_support === '1') ? [tun_addr4, tun_addr6] : [tun_addr4],
mtu: strToInt(tun_mtu),
gso: (tun_gso === '1'),
auto_route: false,
Expand Down Expand Up @@ -645,8 +642,7 @@ if (!isEmpty(main_node)) {
user: cfg.user,
rule_set: get_ruleset(cfg.rule_set),
/* rule_set_ipcidr_match_source is deprecated in sing-box 1.10.0 */
rule_set_ipcidr_match_source: (features.version < '1.10.0' && cfg.rule_set_ip_cidr_match_source === '1') || null,
rule_set_ip_cidr_match_source: (features.version >= '1.10.0' && cfg.rule_set_ip_cidr_match_source === '1') || null,
rule_set_ip_cidr_match_source: (cfg.rule_set_ip_cidr_match_source === '1') || null,
rule_set_ip_cidr_accept_empty: (cfg.rule_set_ip_cidr_accept_empty === '1') || null,
invert: (cfg.invert === '1') || null,
outbound: get_outbound(cfg.outbound)
Expand Down

0 comments on commit a6f5aca

Please sign in to comment.