update 2025-01-17 20:23:38

This commit is contained in:
actions-user 2025-01-17 20:23:38 +08:00
parent 8424782934
commit 09a2824d0a
6 changed files with 1075 additions and 1000 deletions

File diff suppressed because it is too large Load Diff

View File

@ -165,7 +165,7 @@ class RulesEntry {
factor = [{type: 'MATCH'}];
}
rule = hm.removeBlankAttrs(hm, {
rule = hm.removeBlankAttrs({
type: this.type,
payload: factor,
detour: detour || null,
@ -366,7 +366,7 @@ function renderPayload(s, total, uciconfig) {
Object.keys(extenbox).forEach((n) => {
prefix = `payload${n}_`;
o = s.option(hm.CBIStaticList, prefix + 'type', _('Type') + ' ++');
o = s.option(hm.StaticList, prefix + 'type', _('Type') + ' ++');
o.default = hm.rules_type[0][0];
hm.rules_type.forEach((res) => {
o.value.apply(o, res);
@ -411,7 +411,7 @@ function renderPayload(s, total, uciconfig) {
return new RulesEntry(uci.get(uciconfig, section_id, 'entry')).getPayloads().slice(n).map(e => e[key] ?? '');
}, o, n, 'factor', uciconfig)
o = s.option(hm.CBIStaticList, prefix + 'NOTs', _('NOT') + ' ++',
o = s.option(hm.StaticList, prefix + 'NOTs', _('NOT') + ' ++',
_('<code>0</code> or <code>1</code> only.'));
o.value('0');
o.value('1');
@ -508,7 +508,7 @@ function renderRules(s, uciconfig) {
renderPayload(s, Math.max(...Object.values(hm.rules_logical_payload_count).map(e => e.low)), uciconfig);
o = s.option(hm.CBIListValue, 'detour', _('Proxy group'));
o = s.option(hm.ListValue, 'detour', _('Proxy group'));
o.load = function(section_id) {
hm.loadProxyGroupLabel.call(this, hm.preset_outbound.full, section_id);
@ -579,13 +579,13 @@ return view.extend({
s.render = function () {
poll.add(function () {
return hm.getServiceStatus('mihomo-c').then((isRunning) => {
hm.updateStatus(hm, document.getElementById('_client_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-c', true);
hm.updateStatus(document.getElementById('_client_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-c', true);
});
});
return E('div', { class: 'cbi-section' }, [
E('p', [
hm.renderStatus(hm, '_client_bar', false, 'mihomo-c', true)
hm.renderStatus('_client_bar', false, 'mihomo-c', true)
])
]);
}
@ -1010,7 +1010,7 @@ return view.extend({
so.rmempty = false;
so.modalonly = true;
so = ss.option(hm.CBIListValue, 'detour', _('Proxy group'));
so = ss.option(hm.ListValue, 'detour', _('Proxy group'));
so.load = function(section_id) {
hm.loadProxyGroupLabel.call(this, hm.preset_outbound.dns, section_id);
@ -1142,7 +1142,7 @@ return view.extend({
so.rmempty = false;
so.editable = true;
so = ss.option(hm.CBIListValue, 'proxy', _('Proxy group override'),
so = ss.option(hm.ListValue, 'proxy', _('Proxy group override'),
_('Override the Proxy group of DNS server.'));
so.default = hm.preset_outbound.direct[0][0];
hm.preset_outbound.direct.forEach((res) => {

View File

@ -195,18 +195,18 @@ return view.extend({
}
so = ss.option(form.DummyValue, '_client_status', _('Client status'));
so.cfgvalue = function() { return hm.renderStatus(hm, '_client_bar', CisRunning ? { ...CclashAPI, dashboard_repo: dashboard_repo } : false, 'mihomo-c') }
so.cfgvalue = function() { return hm.renderStatus('_client_bar', CisRunning ? { ...CclashAPI, dashboard_repo: dashboard_repo } : false, 'mihomo-c') }
poll.add(function() {
return hm.getServiceStatus('mihomo-c').then((isRunning) => {
hm.updateStatus(hm, document.getElementById('_client_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-c');
hm.updateStatus(document.getElementById('_client_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-c');
});
})
so = ss.option(form.DummyValue, '_server_status', _('Server status'));
so.cfgvalue = function() { return hm.renderStatus(hm, '_server_bar', SisRunning ? { ...SclashAPI, dashboard_repo: dashboard_repo } : false, 'mihomo-s') }
so.cfgvalue = function() { return hm.renderStatus('_server_bar', SisRunning ? { ...SclashAPI, dashboard_repo: dashboard_repo } : false, 'mihomo-s') }
poll.add(function() {
return hm.getServiceStatus('mihomo-s').then((isRunning) => {
hm.updateStatus(hm, document.getElementById('_server_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-s');
hm.updateStatus(document.getElementById('_server_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-s');
});
})
@ -774,7 +774,7 @@ return view.extend({
/* Custom Direct list */
ss.tab('direct_list', _('Custom Direct List'));
so = ss.taboption('direct_list', hm.CBITextValue, 'direct_list.yaml', null);
so = ss.taboption('direct_list', hm.TextValue, 'direct_list.yaml', null);
so.rows = 20;
so.default = 'FQDN:\nIPCIDR:\nIPCIDR6:\n';
so.placeholder = "FQDN:\n- mask.icloud.com\n- mask-h2.icloud.com\n- mask.apple-dns.net\nIPCIDR:\n- '223.0.0.0/12'\nIPCIDR6:\n- '2400:3200::/32'\n";
@ -792,7 +792,7 @@ return view.extend({
/* Custom Proxy list */
ss.tab('proxy_list', _('Custom Proxy List'));
so = ss.taboption('proxy_list', hm.CBITextValue, 'proxy_list.yaml', null);
so = ss.taboption('proxy_list', hm.TextValue, 'proxy_list.yaml', null);
so.rows = 20;
so.default = 'FQDN:\nIPCIDR:\nIPCIDR6:\n';
so.placeholder = "FQDN:\n- www.google.com\nIPCIDR:\n- '91.105.192.0/23'\nIPCIDR6:\n- '2001:67c:4e8::/48'\n";

View File

@ -81,7 +81,7 @@ return view.extend({
so.depends({type: /^(http|socks5|mieru|trojan|hysteria2|tuic|ssh)$/});
so.modalonly = true;
so = ss.taboption('field_general', hm.CBITextValue, 'headers', _('HTTP header'));
so = ss.taboption('field_general', hm.TextValue, 'headers', _('HTTP header'));
so.placeholder = '{\n "User-Agent": [\n "Clash/v1.18.0",\n "mihomo/1.18.3"\n ],\n "Authorization": [\n //"token 1231231"\n ]\n}';
so.validate = L.bind(hm.validateJson, so);
so.depends('type', 'http');
@ -152,7 +152,7 @@ return view.extend({
so.password = true;
so.validate = function(section_id, value) {
const encmode = this.section.getOption('shadowsocks_chipher').formvalue(section_id);
return hm.validateShadowsocksPassword.call(this, hm, encmode, section_id, value);
return hm.validateShadowsocksPassword.call(this, encmode, section_id, value);
}
so.depends({type: 'ss', shadowsocks_chipher: /.+/});
so.modalonly = true;
@ -279,7 +279,7 @@ return view.extend({
so.password = true;
so.validate = function(section_id, value) {
const encmode = this.section.getOption('trojan_ss_chipher').formvalue(section_id);
return hm.validateShadowsocksPassword.call(this, hm, encmode, section_id, value);
return hm.validateShadowsocksPassword.call(this, encmode, section_id, value);
}
so.depends({type: 'trojan', trojan_ss_enabled: '1'});
so.modalonly = true;
@ -639,7 +639,7 @@ return view.extend({
so.depends({transport_enabled: '1', transport_type: /^(h2|ws)$/});
so.modalonly = true;
so = ss.taboption('field_transport', hm.CBITextValue, 'transport_http_headers', _('HTTP header'));
so = ss.taboption('field_transport', hm.TextValue, 'transport_http_headers', _('HTTP header'));
so.placeholder = '{\n "Host": "example.com",\n "Connection": [\n "keep-alive"\n ]\n}';
so.validate = L.bind(hm.validateJson, so);
so.depends({transport_enabled: '1', transport_type: /^(http|ws)$/});
@ -798,7 +798,7 @@ return view.extend({
el.appendChild(E('button', {
'class': 'cbi-button cbi-button-add',
'title': _('Remove idles'),
'click': ui.createHandlerFn(this, hm.handleRemoveIdles, hm)
'click': ui.createHandlerFn(this, hm.handleRemoveIdles)
}, [ _('Remove idles') ]));
return el;
@ -843,7 +843,7 @@ return view.extend({
}
so.modalonly = false;
so = ss.taboption('field_general', hm.CBITextValue, '_editer', _('Editer'),
so = ss.taboption('field_general', hm.TextValue, '_editer', _('Editer'),
_('Please type <a target="_blank" href="%s" rel="noreferrer noopener">%s</a>.')
.format('https://wiki.metacubex.one/config/proxy-providers/content/', _('Contents')));
so.placeholder = _('Content will not be verified, Please make sure you enter it correctly.');
@ -857,7 +857,7 @@ return view.extend({
so.depends('type', 'file');
so.modalonly = true;
so = ss.taboption('field_general', hm.CBITextValue, 'payload', 'payload:',
so = ss.taboption('field_general', hm.TextValue, 'payload', 'payload:',
_('Please type <a target="_blank" href="%s" rel="noreferrer noopener">%s</a>.')
.format('https://wiki.metacubex.one/config/proxy-providers/content/', _('Payload')));
so.placeholder = '- name: "ss1"\n type: ss\n server: server\n port: 443\n cipher: chacha20-ietf-poly1305\n password: "password"\n# ' + _('Content will not be verified, Please make sure you enter it correctly.');
@ -894,7 +894,7 @@ return view.extend({
//so.editable = true;
so.depends('type', 'http');
so = ss.taboption('field_general', hm.CBITextValue, 'header', _('HTTP header'),
so = ss.taboption('field_general', hm.TextValue, 'header', _('HTTP header'),
_('Custom HTTP header.'));
so.placeholder = '{\n "User-Agent": [\n "Clash/v1.18.0",\n "mihomo/1.18.3"\n ],\n "Accept": [\n //"application/vnd.github.v3.raw"\n ],\n "Authorization": [\n //"token 1231231"\n ]\n}';
so.validate = L.bind(hm.validateJson, so);
@ -1041,7 +1041,7 @@ return view.extend({
so.modalonly = true;
so = ss.option(form.DummyValue, '_update');
so.cfgvalue = L.bind(hm.renderResDownload, so, hm);
so.cfgvalue = L.bind(hm.renderResDownload, so);
so.editable = true;
so.modalonly = false;
/* Provider END */

View File

@ -183,7 +183,7 @@ return view.extend({
el.appendChild(E('button', {
'class': 'cbi-button cbi-button-add',
'title': _('Remove idles'),
'click': ui.createHandlerFn(this, hm.handleRemoveIdles, hm)
'click': ui.createHandlerFn(this, hm.handleRemoveIdles)
}, [ _('Remove idles') ]));
return el;
@ -260,7 +260,7 @@ return view.extend({
}
o.modalonly = false;
o = s.option(hm.CBITextValue, '_editer', _('Editer'),
o = s.option(hm.TextValue, '_editer', _('Editer'),
_('Please type <a target="_blank" href="%s" rel="noreferrer noopener">%s</a>.')
.format('https://wiki.metacubex.one/config/rule-providers/content/', _('Contents')));
o.placeholder = _('Content will not be verified, Please make sure you enter it correctly.');
@ -274,7 +274,7 @@ return view.extend({
o.depends({'type': 'file', 'format': /^(text|yaml)$/});
o.modalonly = true;
o = s.option(hm.CBITextValue, 'payload', 'payload:',
o = s.option(hm.TextValue, 'payload', 'payload:',
_('Please type <a target="_blank" href="%s" rel="noreferrer noopener">%s</a>.')
.format('https://wiki.metacubex.one/config/rule-providers/content/', _('Payload')));
o.placeholder = '- DOMAIN-SUFFIX,google.com\n# ' + _('Content will not be verified, Please make sure you enter it correctly.');
@ -312,7 +312,7 @@ return view.extend({
o.depends('type', 'http');
o = s.option(form.DummyValue, '_update');
o.cfgvalue = L.bind(hm.renderResDownload, o, hm);
o.cfgvalue = L.bind(hm.renderResDownload, o);
o.editable = true;
o.modalonly = false;
/* Rule set END */

View File

@ -7,56 +7,6 @@
'require fchomo as hm';
function handleGenKey(option) {
const section_id = this.section.section;
const type = this.section.getOption('type').formvalue(section_id);
let widget = this.map.findElement('id', 'widget.cbid.fchomo.%s.%s'.format(section_id, option));
let password, required_method;
if (option === 'uuid' || option.match(/_uuid/))
required_method = 'uuid';
else if (type === 'shadowsocks')
required_method = this.section.getOption('shadowsocks_chipher')?.formvalue(section_id);
switch (required_method) {
/* NONE */
case 'none':
password = '';
break;
/* UUID */
case 'uuid':
password = hm.generateRand('uuid');
break;
/* DEFAULT */
default:
password = hm.generateRand('hex', 16);
break;
}
/* AEAD */
(function(length) {
if (length && length > 0)
password = hm.generateRand('base64', length);
}(hm.shadowsocks_cipher_length[required_method]));
return widget.value = password;
}
const CBIPWGenValue = form.Value.extend({
__name__: 'CBI.PWGenValue',
renderWidget() {
let node = form.Value.prototype.renderWidget.apply(this, arguments);
(node.querySelector('.control-group') || node).appendChild(E('button', {
'class': 'cbi-button cbi-button-add',
'title': _('Generate'),
'click': ui.createHandlerFn(this, handleGenKey, this.option)
}, [ _('Generate') ]));
return node;
}
});
return view.extend({
load() {
return Promise.all([
@ -78,13 +28,13 @@ return view.extend({
s.render = function () {
poll.add(function () {
return hm.getServiceStatus('mihomo-s').then((isRunning) => {
hm.updateStatus(hm, document.getElementById('_server_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-s', true);
hm.updateStatus(document.getElementById('_server_bar'), isRunning ? { dashboard_repo: dashboard_repo } : false, 'mihomo-s', true);
});
});
return E('div', { class: 'cbi-section' }, [
E('p', [
hm.renderStatus(hm, '_server_bar', false, 'mihomo-s', true)
hm.renderStatus('_server_bar', false, 'mihomo-s', true)
])
]);
}
@ -151,7 +101,7 @@ return view.extend({
o.depends({type: /^(http|socks|mixed|hysteria2)$/});
o.modalonly = true;
o = s.option(CBIPWGenValue, 'password', _('Password'));
o = s.option(hm.GenValue, 'password', _('Password'));
o.password = true;
o.validate = L.bind(hm.validateAuthPassword, o);
o.rmempty = false;
@ -184,7 +134,7 @@ return view.extend({
o.depends('type', 'hysteria2');
o.modalonly = true;
o = s.option(CBIPWGenValue, 'hysteria_obfs_password', _('Obfuscate password'),
o = s.option(hm.GenValue, 'hysteria_obfs_password', _('Obfuscate password'),
_('Enabling obfuscation will make the server incompatible with standard QUIC connections, losing the ability to masquerade with HTTP/3.'));
o.password = true;
o.rmempty = false;
@ -207,17 +157,17 @@ return view.extend({
o.depends('type', 'shadowsocks');
o.modalonly = true;
o = s.option(CBIPWGenValue, 'shadowsocks_password', _('Password'));
o = s.option(hm.GenValue, 'shadowsocks_password', _('Password'));
o.password = true;
o.validate = function(section_id, value) {
const encmode = this.section.getOption('shadowsocks_chipher').formvalue(section_id);
return hm.validateShadowsocksPassword.call(this, hm, encmode, section_id, value);
return hm.validateShadowsocksPassword.call(this, encmode, section_id, value);
}
o.depends({type: 'shadowsocks', shadowsocks_chipher: /.+/});
o.modalonly = true;
/* Tuic fields */
o = s.option(CBIPWGenValue, 'uuid', _('UUID'));
o = s.option(hm.GenValue, 'uuid', _('UUID'));
o.rmempty = false;
o.validate = L.bind(hm.validateUUID, o);
o.depends('type', 'tuic');
@ -253,7 +203,7 @@ return view.extend({
o.modalonly = true;
/* VMess fields */
o = s.option(CBIPWGenValue, 'vmess_uuid', _('UUID'));
o = s.option(hm.GenValue, 'vmess_uuid', _('UUID'));
o.rmempty = false;
o.validate = L.bind(hm.validateUUID, o);
o.depends('type', 'vmess');