mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-06 11:24:07 +08:00
⛅ Sync 2026-10-05 09:23:32
This commit is contained in:
1 parent
9c9db09f6b
commit
e50b16f095
6 files changed
+1
-272
No files matched your search
@@ -90,71 +90,6 @@ return baseclass.extend({
|
||||
user copies. */
|
||||
rule_path_default: HP_RULE_PATH_DEFAULT,
|
||||
|
||||
/* Parse sing-box's rule-set download failures out of a log.
|
||||
*
|
||||
* A remote rule-set is fetched during initialization, before the inbounds
|
||||
* bind, so a failure there is a failed start:
|
||||
*
|
||||
* 2026-10-03 01:15:42 ERROR router: fetch rule-set example: Get "https://…": dial tcp …
|
||||
*
|
||||
* That is loud - but only in a log, and only for the rule-sets a user
|
||||
* defined themselves (the built-in China split is local files, nothing to
|
||||
* download). A start that failed leaves no running instance and no status
|
||||
* page, so the reason is readable only over ssh. Surfacing it here is the
|
||||
* whole job.
|
||||
*
|
||||
* Two deliberate choices about the format:
|
||||
*
|
||||
* - the tag and the reason are matched on the stable part
|
||||
* (`fetch rule-set <tag>:`) and nothing assumes sing-box's timestamp
|
||||
* or level layout. A rule-set whose download failed long ago and whose
|
||||
* log line moves out of the file must not read as "no failures", so a
|
||||
* missing timestamp is omitted rather than faked.
|
||||
* - the last occurrence of a tag wins. The file is truncated at 50 KB by
|
||||
* clean_log.sh, so a tag that failed every 24 hours is in there
|
||||
* repeatedly, and the most recent reason is the one that is true now.
|
||||
*
|
||||
* The timestamp shape is the one thing that IS pinned, and it was pinned
|
||||
* from a real 1.14.2 line rather than guessed - the device writes
|
||||
*
|
||||
* +0800 2026-10-03 09:29:34 ERROR router: fetch rule-set geoip-cn: Get ...
|
||||
*
|
||||
* i.e. a UTC offset BEFORE the date. An earlier version of this anchored
|
||||
* the date at the start of the line and therefore returned no time for
|
||||
* every real line, which is the one shape the panel is supposed to show.
|
||||
* The offset is optional in the pattern so a build that omits it still
|
||||
* parses.
|
||||
*
|
||||
* Returns [{ tag, reason, at }], newest last. Never throws: this reads a
|
||||
* file that may be empty, half-written, or rotated mid-read. */
|
||||
parseRuleSetFetchFailures(text) {
|
||||
const out = [];
|
||||
if (!text)
|
||||
return out;
|
||||
|
||||
const seen = {};
|
||||
|
||||
for (const line of String(text).split('\n')) {
|
||||
const m = /fetch rule-set\s+([^\s:]+):\s*(.*)$/.exec(line);
|
||||
if (!m)
|
||||
continue;
|
||||
|
||||
const tag = m[1];
|
||||
const at = /^(?:[+-]\d{4}\s+)?(\d{4}-\d{2}-\d{2}[ T][0-9:.]+)/.exec(line);
|
||||
|
||||
if (seen[tag] !== undefined) {
|
||||
out[seen[tag]].reason = m[2].trim();
|
||||
out[seen[tag]].at = at ? at[1] : null;
|
||||
continue;
|
||||
}
|
||||
|
||||
seen[tag] = out.length;
|
||||
out.push({ tag: tag, reason: m[2].trim(), at: at ? at[1] : null });
|
||||
}
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
dns_strategy: {
|
||||
'': _('Default'),
|
||||
'prefer_ipv4': _('Prefer IPv4'),
|
||||
|
||||
Reference in new issue
Block a user