Dawnline 0.16.1
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- Checking one component for updates in Components no longer fails with "XHR request timed out": the check starts at once instead of keeping the page waiting twenty seconds - On a router without curl, updates and the installer download release files through GitHub's API: GitHub's own download links can make OpenWrt's built-in downloader hang - Adding a device in the admin offers the same four types as the personal page: PC, Mobile, Router and Other (phones and tablets are one choice)
This commit is contained in:
1 parent
2388603322
commit
0fd22b917a
20 files changed
+179
-73
No files matched your search
@@ -6,7 +6,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-dawnline
|
||||
PKG_VERSION:=0.16.0
|
||||
PKG_VERSION:=0.16.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_LICENSE:=MIT
|
||||
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
|
||||
|
||||
@@ -4099,6 +4099,10 @@ msgstr "Метод не поддерживается."
|
||||
msgid "Missing: %s."
|
||||
msgstr "Не хватает: %s."
|
||||
|
||||
#: web/src/shared/format.ts
|
||||
msgid "Mobile"
|
||||
msgstr "Мобильный"
|
||||
|
||||
#: web/src/admin/pages/person/limits.ts
|
||||
msgid "Monthly"
|
||||
msgstr "В месяц"
|
||||
|
||||
@@ -4043,6 +4043,10 @@ msgstr ""
|
||||
msgid "Missing: %s."
|
||||
msgstr ""
|
||||
|
||||
#: web/src/shared/format.ts
|
||||
msgid "Mobile"
|
||||
msgstr ""
|
||||
|
||||
#: web/src/admin/pages/person/limits.ts
|
||||
msgid "Monthly"
|
||||
msgstr ""
|
||||
|
||||
@@ -360,7 +360,7 @@ let LOCK = null;
|
||||
for (let i = 0; i < 10 && !LOCK; i++) {
|
||||
LOCK = upd.try_lock();
|
||||
if (!LOCK)
|
||||
system('usleep 100000 2>/dev/null || sleep 1');
|
||||
sleep(100);
|
||||
}
|
||||
if (!LOCK)
|
||||
exit(0);
|
||||
|
||||
@@ -79,14 +79,17 @@ function cached(key, ttl, fn) {
|
||||
/* ---------- releases ---------- */
|
||||
|
||||
function slim(x) {
|
||||
let digests = {};
|
||||
for (let a in x.assets ?? [])
|
||||
let digests = {}, ids = {};
|
||||
for (let a in x.assets ?? []) {
|
||||
if (match(a.digest ?? '', /^sha256:[0-9a-f]{64}$/))
|
||||
digests[a.name] = substr(a.digest, 7);
|
||||
if (type(a.id) == 'int' && a.id > 0)
|
||||
ids[a.name] = a.id;
|
||||
}
|
||||
return {
|
||||
tag: x.tag_name, name: x.name ?? x.tag_name, published: x.published_at ?? null,
|
||||
prerelease: !!x.prerelease, url: x.html_url ?? null, body: substr(x.body ?? '', 0, 12000),
|
||||
assets: map(x.assets ?? [], (a) => a.name), digests,
|
||||
assets: map(x.assets ?? [], (a) => a.name), digests, ids,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -194,6 +197,25 @@ export function sha256(path) {
|
||||
return match(run(`sha256sum ${q(path)}`).out, /^([0-9a-f]{64})/)?.[1];
|
||||
};
|
||||
|
||||
/** A release file's URL on github.com in parts: { repo, tag, name }, or null for any other URL. */
|
||||
export function release_file(url) {
|
||||
let m = match(url ?? '', /^https:\/\/github\.com\/([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\/releases\/download\/([^\/?#]+)\/([^\/?#]+)$/);
|
||||
return m ? { repo: m[1], tag: m[2], name: m[3] } : null;
|
||||
};
|
||||
|
||||
/** The same file through the API (api.github.com), when its release is known; else null. */
|
||||
function asset_api_url(url) {
|
||||
let f = release_file(url);
|
||||
if (!f)
|
||||
return null;
|
||||
let id = null;
|
||||
try {
|
||||
id = release(f.repo, f.tag)?.ids?.[f.name];
|
||||
}
|
||||
catch (e) {}
|
||||
return id ? `https://api.github.com/repos/${f.repo}/releases/assets/${id}` : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download to a file. o: { sha256, mirrors, log }. Direct first; mirrors
|
||||
* only when the sha256 is known (from the API) and mirrors are allowed. A
|
||||
@@ -203,24 +225,32 @@ export function sha256(path) {
|
||||
export function download(url, dest, o) {
|
||||
o ??= {};
|
||||
let want = o.sha256 ? lc(o.sha256) : null;
|
||||
let tries = [ url ];
|
||||
let curl = have_curl();
|
||||
let tries = [];
|
||||
// Without curl a release file comes through the API first: github.com's redirect to it carries a
|
||||
// Content-Security-Policy header that can outgrow uclient-fetch's 4 KB line buffer, and it stalls there.
|
||||
let api = curl ? null : asset_api_url(url);
|
||||
if (api)
|
||||
push(tries, { u: api, accept: 'application/octet-stream' });
|
||||
push(tries, { u: url });
|
||||
let direct = length(tries);
|
||||
if (want && o.mirrors && match(url, /^https:\/\/(github\.com|raw\.githubusercontent\.com)\//))
|
||||
for (let m in MIRRORS)
|
||||
push(tries, m + url);
|
||||
for (let i, u in tries) {
|
||||
let host = replace(u, /^https:\/\/([^\/]+)\/.*$/, '$1');
|
||||
if (i > 0)
|
||||
push(tries, { u: m + url, mirror: true });
|
||||
for (let i, t in tries) {
|
||||
let host = replace(t.u, /^https:\/\/([^\/]+)\/.*$/, '$1');
|
||||
if (t.mirror)
|
||||
o.log?.(sprintf(_('Trying mirror %s'), host));
|
||||
let r = have_curl()
|
||||
? run(`curl -fsSL --connect-timeout 15 --max-time 300 --retry 1 -o ${q(dest)} ${q(u)}`)
|
||||
: run(`uclient-fetch -q -T 30 -O ${q(dest)} ${q(u)}`);
|
||||
let r = curl
|
||||
? run(`curl -fsSL --connect-timeout 15 --max-time 300 --retry 1 -o ${q(dest)} ${q(t.u)}`)
|
||||
: run(`uclient-fetch -q -T 30 ${t.accept ? `--header=${q('Accept: ' + t.accept)} ` : ''}-O ${q(dest)} ${q(t.u)}`);
|
||||
if (r.code == 0 && (stat(dest)?.size ?? 0) > 0) {
|
||||
if (!want || sha256(dest) == want)
|
||||
return u;
|
||||
return t.u;
|
||||
o.log?.(sprintf(_("Warning: %s sent a file that does not match GitHub's sha256, discarded"), host));
|
||||
}
|
||||
system(`rm -f ${q(dest)}`);
|
||||
if (i == 0 && length(tries) > 1)
|
||||
if (i == direct - 1 && length(tries) > direct)
|
||||
o.log?.(_('GitHub did not answer, trying mirrors'));
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -80,7 +80,7 @@ function releases(a) {
|
||||
let page = +(a.page ?? 1);
|
||||
if (page != int(page) || page < 1 || page > 50)
|
||||
die(_('Unknown page.'));
|
||||
return { releases: map(gh.releases(REPO, page), (x) => ({ ...x, body: null, digests: null })), page };
|
||||
return { releases: map(gh.releases(REPO, page), (x) => ({ ...x, body: null, digests: null, ids: null })), page };
|
||||
}
|
||||
|
||||
/** Release notes for What's new: Dawnline by tag, or an AmneziaWG build's release. */
|
||||
@@ -94,7 +94,7 @@ function notes(a) {
|
||||
r = gh.release(rp, `v${tag}`);
|
||||
if (!r)
|
||||
die(sprintf(_('No release %s in %s.'), tag, rp));
|
||||
return { ...r, digests: null, repo: rp };
|
||||
return { ...r, digests: null, ids: null, repo: rp };
|
||||
}
|
||||
|
||||
/** What changed between the installed Dawnline and a release (points for the Components tab). */
|
||||
@@ -111,8 +111,10 @@ function changes(a) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start an update job. Returns the new job once its worker has written it,
|
||||
* else null (the caller follows updates_status); never an older job.
|
||||
* Start an update job. Returns the new job once its worker has written it
|
||||
* (a quick check may be over by then), else null (the caller follows
|
||||
* updates_status); never an older job. Waits two seconds at most: LuCI gives
|
||||
* up on a call after twenty.
|
||||
*/
|
||||
function run(a) {
|
||||
let what = a.what ?? 'check';
|
||||
@@ -126,16 +128,17 @@ function run(a) {
|
||||
if (upd.busy())
|
||||
die(_('Another component action is already running'));
|
||||
ensure_dir(RUN_DIR);
|
||||
let t0 = time();
|
||||
let t0 = time(), prev = read_json(upd.JOB_FILE, null)?.id;
|
||||
let args = substr(what, 0, 5) == 'check' ? `check ${substr(what, 6)}` : `install ${what}`;
|
||||
// The job speaks the admin's language (use() let only a plain language code through).
|
||||
let lang = i18n.current();
|
||||
system(`${lang ? `DAWNLINE_LANG=${lang} ` : ''}start-stop-daemon -S -b -x /usr/libexec/dawnline/updater -- ${args}`);
|
||||
for (let i = 0; i < 20; i++) {
|
||||
let j = read_json(upd.JOB_FILE, null);
|
||||
if (j?.state == 'running' && j.started >= t0)
|
||||
if (j && j.id != prev && j.started >= t0)
|
||||
return { started: true, job: j };
|
||||
system('usleep 100000 2>/dev/null || sleep 1');
|
||||
// ucode's own sleep: OpenWrt's BusyBox has no usleep.
|
||||
sleep(100);
|
||||
}
|
||||
return { started: true, job: null };
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export function check(ctx) {
|
||||
|
||||
/**
|
||||
* The sha256 a release publishes for a file: GitHub's own (API), else the
|
||||
* release's sha256sums.txt fetched straight from github.com (never a mirror).
|
||||
* release's sha256sums.txt fetched straight from GitHub (never a mirror).
|
||||
*/
|
||||
function want_sha(ctx, tag, asset, dir) {
|
||||
let want = gh.asset_sha256(REPO, tag, asset);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||
import { _ } from 'dawnline.i18n';
|
||||
|
||||
export const VERSION = '0.16.0';
|
||||
export const VERSION = '0.16.1';
|
||||
/** GitHub repository with Dawnline releases (updates and the installer). */
|
||||
export const REPO = 'tickcount/luci-app-dawnline';
|
||||
export const RUN_DIR = '/var/run/dawnline';
|
||||
|
||||
Reference in new issue
Block a user