mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 18:44:03 +08:00
🌴 Sync 2026-10-06 02:20:56
This commit is contained in:
1 parent
5c201dd3af
commit
487c4fad50
111 files changed
+4641
-746
No files matched your search
@@ -984,6 +984,52 @@ return baseclass.extend({
|
||||
.replace(/[<>]/g, '');
|
||||
},
|
||||
|
||||
/* Repair node references that point at a section which no longer exists.
|
||||
*
|
||||
* Deleting a node from the grid stages a plain `uci.remove`; nothing
|
||||
* rewrites `config.main_node` / `main_udp_node` / the urltest member lists,
|
||||
* and the generator then dies on every later run with
|
||||
*
|
||||
* cannot build main-out: the node it refers to does not exist (it may
|
||||
* have been deleted, or the reference is stale).
|
||||
*
|
||||
* so the reload aborts (the running configuration is kept) while the UI
|
||||
* reports the save as applied - measured on the device: generation exit 254
|
||||
* with exactly that message. `nil` and `urltest` are not section names, and
|
||||
* a reference that still resolves is left alone.
|
||||
*
|
||||
* Takes the cursor as an argument so this is testable without a form;
|
||||
* returns the list of repairs it made.
|
||||
*/
|
||||
repairNodeRefs(uci, cfg) {
|
||||
const repaired = [];
|
||||
|
||||
for (let opt of [ 'main_node', 'main_udp_node' ]) {
|
||||
const ref = uci.get(cfg, 'config', opt);
|
||||
|
||||
if (ref && ref !== 'nil' && ref !== 'urltest' && uci.get(cfg, ref) == null) {
|
||||
uci.set(cfg, 'config', opt, 'nil');
|
||||
repaired.push(opt);
|
||||
}
|
||||
}
|
||||
|
||||
for (let opt of [ 'main_urltest_nodes', 'main_udp_urltest_nodes' ]) {
|
||||
const list = uci.get(cfg, 'config', opt);
|
||||
|
||||
if (!Array.isArray(list) || !list.length)
|
||||
continue;
|
||||
|
||||
const kept = list.filter((id) => uci.get(cfg, id) != null);
|
||||
|
||||
if (kept.length !== list.length) {
|
||||
uci.set(cfg, 'config', opt, kept);
|
||||
repaired.push(opt);
|
||||
}
|
||||
}
|
||||
|
||||
return repaired;
|
||||
},
|
||||
|
||||
loadModalTitle(title, addtitle, uciconfig, ucisection) {
|
||||
let label = uci.get(uciconfig, ucisection, 'label');
|
||||
return label ? title + ' » ' + this.escapeTitleText(label) : addtitle;
|
||||
|
||||
@@ -84,7 +84,12 @@ function renderNodeSettings(section, data, features, main_node, routing_mode) {
|
||||
o.depends({'type': 'shadowtls', 'shadowtls_version': '2'});
|
||||
o.depends({'type': 'shadowtls', 'shadowtls_version': '3'});
|
||||
o.depends({'type': 'socks', 'socks_version': '5'});
|
||||
o.validate = hp.validatePassword([ 'anytls', 'shadowsocks', 'shadowtls', 'snell', 'trojan' ]);
|
||||
/* hysteria2 and tuic carry a password in REQUIRED_CREDENTIALS too, and
|
||||
* leaving them out here let an empty one be saved - after which the whole
|
||||
* side's generation dies (OutboundFactory.create() calls die() on it) and
|
||||
* the user only sees "my setting did not take". Pinned against the
|
||||
* backend table by tests/frontend-protocol-inventory.js. */
|
||||
o.validate = hp.validatePassword([ 'anytls', 'hysteria2', 'shadowsocks', 'shadowtls', 'snell', 'trojan', 'tuic' ]);
|
||||
o.modalonly = true;
|
||||
|
||||
/* Direct config */
|
||||
@@ -581,6 +586,22 @@ return view.extend({
|
||||
|
||||
m = new form.Map('homeproxy-pro', _('Edit nodes'));
|
||||
|
||||
/* Every save of this map can commit a node reference the grid's delete
|
||||
* button just made dangling - including the page footer's Save & Apply,
|
||||
* which calls map.save() itself and never passes through the buttons
|
||||
* below. Repair first; see hp.repairNodeRefs(). */
|
||||
const map_save = (typeof m.save === 'function') ? m.save.bind(m) : null;
|
||||
|
||||
if (map_save)
|
||||
m.save = function() {
|
||||
const repaired = hp.repairNodeRefs(uci, 'homeproxy-pro');
|
||||
|
||||
if (repaired.length)
|
||||
console.warn('homeproxy-pro: repaired dangling node reference(s): ' + repaired.join(', '));
|
||||
|
||||
return map_save.apply(null, arguments);
|
||||
};
|
||||
|
||||
s = m.section(form.NamedSection, 'subscription', 'homeproxy-pro');
|
||||
|
||||
/* Node settings start */
|
||||
|
||||
@@ -224,7 +224,10 @@ return view.extend({
|
||||
o.depends('type', 'snell');
|
||||
o.depends('type', 'trojan');
|
||||
o.depends('type', 'tuic');
|
||||
o.validate = hp.validatePassword([ 'anytls', 'http', 'mixed', 'naive', 'shadowsocks', 'snell', 'socks', 'trojan' ]);
|
||||
/* Same list, same reason as the node form's: an empty password on
|
||||
* hysteria2/tuic makes InboundFactory.create() die() and the server side
|
||||
* never generates. */
|
||||
o.validate = hp.validatePassword([ 'anytls', 'http', 'hysteria2', 'mixed', 'naive', 'shadowsocks', 'snell', 'socks', 'trojan', 'tuic' ]);
|
||||
o.modalonly = true;
|
||||
|
||||
/* AnyTLS config */
|
||||
|
||||
Reference in new issue
Block a user