Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8130e39a8 | ||
|
|
18e3013047 | ||
|
|
b0d9982796 | ||
|
|
f2b5ba101b | ||
|
|
0fd22b917a | ||
|
|
2388603322 | ||
|
|
750564ab7e | ||
|
|
3fadee87d3 | ||
|
|
ba231e7187 |
No files matched your search
@@ -33,7 +33,7 @@ jobs:
|
|||||||
version: ${{ steps.version.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -63,14 +63,14 @@ jobs:
|
|||||||
- { type: apk, sdk: 'itdoginfo/openwrt-sdk-apk:25.12.3@sha256:6d832008ddd1b8ec4edc84f5e6e0bf22a13ba2d6888083a8e69fa26d752c276f' }
|
- { type: apk, sdk: 'itdoginfo/openwrt-sdk-apk:25.12.3@sha256:6d832008ddd1b8ec4edc84f5e6e0bf22a13ba2d6888083a8e69fa26d752c276f' }
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
|
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '26'
|
||||||
cache: npm
|
cache: npm
|
||||||
cache-dependency-path: web/package-lock.json
|
cache-dependency-path: web/package-lock.json
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
run: scripts/build-packages.sh ${{ matrix.type }}
|
run: scripts/build-packages.sh ${{ matrix.type }}
|
||||||
|
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: package-${{ matrix.type }}
|
name: package-${{ matrix.type }}
|
||||||
# The app and its translation packages (luci-i18n-dawnline-<lang>).
|
# The app and its translation packages (luci-i18n-dawnline-<lang>).
|
||||||
@@ -105,7 +105,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# The whole history and the tags: the notes list the commits since the previous tag.
|
# The whole history and the tags: the notes list the commits since the previous tag.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -116,7 +116,7 @@ jobs:
|
|||||||
cat notes.md
|
cat notes.md
|
||||||
|
|
||||||
- name: Download packages
|
- name: Download packages
|
||||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
pattern: package-*
|
pattern: package-*
|
||||||
path: release
|
path: release
|
||||||
@@ -129,7 +129,7 @@ jobs:
|
|||||||
cat sha256sums.txt
|
cat sha256sums.txt
|
||||||
|
|
||||||
- name: Publish the release
|
- name: Publish the release
|
||||||
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
|
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
|
||||||
with:
|
with:
|
||||||
name: Dawnline ${{ github.ref_name }}
|
name: Dawnline ${{ github.ref_name }}
|
||||||
tag_name: ${{ github.ref_name }}
|
tag_name: ${{ github.ref_name }}
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ jobs:
|
|||||||
working-directory: web
|
working-directory: web
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v5
|
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '26'
|
||||||
cache: npm
|
cache: npm
|
||||||
cache-dependency-path: web/package-lock.json
|
cache-dependency-path: web/package-lock.json
|
||||||
|
|
||||||
@@ -51,6 +51,20 @@ jobs:
|
|||||||
id: types
|
id: types
|
||||||
run: npm run --silent typecheck
|
run: npm run --silent typecheck
|
||||||
|
|
||||||
|
# oxlint's correctness rules: what the types let through (a stray expression, a needless escape).
|
||||||
|
- name: Lint
|
||||||
|
id: lint
|
||||||
|
run: npm run --silent lint
|
||||||
|
|
||||||
|
# Exports nobody imports, files nobody reaches, dependencies used but not listed (or listed but unused).
|
||||||
|
- name: Unused code
|
||||||
|
id: knip
|
||||||
|
run: |
|
||||||
|
if ! npm run --silent knip; then
|
||||||
|
echo "::error::knip found unused code or a dependency problem: remove it, or drop the export when only its own file uses it."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# The catalogs follow the code: every string collected, translated, its placeholders kept.
|
# The catalogs follow the code: every string collected, translated, its placeholders kept.
|
||||||
- name: Translations
|
- name: Translations
|
||||||
id: i18n
|
id: i18n
|
||||||
@@ -64,17 +78,17 @@ jobs:
|
|||||||
id: tests
|
id: tests
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
# The bundles under package/ are committed: a build must change nothing
|
# The bundles under package/ are not committed (build.yml builds them
|
||||||
# and leave no new file behind (an output nobody added to git would be
|
# before packaging): a build must touch no tracked file and leave every
|
||||||
# missing from the package).
|
# output it writes ignored by .gitignore, so none ends up in a commit.
|
||||||
- name: Build bundles and check they are committed
|
- name: Build bundles and check they stay out of git
|
||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
npm run --silent build
|
npm run --silent build
|
||||||
changed="$(git status --porcelain --untracked-files=all -- ../package)"
|
changed="$(git status --porcelain --untracked-files=all -- ../package)"
|
||||||
if [ -n "$changed" ]; then
|
if [ -n "$changed" ]; then
|
||||||
echo "$changed"
|
echo "$changed"
|
||||||
echo "::error::The committed bundles are out of date or the build left new files. Run 'npm run build' in web/ and commit the result."
|
echo "::error::The build changed a tracked file under package/ or wrote one .gitignore does not cover."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -88,6 +102,8 @@ jobs:
|
|||||||
echo "|---|---|"
|
echo "|---|---|"
|
||||||
echo "| Formatting | ${{ steps.format.outcome }} |"
|
echo "| Formatting | ${{ steps.format.outcome }} |"
|
||||||
echo "| Types | ${{ steps.types.outcome }} |"
|
echo "| Types | ${{ steps.types.outcome }} |"
|
||||||
|
echo "| Lint | ${{ steps.lint.outcome }} |"
|
||||||
|
echo "| Unused code | ${{ steps.knip.outcome }} |"
|
||||||
echo "| Translations | ${{ steps.i18n.outcome }} |"
|
echo "| Translations | ${{ steps.i18n.outcome }} |"
|
||||||
echo "| Tests | ${{ steps.tests.outcome }} |"
|
echo "| Tests | ${{ steps.tests.outcome }} |"
|
||||||
echo "| Bundles | ${{ steps.build.outcome }} |"
|
echo "| Bundles | ${{ steps.build.outcome }} |"
|
||||||
@@ -98,7 +114,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -127,7 +143,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -174,7 +190,7 @@ jobs:
|
|||||||
release: ['24.10', '25.12']
|
release: ['24.10', '25.12']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,6 @@ node_modules/
|
|||||||
dist/
|
dist/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
web/coverage/
|
web/coverage/
|
||||||
|
# The web bundles: web/ builds them (npm run build), CI before packaging.
|
||||||
|
package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/
|
||||||
|
package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/
|
||||||
@@ -17,7 +17,7 @@ This repo usually sits inside the router-admin workspace (`../AGENTS.md`). Its r
|
|||||||
## Layout
|
## Layout
|
||||||
|
|
||||||
- `package/luci-app-dawnline/root/` — what lands on the router: ucode modules in `usr/share/ucode/dawnline/` (`rpc/` for the LuCI backend), the agent and updater in `usr/libexec/dawnline/`, the portal in `usr/share/dawnline/portal/`, the init script, rpcd ACL.
|
- `package/luci-app-dawnline/root/` — what lands on the router: ucode modules in `usr/share/ucode/dawnline/` (`rpc/` for the LuCI backend), the agent and updater in `usr/libexec/dawnline/`, the portal in `usr/share/dawnline/portal/`, the init script, rpcd ACL.
|
||||||
- `web/` — TypeScript sources of the admin UI (`src/admin`) and the portal (`src/portal`), shared code in `src/shared`; the built bundles are committed under `package/`. `web/i18n/` — the string catalogs' tools (`extract.ts`, `po.ts`, `lmo.ts`).
|
- `web/` — TypeScript sources of the admin UI (`src/admin`) and the portal (`src/portal`), shared code in `src/shared`; `npm run build` writes the bundles under `package/` (git-ignored: CI builds them before packaging). `web/i18n/` — the string catalogs' tools (`extract.ts`, `po.ts`, `lmo.ts`).
|
||||||
- `package/luci-app-dawnline/po/` — the admin's catalog (`templates/dawnline.pot`, `ru/dawnline.po`): luci.mk builds the `luci-i18n-dawnline-ru` package from it. The portal's catalog is `web/src/portal/i18n/ru.po`, bundled into the portal.
|
- `package/luci-app-dawnline/po/` — the admin's catalog (`templates/dawnline.pot`, `ru/dawnline.po`): luci.mk builds the `luci-i18n-dawnline-ru` package from it. The portal's catalog is `web/src/portal/i18n/ru.po`, bundled into the portal.
|
||||||
- `install.sh`, `uninstall.sh` — the standalone installer and uninstaller (both have `--dry-run`).
|
- `install.sh`, `uninstall.sh` — the standalone installer and uninstaller (both have `--dry-run`).
|
||||||
- `scripts/` — `lint-ucode.py`, `compile-ucode.sh` (compiles every ucode file of a tree wherever ucode runs), `check-ucode.sh` (the same on the router, without installing), `ucode-container.sh` (compile and unit tests in the OpenWrt rootfs containers CI uses), `deploy.sh` (dev deploy over SSH), `build-packages.sh`, `build-release.sh`, `release-notes.sh`.
|
- `scripts/` — `lint-ucode.py`, `compile-ucode.sh` (compiles every ucode file of a tree wherever ucode runs), `check-ucode.sh` (the same on the router, without installing), `ucode-container.sh` (compile and unit tests in the OpenWrt rootfs containers CI uses), `deploy.sh` (dev deploy over SSH), `build-packages.sh`, `build-release.sh`, `release-notes.sh`.
|
||||||
@@ -27,7 +27,7 @@ This repo usually sits inside the router-admin workspace (`../AGENTS.md`). Its r
|
|||||||
|
|
||||||
- `python3 scripts/lint-ucode.py` (use before definition, exports, POSIX regexes, rpcd methods; layering notes are informational).
|
- `python3 scripts/lint-ucode.py` (use before definition, exports, POSIX regexes, rpcd methods; layering notes are informational).
|
||||||
- `scripts/ucode-container.sh` (needs docker): compiles every ucode file and runs `tests/ucode` on OpenWrt 24.10 and 25.12, exactly what CI does. `scripts/check-ucode.sh` compiles on the router instead when there is no docker. New ucode entry points are added to the compile list in `scripts/compile-ucode.sh`, to `lint-ucode.py`, and to the executables list in `.github/workflows/ci.yml`; a pure function gets a case in `tests/ucode/<module>.test.uc`.
|
- `scripts/ucode-container.sh` (needs docker): compiles every ucode file and runs `tests/ucode` on OpenWrt 24.10 and 25.12, exactly what CI does. `scripts/check-ucode.sh` compiles on the router instead when there is no docker. New ucode entry points are added to the compile list in `scripts/compile-ucode.sh`, to `lint-ucode.py`, and to the executables list in `.github/workflows/ci.yml`; a pure function gets a case in `tests/ucode/<module>.test.uc`.
|
||||||
- In `web/`: `npm run format:check`, `npm run typecheck` (sources and tests), `npm run i18n:check` (after changing visible text: `npm run i18n`, translate the new entries in each `ru.po`), `npm test`, `npm run build` — and commit the rebuilt bundles and the catalogs (CI fails on a changed or new file under `package/`).
|
- In `web/`: `npm run format:check`, `npm run typecheck` (sources and tests), `npm run lint` (oxlint), `npm run knip` (unused exports and dependencies), `npm run i18n:check` (after changing visible text: `npm run i18n`, translate the new entries in each `ru.po`), `npm test`, `npm run build` — and commit the catalogs (the bundles stay out of git; CI fails when the build leaves a file under `package/` that `.gitignore` does not cover).
|
||||||
- `shellcheck -S warning` for the shell scripts (CI finds them by shebang).
|
- `shellcheck -S warning` for the shell scripts (CI finds them by shebang).
|
||||||
- A tag builds only after CI passes on it (`build.yml` calls `ci.yml`).
|
- A tag builds only after CI passes on it (`build.yml` calls `ci.yml`).
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ follows a modern design.
|
|||||||
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
|
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Set up** in LuCI: <kbd>Network</kbd> › <kbd>Dawnline</kbd>, and follow the
|
2. **Set up** in LuCI: <kbd>Services</kbd> › <kbd>Dawnline</kbd>, and follow the
|
||||||
wizard. It suggests the port, the public address and the networks.
|
wizard. It suggests the port, the public address and the networks.
|
||||||
3. **Invite** someone: <kbd>Add person</kbd>, then send them the link or the
|
3. **Invite** someone: <kbd>Add person</kbd>, then send them the link or the
|
||||||
invite card with its QR code. They do the rest.
|
invite card with its QR code. They do the rest.
|
||||||
@@ -315,8 +315,10 @@ By hand: <kbd>Settings</kbd> › <kbd>Remove Dawnline from this router</kbd>
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
AmneziaVPN or AmneziaWG on phones and computers, and plain WireGuard when the
|
AmneziaVPN or AmneziaWG on phones and computers, V2RayTun on Android (its
|
||||||
disguise is off. The portal shows each person the app for their system and how
|
`awg://` link; not with the Maximum disguise, which it cannot
|
||||||
|
run yet),
|
||||||
|
and plain WireGuard when the disguise is off. The portal shows each person the app for their system and how
|
||||||
to add the connection in it.
|
to add the connection in it.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -378,6 +380,14 @@ are kept in `/var/run/dawnline` and flushed to flash at most hourly. Access
|
|||||||
changes reach the tunnel with `awg syncconf`, without restarting the interface;
|
changes reach the tunnel with `awg syncconf`, without restarting the interface;
|
||||||
`dawnline log` on the router shows the service log.
|
`dawnline log` on the router shows the service log.
|
||||||
|
|
||||||
|
Everything service-related also goes to the router's system log, one line per
|
||||||
|
event with its syslog priority: `logread -e dawnline` shows
|
||||||
|
`[info] [service] starting`, `[info] [apply] configuration applied in 310 ms · …`,
|
||||||
|
tunnels and the portal going down and back, crashes with what syslog knew about
|
||||||
|
them, every settings change (`admin changed settings · domain: lan → home`) and
|
||||||
|
people's and devices' changes. Settings → Logs & history → System log picks the
|
||||||
|
level: errors, warnings, normal or verbose (each step of a start and an apply).
|
||||||
|
|
||||||
## 🧰 Development
|
## 🧰 Development
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -400,7 +410,7 @@ scripts/ build, deploy and check scripts
|
|||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci
|
||||||
npm run format # Prettier
|
npm run format # Prettier
|
||||||
npm run ci # format check, types, catalogs, tests, minified bundles
|
npm run ci # format check, types, lint, unused code, catalogs, tests, minified bundles
|
||||||
npm run i18n # collect new strings into the catalogs (then translate them in ru.po)
|
npm run i18n # collect new strings into the catalogs (then translate them in ru.po)
|
||||||
|
|
||||||
scripts/lint-ucode.py # static ucode checks
|
scripts/lint-ucode.py # static ucode checks
|
||||||
@@ -412,8 +422,9 @@ scripts/capture-portal.mjs # the portal's from its demo, in Englis
|
|||||||
scripts/frame-screenshots.py # frame them for this README
|
scripts/frame-screenshots.py # frame them for this README
|
||||||
```
|
```
|
||||||
|
|
||||||
The web bundles and the catalogs are committed: CI fails when they are out of
|
The web bundles are built, not committed (`npm run build` before
|
||||||
date or a string is untranslated (`rules/i18n.md`). Pushing a tag `vX.Y.Z`
|
`scripts/build-packages.sh`); the catalogs are committed, and CI fails when they
|
||||||
|
are out of date or a string is untranslated (`rules/i18n.md`). Pushing a tag `vX.Y.Z`
|
||||||
(matching `PKG_VERSION`) builds the packages and their translations with the
|
(matching `PKG_VERSION`) builds the packages and their translations with the
|
||||||
OpenWrt SDK and publishes a release with `sha256sums.txt`.
|
OpenWrt SDK and publishes a release with `sha256sums.txt`.
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ Dawnline запускает сервер [AmneziaWG] на вашем роуте
|
|||||||
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
|
sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)"
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Настройте** в LuCI: <kbd>Network</kbd> › <kbd>Dawnline</kbd>, дальше по
|
2. **Настройте** в LuCI: <kbd>Services</kbd> › <kbd>Dawnline</kbd>, дальше по
|
||||||
мастеру. Он предложит порт, публичный адрес и сети.
|
мастеру. Он предложит порт, публичный адрес и сети.
|
||||||
3. **Пригласите** человека: <kbd>Добавить человека</kbd>, затем отправьте ему
|
3. **Пригласите** человека: <kbd>Добавить человека</kbd>, затем отправьте ему
|
||||||
ссылку или карточку приглашения с QR-кодом. Остальное он сделает сам.
|
ссылку или карточку приглашения с QR-кодом. Остальное он сделает сам.
|
||||||
@@ -318,8 +318,10 @@ sh /tmp/dawnline-uninstall.sh --dry-run
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
AmneziaVPN или AmneziaWG на телефонах и компьютерах, а обычный WireGuard, если
|
AmneziaVPN или AmneziaWG на телефонах и компьютерах, V2RayTun на Android (по
|
||||||
маскировка выключена. Портал показывает каждому приложение для его системы и
|
ссылке `awg://`; кроме максимальной маскировки, её он пока не
|
||||||
|
умеет), а
|
||||||
|
обычный WireGuard, если маскировка выключена. Портал показывает каждому приложение для его системы и
|
||||||
как добавить в нём подключение.
|
как добавить в нём подключение.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
@@ -382,6 +384,15 @@ AmneziaVPN или AmneziaWG на телефонах и компьютерах,
|
|||||||
чаще раза в час. Изменения доступа доходят до туннеля через `awg syncconf`, без
|
чаще раза в час. Изменения доступа доходят до туннеля через `awg syncconf`, без
|
||||||
перезапуска интерфейса; `dawnline log` на роутере показывает журнал служб.
|
перезапуска интерфейса; `dawnline log` на роутере показывает журнал служб.
|
||||||
|
|
||||||
|
Всё, что касается служб, попадает и в системный журнал роутера, строкой на
|
||||||
|
событие с приоритетом syslog: `logread -e dawnline` покажет
|
||||||
|
`[info] [service] starting`, `[info] [apply] configuration applied in 310 ms · …`,
|
||||||
|
падения и восстановление туннелей и портала, сбои с тем, что о них знал syslog,
|
||||||
|
каждое изменение настроек (`admin changed settings · domain: lan → home`) и
|
||||||
|
изменения людей и устройств. Уровень выбирается в «Настройки → Журналы и
|
||||||
|
история → Системный журнал»: ошибки, предупреждения, обычный или подробный
|
||||||
|
(каждый шаг запуска и применения настроек).
|
||||||
|
|
||||||
## 🧰 Разработка
|
## 🧰 Разработка
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -404,7 +415,7 @@ scripts/ скрипты сборки, деплоя и
|
|||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci
|
||||||
npm run format # Prettier
|
npm run format # Prettier
|
||||||
npm run ci # форматирование, типы, каталоги, тесты, минифицированные бандлы
|
npm run ci # форматирование, типы, линтер, неиспользуемый код, каталоги, тесты, бандлы
|
||||||
npm run i18n # собрать новые строки в каталоги (затем перевести их в ru.po)
|
npm run i18n # собрать новые строки в каталоги (затем перевести их в ru.po)
|
||||||
|
|
||||||
scripts/lint-ucode.py # статические проверки ucode
|
scripts/lint-ucode.py # статические проверки ucode
|
||||||
@@ -416,8 +427,9 @@ scripts/capture-portal.mjs # скриншоты портала д
|
|||||||
scripts/frame-screenshots.py # оформить их для README
|
scripts/frame-screenshots.py # оформить их для README
|
||||||
```
|
```
|
||||||
|
|
||||||
Бандлы и каталоги лежат в репозитории: CI падает, если они устарели или строка
|
Бандлы не лежат в репозитории, они собираются (`npm run build` перед
|
||||||
не переведена (`rules/i18n.md`). Тег `vX.Y.Z` (совпадающий с `PKG_VERSION`)
|
`scripts/build-packages.sh`); каталоги лежат, и CI падает, если они устарели или
|
||||||
|
строка не переведена (`rules/i18n.md`). Тег `vX.Y.Z` (совпадающий с `PKG_VERSION`)
|
||||||
собирает пакеты и переводы в OpenWrt SDK и публикует релиз с `sha256sums.txt`.
|
собирает пакеты и переводы в OpenWrt SDK и публикует релиз с `sha256sums.txt`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Builds luci-app-dawnline with the OpenWrt SDK.
|
# Builds luci-app-dawnline with the OpenWrt SDK.
|
||||||
# docker build -f build/Dockerfile --build-arg SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6 .
|
# docker build -f build/Dockerfile --build-arg SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6 .
|
||||||
# The web bundles (htdocs/.../app.js, portal assets) are built by npm first and
|
# The web bundles (htdocs/.../app.js, portal assets) are built by npm first
|
||||||
# committed; the SDK only packs files, so the package is the same on every arch.
|
# (not committed); the SDK only packs files, so the package is the same on every arch.
|
||||||
ARG SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6
|
ARG SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6
|
||||||
FROM ${SDK_IMAGE}
|
FROM ${SDK_IMAGE}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 388 KiB After Width: | Height: | Size: 387 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 186 KiB |
@@ -487,18 +487,19 @@ check_tools() {
|
|||||||
|
|
||||||
# ---------- downloads ----------
|
# ---------- downloads ----------
|
||||||
|
|
||||||
# fetch_once URL FILE [SECONDS]
|
# fetch_once URL FILE [SECONDS] [ACCEPT]
|
||||||
fetch_once() {
|
fetch_once() {
|
||||||
_fu="$1"
|
_fu="$1"
|
||||||
_fd="$2"
|
_fd="$2"
|
||||||
_ft="${3:-$DOWNLOAD_TIMEOUT}"
|
_ft="${3:-$DOWNLOAD_TIMEOUT}"
|
||||||
|
_fa="${4:-}"
|
||||||
rm -f "$_fd"
|
rm -f "$_fd"
|
||||||
case "$FETCHER" in
|
case "$FETCHER" in
|
||||||
curl)
|
curl)
|
||||||
run_logged download curl -fsSL --connect-timeout "$CONNECT_TIMEOUT" --max-time "$_ft" \
|
run_logged download curl -fsSL --connect-timeout "$CONNECT_TIMEOUT" --max-time "$_ft" \
|
||||||
--speed-limit 1024 --speed-time 30 -o "$_fd" "$_fu"
|
--speed-limit 1024 --speed-time 30 ${_fa:+-H "Accept: $_fa"} -o "$_fd" "$_fu"
|
||||||
;;
|
;;
|
||||||
*) run_logged download "$FETCHER" -q -T "$CONNECT_TIMEOUT" -O "$_fd" "$_fu" ;;
|
*) run_logged download "$FETCHER" -q -T "$CONNECT_TIMEOUT" ${_fa:+--header="Accept: $_fa"} -O "$_fd" "$_fu" ;;
|
||||||
esac
|
esac
|
||||||
_frc=$?
|
_frc=$?
|
||||||
[ "$_frc" -eq 0 ] && [ -s "$_fd" ] && return 0
|
[ "$_frc" -eq 0 ] && [ -s "$_fd" ] && return 0
|
||||||
@@ -531,16 +532,29 @@ asset_digest() {
|
|||||||
jsonfilter -i "$1" -e "@.assets[@.name='$2'].digest" 2>/dev/null | head -n 1 | sed -n 's/^sha256:\([0-9a-f]\{64\}\)$/\1/p'
|
jsonfilter -i "$1" -e "@.assets[@.name='$2'].digest" 2>/dev/null | head -n 1 | sed -n 's/^sha256:\([0-9a-f]\{64\}\)$/\1/p'
|
||||||
}
|
}
|
||||||
|
|
||||||
# download URL FILE LABEL [SHA256]: direct, then (only when the sha256 is
|
# A release file's URL in the GitHub API, from release JSON (empty if unknown).
|
||||||
# known) two mirrors, then direct again. A file whose sha256 doesn't match is
|
# Asked for application/octet-stream, it answers with the file itself.
|
||||||
# thrown away and the next source is tried; without a sha256 only GitHub
|
asset_api_url() {
|
||||||
# itself is used.
|
[ -s "$1" ] || return 0
|
||||||
|
jsonfilter -i "$1" -e "@.assets[@.name='$2'].url" 2>/dev/null | head -n 1 |
|
||||||
|
sed -n 's#^\(https://api\.github\.com/repos/[^/]*/[^/]*/releases/assets/[0-9][0-9]*\)$#\1#p'
|
||||||
|
}
|
||||||
|
|
||||||
|
# download URL FILE LABEL [SHA256] [API_URL]: without curl the API's URL
|
||||||
|
# first (github.com's redirect carries a Content-Security-Policy header that
|
||||||
|
# can outgrow uclient-fetch's 4 KB line buffer, and it stalls there), then
|
||||||
|
# direct, then (only when the sha256 is known) two mirrors, then direct again.
|
||||||
|
# A file whose sha256 doesn't match is thrown away and the next source is
|
||||||
|
# tried; without a sha256 only GitHub itself is used.
|
||||||
download() {
|
download() {
|
||||||
_du="$1"
|
_du="$1"
|
||||||
_dd="$2"
|
_dd="$2"
|
||||||
_dl="$3"
|
_dl="$3"
|
||||||
_dw="${4:-}"
|
_dw="${4:-}"
|
||||||
|
_da="${5:-}"
|
||||||
|
[ "$FETCHER" != curl ] || _da=""
|
||||||
set -- "$_du"
|
set -- "$_du"
|
||||||
|
[ -z "$_da" ] || set -- "$_da" "$_du"
|
||||||
if [ -n "$_dw" ]; then
|
if [ -n "$_dw" ]; then
|
||||||
for _m in $MIRRORS; do set -- "$@" "$_m$_du"; done
|
for _m in $MIRRORS; do set -- "$@" "$_m$_du"; done
|
||||||
fi
|
fi
|
||||||
@@ -555,7 +569,9 @@ download() {
|
|||||||
sleep 2
|
sleep 2
|
||||||
msg "Downloading $_dl via $(host_of "$_try") (attempt $_n/$_total)"
|
msg "Downloading $_dl via $(host_of "$_try") (attempt $_n/$_total)"
|
||||||
fi
|
fi
|
||||||
if fetch_once "$_try" "$_dd"; then
|
_acc=""
|
||||||
|
[ "$_try" != "$_da" ] || _acc="application/octet-stream"
|
||||||
|
if fetch_once "$_try" "$_dd" "" "$_acc"; then
|
||||||
if [ -n "$_dw" ] && [ "$(sha256sum "$_dd" 2>/dev/null | awk '{ print $1 }')" != "$_dw" ]; then
|
if [ -n "$_dw" ] && [ "$(sha256sum "$_dd" 2>/dev/null | awk '{ print $1 }')" != "$_dw" ]; then
|
||||||
warn "$(host_of "$_try") sent a file that doesn't match GitHub's sha256: discarded"
|
warn "$(host_of "$_try") sent a file that doesn't match GitHub's sha256: discarded"
|
||||||
rm -f "$_dd"
|
rm -f "$_dd"
|
||||||
@@ -1118,10 +1134,11 @@ confirm() {
|
|||||||
download_release_file() {
|
download_release_file() {
|
||||||
_name="$1"
|
_name="$1"
|
||||||
_sums="$TMP_DIR/sha256sums.txt"
|
_sums="$TMP_DIR/sha256sums.txt"
|
||||||
# The checksum: GitHub's own (API), else the release's sha256sums.txt straight from github.com.
|
# The checksum: GitHub's own (API), else the release's sha256sums.txt straight from GitHub.
|
||||||
_want="$(asset_digest "$TMP_DIR/release.json" "$_name")"
|
_want="$(asset_digest "$TMP_DIR/release.json" "$_name")"
|
||||||
if [ -z "$_want" ]; then
|
if [ -z "$_want" ]; then
|
||||||
[ -s "$_sums" ] || download "$ASSET_BASE/sha256sums.txt" "$_sums" sha256sums.txt || {
|
[ -s "$_sums" ] || download "$ASSET_BASE/sha256sums.txt" "$_sums" sha256sums.txt "" \
|
||||||
|
"$(asset_api_url "$TMP_DIR/release.json" sha256sums.txt)" || {
|
||||||
err "Download failed: sha256sums.txt (does release $VERSION exist?)"
|
err "Download failed: sha256sums.txt (does release $VERSION exist?)"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -1131,7 +1148,7 @@ download_release_file() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
download "$ASSET_BASE/$_name" "$TMP_DIR/$_name" "$_name" "$_want" || {
|
download "$ASSET_BASE/$_name" "$TMP_DIR/$_name" "$_name" "$_want" "$(asset_api_url "$TMP_DIR/release.json" "$_name")" || {
|
||||||
err "Download failed: $_name"
|
err "Download failed: $_name"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -1158,7 +1175,8 @@ download_awg() {
|
|||||||
_f="$TMP_DIR/$_p$_pf"
|
_f="$TMP_DIR/$_p$_pf"
|
||||||
# Verified when GitHub publishes the file's sha256 (then mirrors may serve it).
|
# Verified when GitHub publishes the file's sha256 (then mirrors may serve it).
|
||||||
_want="$(asset_digest "$TMP_DIR/awg-$_s.json" "$_p$_pf")"
|
_want="$(asset_digest "$TMP_DIR/awg-$_s.json" "$_p$_pf")"
|
||||||
if download "https://github.com/$_repo/releases/download/v$OWRT_RELEASE/$_p$_pf" "$_f" "$_p ($_repo)" "$_want" &&
|
if download "https://github.com/$_repo/releases/download/v$OWRT_RELEASE/$_p$_pf" "$_f" "$_p ($_repo)" "$_want" \
|
||||||
|
"$(asset_api_url "$TMP_DIR/awg-$_s.json" "$_p$_pf")" &&
|
||||||
verify_archive "$_f"; then
|
verify_archive "$_f"; then
|
||||||
_files="$_files $_f"
|
_files="$_files $_f"
|
||||||
else
|
else
|
||||||
@@ -1425,7 +1443,7 @@ on_pipe() {
|
|||||||
lan_url() {
|
lan_url() {
|
||||||
_ip="$(uci -q get network.lan.ipaddr 2>/dev/null | cut -d/ -f1 | awk '{ print $1 }')"
|
_ip="$(uci -q get network.lan.ipaddr 2>/dev/null | cut -d/ -f1 | awk '{ print $1 }')"
|
||||||
[ -n "$_ip" ] || _ip="192.168.1.1"
|
[ -n "$_ip" ] || _ip="192.168.1.1"
|
||||||
printf 'http://%s/cgi-bin/luci/admin/network/dawnline/server' "$_ip"
|
printf 'http://%s/cgi-bin/luci/admin/services/dawnline/server' "$_ip"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
@@ -1495,9 +1513,9 @@ main() {
|
|||||||
msg "Log: $LOG_FILE"
|
msg "Log: $LOG_FILE"
|
||||||
msg "Recovery snapshot: $SNAPSHOT_DIR"
|
msg "Recovery snapshot: $SNAPSHOT_DIR"
|
||||||
if [ "$MODE" = install ]; then
|
if [ "$MODE" = install ]; then
|
||||||
msg "Open LuCI → Network → Dawnline and run the setup wizard:"
|
msg "Open LuCI → Services → Dawnline and run the setup wizard:"
|
||||||
else
|
else
|
||||||
msg "Open LuCI → Network → Dawnline:"
|
msg "Open LuCI → Services → Dawnline:"
|
||||||
fi
|
fi
|
||||||
msg " $(lan_url)"
|
msg " $(lan_url)"
|
||||||
awg_netifd_restart
|
awg_netifd_restart
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-dawnline
|
PKG_NAME:=luci-app-dawnline
|
||||||
PKG_VERSION:=0.14.1
|
PKG_VERSION:=0.18.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
|
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
// Generated from dawnline/web — do not edit by hand.
|
|
||||||
'use strict';
|
|
||||||
'require baseclass';
|
|
||||||
'require dom';
|
|
||||||
'require poll';
|
|
||||||
'require rpc';
|
|
||||||
'require ui';
|
|
||||||
var va=Object.create;var ds=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var xa=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,ya=Object.prototype.hasOwnProperty;var ka=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var _a=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of xa(e))!ya.call(t,r)&&r!==o&&ds(t,r,{get:()=>e[r],enumerable:!(s=ba(e,r))||s.enumerable});return t};var Ca=(t,e,o)=>(o=t!=null?va(wa(t)):{},_a(e||!t||!t.__esModule?ds(o,"default",{value:t,enumerable:!0}):o,t));var _s=ka((ys,ks)=>{"use strict";var ws=(function(){var t=function(P,R){var w=236,k=17,y=P,O=o[R],b=null,f=0,T=null,C=[],A={},K=function(z,$){f=y*4+17,b=(function(E){for(var I=new Array(E),D=0;D<E;D+=1){I[D]=new Array(E);for(var W=0;W<E;W+=1)I[D][W]=null}return I})(f),Y(0,0),Y(f-7,0),Y(0,f-7),Z(),j(),me(z,$),y>=7&&te(z),T==null&&(T=ne(y,O,C)),ke(T,$)},Y=function(z,$){for(var E=-1;E<=7;E+=1)if(!(z+E<=-1||f<=z+E))for(var I=-1;I<=7;I+=1)$+I<=-1||f<=$+I||(0<=E&&E<=6&&(I==0||I==6)||0<=I&&I<=6&&(E==0||E==6)||2<=E&&E<=4&&2<=I&&I<=4?b[z+E][$+I]=!0:b[z+E][$+I]=!1)},Q=function(){for(var z=0,$=0,E=0;E<8;E+=1){K(!0,E);var I=r.getLostPoint(A);(E==0||z>I)&&(z=I,$=E)}return $},j=function(){for(var z=8;z<f-8;z+=1)b[z][6]==null&&(b[z][6]=z%2==0);for(var $=8;$<f-8;$+=1)b[6][$]==null&&(b[6][$]=$%2==0)},Z=function(){for(var z=r.getPatternPosition(y),$=0;$<z.length;$+=1)for(var E=0;E<z.length;E+=1){var I=z[$],D=z[E];if(b[I][D]==null)for(var W=-2;W<=2;W+=1)for(var ee=-2;ee<=2;ee+=1)W==-2||W==2||ee==-2||ee==2||W==0&&ee==0?b[I+W][D+ee]=!0:b[I+W][D+ee]=!1}},te=function(z){for(var $=r.getBCHTypeNumber(y),E=0;E<18;E+=1){var I=!z&&($>>E&1)==1;b[Math.floor(E/3)][E%3+f-8-3]=I}for(var E=0;E<18;E+=1){var I=!z&&($>>E&1)==1;b[E%3+f-8-3][Math.floor(E/3)]=I}},me=function(z,$){for(var E=O<<3|$,I=r.getBCHTypeInfo(E),D=0;D<15;D+=1){var W=!z&&(I>>D&1)==1;D<6?b[D][8]=W:D<8?b[D+1][8]=W:b[f-15+D][8]=W}for(var D=0;D<15;D+=1){var W=!z&&(I>>D&1)==1;D<8?b[8][f-D-1]=W:D<9?b[8][15-D-1+1]=W:b[8][15-D-1]=W}b[f-8][8]=!z},ke=function(z,$){for(var E=-1,I=f-1,D=7,W=0,ee=r.getMaskFunction($),X=f-1;X>0;X-=2)for(X==6&&(X-=1);;){for(var ve=0;ve<2;ve+=1)if(b[I][X-ve]==null){var Le=!1;W<z.length&&(Le=(z[W]>>>D&1)==1);var re=ee(I,X-ve);re&&(Le=!Le),b[I][X-ve]=Le,D-=1,D==-1&&(W+=1,D=7)}if(I+=E,I<0||f<=I){I-=E,E=-E;break}}},U=function(z,$){for(var E=0,I=0,D=0,W=new Array($.length),ee=new Array($.length),X=0;X<$.length;X+=1){var ve=$[X].dataCount,Le=$[X].totalCount-ve;I=Math.max(I,ve),D=Math.max(D,Le),W[X]=new Array(ve);for(var re=0;re<W[X].length;re+=1)W[X][re]=255&z.getBuffer()[re+E];E+=ve;var ze=r.getErrorCorrectPolynomial(Le),Re=a(W[X],ze.getLength()-1),is=Re.mod(ze);ee[X]=new Array(ze.getLength()-1);for(var re=0;re<ee[X].length;re+=1){var as=re+is.getLength()-ee[X].length;ee[X][re]=as>=0?is.getAt(as):0}}for(var ls=0,re=0;re<$.length;re+=1)ls+=$[re].totalCount;for(var ao=new Array(ls),hn=0,re=0;re<I;re+=1)for(var X=0;X<$.length;X+=1)re<W[X].length&&(ao[hn]=W[X][re],hn+=1);for(var re=0;re<D;re+=1)for(var X=0;X<$.length;X+=1)re<ee[X].length&&(ao[hn]=ee[X][re],hn+=1);return ao},ne=function(z,$,E){for(var I=l.getRSBlocks(z,$),D=d(),W=0;W<E.length;W+=1){var ee=E[W];D.put(ee.getMode(),4),D.put(ee.getLength(),r.getLengthInBits(ee.getMode(),z)),ee.write(D)}for(var X=0,W=0;W<I.length;W+=1)X+=I[W].dataCount;if(D.getLengthInBits()>X*8)throw"code length overflow. ("+D.getLengthInBits()+">"+X*8+")";for(D.getLengthInBits()+4<=X*8&&D.put(0,4);D.getLengthInBits()%8!=0;)D.putBit(!1);for(;!(D.getLengthInBits()>=X*8||(D.put(w,8),D.getLengthInBits()>=X*8));)D.put(k,8);return U(D,I)};A.addData=function(z,$){$=$||"Byte";var E=null;switch($){case"Numeric":E=c(z);break;case"Alphanumeric":E=p(z);break;case"Byte":E=u(z);break;case"Kanji":E=g(z);break;default:throw"mode:"+$}C.push(E),T=null},A.isDark=function(z,$){if(z<0||f<=z||$<0||f<=$)throw z+","+$;return b[z][$]},A.getModuleCount=function(){return f},A.make=function(){if(y<1){for(var z=1;z<40;z++){for(var $=l.getRSBlocks(z,O),E=d(),I=0;I<C.length;I++){var D=C[I];E.put(D.getMode(),4),E.put(D.getLength(),r.getLengthInBits(D.getMode(),z)),D.write(E)}for(var W=0,I=0;I<$.length;I++)W+=$[I].dataCount;if(E.getLengthInBits()<=W*8)break}y=z}K(!1,Q())},A.createTableTag=function(z,$){z=z||2,$=typeof $>"u"?z*4:$;var E="";E+='<table style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: "+$+"px;",E+='">',E+="<tbody>";for(var I=0;I<A.getModuleCount();I+=1){E+="<tr>";for(var D=0;D<A.getModuleCount();D+=1)E+='<td style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: 0px;",E+=" width: "+z+"px;",E+=" height: "+z+"px;",E+=" background-color: ",E+=A.isDark(I,D)?"#000000":"#ffffff",E+=";",E+='"/>';E+="</tr>"}return E+="</tbody>",E+="</table>",E},A.createSvgTag=function(z,$,E,I){var D={};typeof arguments[0]=="object"&&(D=arguments[0],z=D.cellSize,$=D.margin,E=D.alt,I=D.title),z=z||2,$=typeof $>"u"?z*4:$,E=typeof E==Line truncated
|
|
||||||
`}return E%2&&z>0?Re.substring(0,Re.length-E-1)+Array(E+1).join("▀"):Re.substring(0,Re.length-1)};return A.createASCII=function(z,$){if(z=z||1,z<2)return fe($);z-=1,$=typeof $>"u"?z*2:$;var E=A.getModuleCount()*z+$*2,I=$,D=E-$,W,ee,X,ve,Le=Array(z+1).join("██"),re=Array(z+1).join(" "),ze="",Re="";for(W=0;W<E;W+=1){for(X=Math.floor((W-I)/z),Re="",ee=0;ee<E;ee+=1)ve=1,I<=ee&&ee<D&&I<=W&&W<D&&A.isDark(X,Math.floor((ee-I)/z))&&(ve=0),Re+=ve?Le:re;for(X=0;X<z;X+=1)ze+=Re+`
|
|
||||||
`}return ze.substring(0,ze.length-1)},A.renderTo2dContext=function(z,$){$=$||2;for(var E=A.getModuleCount(),I=0;I<E;I++)for(var D=0;D<E;D++)z.fillStyle=A.isDark(I,D)?"black":"white",z.fillRect(I*$,D*$,$,$)},A};t.stringToBytesFuncs={default:function(P){for(var R=[],w=0;w<P.length;w+=1){var k=P.charCodeAt(w);R.push(k&255)}return R}},t.stringToBytes=t.stringToBytesFuncs.default,t.createStringToBytes=function(P,R){var w=(function(){for(var y=h(P),O=function(){var j=y.read();if(j==-1)throw"eof";return j},b=0,f={};;){var T=y.read();if(T==-1)break;var C=O(),A=O(),K=O(),Y=String.fromCharCode(T<<8|C),Q=A<<8|K;f[Y]=Q,b+=1}if(b!=R)throw b+" != "+R;return f})(),k=63;return function(y){for(var O=[],b=0;b<y.length;b+=1){var f=y.charCodeAt(b);if(f<128)O.push(f);else{var T=w[y.charAt(b)];typeof T=="number"?(T&255)==T?O.push(T):(O.push(T>>>8),O.push(T&255)):O.push(k)}}return O}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},s={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var P=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],R=1335,w=7973,k=21522,y={},O=function(b){for(var f=0;b!=0;)f+=1,b>>>=1;return f};return y.getBCHTypeInfo=function(b){for(var f=b<<10;O(f)-O(R)>=0;)f^=R<<O(f)-O(R);return(b<<10|f)^k},y.getBCHTypeNumber=function(b){for(var f=b<<12;O(f)-O(w)>=0;)f^=w<<O(f)-O(w);return b<<12|f},y.getPatternPosition=function(b){return P[b-1]},y.getMaskFunction=function(b){switch(b){case s.PATTERN000:return function(f,T){return(f+T)%2==0};case s.PATTERN001:return function(f,T){return f%2==0};case s.PATTERN010:return function(f,T){return T%3==0};case s.PATTERN011:return function(f,T){return(f+T)%3==0};case s.PATTERN100:return function(f,T){return(Math.floor(f/2)+Math.floor(T/3))%2==0};case s.PATTERN101:return function(f,T){return f*T%2+f*T%3==0};case s.PATTERN110:return function(f,T){return(f*T%2+f*T%3)%2==0};case s.PATTERN111:return function(f,T){return(f*T%3+(f+T)%2)%2==0};default:throw"bad maskPattern:"+b}},y.getErrorCorrectPolynomial=function(b){for(var f=a([1],0),T=0;T<b;T+=1)f=f.multiply(a([1,i.gexp(T)],0));return f},y.getLengthInBits=function(b,f){if(1<=f&&f<10)switch(b){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw"mode:"+b}else if(f<27)switch(b){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw"mode:"+b}else if(f<41)switch(b){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw"mode:"+b}else throw"type:"+f},y.getLostPoint=function(b){for(var f=b.getModuleCount(),T=0,C=0;C<f;C+=1)for(var A=0;A<f;A+=1){for(var K=0,Y=b.isDark(C,A),Q=-1;Q<=1;Q+=1)if(!(C+Q<0||f<=C+Q))for(var j=-1;j<=1;j+=1)A+j<0||f<=A+j||Q==0&&j==0||Y==b.isDark(C+Q,A+j)&&(K+=1);K>5&&(T+=3+K-5)}for(var C=0;C<f-1;C+=1)for(var A=0;A<f-1;A+=1){var Z=0;b.isDark(C,A)&&(Z+=1),b.isDark(C+1,A)&&(Z+=1),b.isDark(C,A+1)&&(Z+=1),b.isDark(C+1,A+1)&&(Z+=1),(Z==0||Z==4)&&(T+=3)}for(var C=0;C<f;C+=1)for(var A=0;A<f-6;A+=1)b.isDark(C,A)&&!b.isDark(C,A+1)&&b.isDark(C,A+2)&&b.isDark(C,A+3)&&b.isDark(C,A+4)&&!b.isDark(C,A+5)&&b.isDark(C,A+6)&&(T+=40);for(var A=0;A<f;A+=1)for(var C=0;C<f-6;C+=1)b.isDark(C,A)&&!b.isDark(C+1,A)&&b.isDark(C+2,A)&&b.isDark(C+3,A)&&b.isDark(C+4,A)&&!b.isDark(C+5,A)&&b.isDark(C+6,A)&&(T+=40);for(var te=0,A=0;A<f;A+=1)for(var C=0;C<f;C+=1)b.isDark(C,A)&&(te+=1);var me=Math.abs(100*te/f/f-50)/5;return T+=me*10,T},y})(),i=(function(){for(var P=new Array(256),R=new Array(256),w=0;w<8;w+=1)P[w]=1<<w;for(var w=8;w<256;w+=1)P[w]=P[w-4]^P[w-5]^P[w-6]^P[w-8];for(var w=0;w<255;w+=1)R[P[w]]=w;var k={};return k.glog=function(y){if(y<1)throw"glog("+y+")";return R[y]},k.gexp=function(y){for(;y<0;)y+=255;for(;y>=256;)y-=255;return P[y]},k})();function a(P,R){if(typeof P.length>"u")throw P.length+"/"+R;var w=(function(){for(var y=0;y<P.length&&P[y]==0;)y+=1;for(var O=new Array(P.length-y+R),b=0;b<P.length-y;b+=1)O[b]=P[b+y];return O})(),k={};return k.getAt=function(y){return w[y]},k.getLength=function(){return w.length},k.multiply=function(y){for(var O=new Array(k.getLength()+y.getLength()-1),b=0;b<k.getLength();b+=1)for(var f=0;f<y.getLength();f+=1)O[b+f]^=i.gexp(i.glog(k.getAt(b))+i.glog(y.getAt(f)));return a(O,0)},k.mod=function(y){if(k.getLengt
Line truncated
|
|
||||||
`)}function ol(t){let e=new Map(t.people.map(s=>[s.id,s.name])),o=new Map(t.people.flatMap(s=>s.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Xe(t,e,o,s="",r=[]){let i=ol(t),a=[...e.map(u=>({ts:u.ts,category:Zt(u.type),type:u.type,person:u.person?i.people.get(u.person)??u.pname??u.person:"",device:u.device?i.devices.get(u.device)??u.dname??u.device:"",detail:u.detail??"",where:u.where??"",by:Ve(u)??""})),...r.map(u=>({ts:u.ts,category:"system",type:`${u.src}.${u.level}`,person:"",device:"",detail:`${u.who?`${u.who} `:""}${u.msg}${u.detail?`
|
|
||||||
${u.detail}`:""}`,where:Qt(u.src),by:""}))].sort((u,g)=>u.ts-g.ts).map(({ts:u,...g})=>({time:new Date(u*1e3).toISOString(),...g})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${s?`-${s}`:""}-${l}.${o}`;if(o==="json"){Ae(d,JSON.stringify(a,null,2),"application/json");return}let c=["time","category","type","person","device","detail","where","by"],p={time:_("Time"),category:_("Category"),type:_("Type"),person:_("Person"),device:_("Device"),detail:_("Detail"),where:_("Where"),by:_("By")};Ae(d,nr(c,a,p),"text/csv")}var sl=["","7","30","90"],rl=t=>t?G(Number(t),"Older than %s day","Older than %s days"):_("Everything"),or=t=>t?G(t,"%s event removed","%s events removed"):_("Nothing matched");function dt(t,e,o,s,r,i=!1){let a=n("select",{class:"cbi-input-select"},[n("option",{value:""},_("All categories")),...Rt.map(d=>n("option",{value:d,selected:d===r?"selected":null},Ke(d))),i?n("option",{value:"system",selected:r==="system"?"selected":null},_("System")):""]),l=n("select",{class:"cbi-input-select"},sl.map(d=>n("option",{value:d},rl(d))));ae(t,[n("p",{class:"dl-muted"},`${e} ${_("This cannot be undone; export first if you want a copy.")}`),n("label",{class:"dl-fld"},[n("span",{class:"dl-fld-label"},_("Category")),a]),n("label",{class:"dl-fld"},[n("span",{class:"dl-fld-label"},_("Which events")),l])],[de()," ",H(_("Clear"),async()=>{let d=0;if(a.value!=="system")try{d+=(await N.logsClear({...o,category:a.value,older_days:l.value})).removed}catch(c){F(_e(c),"error",1e4);return}if(i&&(a.value==="system"||a.value===""))try{d+=(await N.serviceLogClear(l.value)).removed}catch(c){le();let p=m(_("The service log was not cleared: %s"),_e(c));F(a.value==="system"?p:`${m(_("Activity: %s."),or(d).toLowerCase())} ${p}`,"error",1e4),s();return}le(),F(or(d),"success",3e3),s()},"negative")])}function It(t,e,o,s){let r=t==="device"?m(_("Clears %s's daily and monthly traffic history. Their person's totals and data limit are not changed."),o):t==="person"?m(_("Clears %s's traffic history and that of their devices. Their data limit starts again from zero."),o):_("Clears traffic history for everyone. Data limits start again from zero.");ae(t==="all"?_("Reset all traffic history?"):m(_("Reset traffic history for %s?"),o),[n("p",{class:"dl-muted"},r)],[de()," ",H(_("Reset"),async()=>{await q(()=>N.usageClear(t,e),_("Traffic history reset"))&&(le(),s())},"negative")])}var il={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"",s4:"",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},al={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function ll(t){let e={};for(let[o,s]of Object.entries(al))t[o]!=null&&t[o]!==""&&(e[s]=String(t[o]));return e}function dl(t,e){let o=t.amnezia,s=o.obfuscation??{},r=d=>s[d]!=null&&s[d]!==""?String(s[d]):il[d],i=o.host.replace(/^\[(.*)\]$/,"$1"),a={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...ll(s),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:t.conf.replace(/\r?\n/g,`\r
|
|
||||||
`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(a),port:String(o.port),protocol_version:s.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0],l.dns2=o.dns[1]||o.dns[0]),l}function cl(t){let e="";for(let o=0;o<t.length;o+=32768)e+=String.fromCharCode(...t.subarray(o,o+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function pl(t){let e=globalThis;if(typeof e.CompressionStream>"u")return null;try{let o=new e.Blob([t]).stream().pipeThrough(new e.CompressionStream("deflate")),s=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+s.length);return new DataView(r.buffer).setUint32(0,t.length,!1),r.set(s,4),r}catch{return null}}async function Po(t,e,o=!0){let s=new TextEncoder().encode(JSON.stringify(dl(t,e))),r=o?await pl(s):null;return`vpn://${cl(r??s)}`}function rr(){return[{id:"off",title:_("Off"),ic:"zap",stealth:0,speed:4,text:_("Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block."),apps:_("Any WireGuard app"),short:_("Any WireGuard app")},{id:"balanced",title:_("Balanced"),ic:"shield",stealth:3,speed:4,needs:"v2",text:_("AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk."),apps:_("AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps"),short:_("AmneziaWG 2.0+ apps")},{id:"max",title:_("Maximum"),ic:"lock",stealth:4,speed:3,needs:"v3",text:_("AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS."),apps:_("Apps with AmneziaWG 3.1 (current AmneziaVPN)"),short:_("AmneziaWG 3.1 apps")}]}var Xt=t=>rr().find(e=>e.id===t),$n=t=>t.v3?"max":t.v2?"balanced":"off",en=t=>t==="standard"?_("Standard (old)"):t==="strong"?_("Strong (old)"):null;function ul(t,e){return e?t==="v2"?_("Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on)."):_("Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."):t==="v2"?_("Needs AmneziaWG on the router."):_("Needs AmneziaWG 3.1 on the router: install it first.")}function sr(t,e){return n("span",{class:"dl-dots",title:m(_("%s: %s of 4"),e,t)},[n("span",{class:"dl-dots-label"},e),n("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>n("i",{class:o<t?"on":""})))])}function Dn(t,e,o,s,r=!0){let i=n("div",{class:"dl-methods",role:"radiogroup","aria-label":_("Disguise method")}),a=()=>dom.content(i,rr().map(l=>{let d=!l.needs||t[l.needs],c=l.id===e;return n("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,a(),o(l.id))}},[n("div",{class:"dl-method-head"},[n("span",{class:"dl-method-ic"},v(l.ic)),n("b",{},l.title),l.id===s?n("span",{class:"dl-pill ok"},_("Current")):""]),n("p",{},l.text),n("div",{class:"dl-method-meters"},[sr(l.stealth,_("Stealth")),sr(l.speed,_("Speed"))]),n("div",{class:"dl-method-foot"},d?[v(l.id==="off"?"wireguard":"amneziawg"),n("span",{},l.apps)]:[v("alert"),n("span",{},ul(l.needs,r))])])}));return a(),i}function ir(t,e){return n("div",{class:"dl-corehead"},[n("h3",{},t),e?n("span",{class:"dl-sub"},e):""])}var ar=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function ml(t,e){let o=p=>p==="header_protection_key"?e:t[p]!=null&&t[p]!=="",s=ar.filter(([p])=>o(p));if(!s.length)return null;let r=(p,u)=>n("span",{class:"dl-pv"},[n("i",{},u),n("b",{},p==="header_protection_key"?_("set","key"):t[p])]),i=(p,u,g,M)=>{let x=ar.filter(([h])=>M.includes(h)&&o(h));return x.length?n("div",{class:"dl-pgroup"},[n("div",{class:"dl-pgroup-head"},[v(u),n("b",{},p)]),n("p",{},g),n("div",{class:"dl-pvals"},x.map(([h,S])=>r(h,S)))]):""},a=Number(t.jc||0),l=(t.i1??"").includes("0x8580")?_("A first packet shaped like a DNS answer."):_("Extra packets sent before the handshake."),d=s.filter(([p])=>p!=="header_protection_key").map(([p,u])=>`${u} = ${t[p]}`).join(`
|
|
||||||
`),c=n("div",{class:"dl-pgrid"},[i(_("Junk packets"),"zap",a?m(N_(a,"%s random packet of %s–%s bytes before each handshake.","%s random packets of %s–%s bytes before each handshake."),V(a),t.jmin,t.jmax):_("No junk packets."),["jc","jmin","jmax"]),i(_("Padding"),"archive",_("Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard."),["s1","s2","s3","s4"]),i(_("Packet types"),"key",_("The values that replace WireGuard’s recognisable message types."),["h1","h2","h3","h4"]),i(_("Signatures"),"globe",l,["i1","i2","i3","i4","i5"]),i(_("Protection"),"lock",_("AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets."),["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),i(_("Timing"),"clock",_("Handshake and key timers vary within these ranges instead of WireGuard’s fixed values."),["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return n("details",{class:"dl-params"},[n("summary",{},[v("chevron"),n("span",{},_("Current parameters")),n("span",{class:"dl-pcount"},String(s.length)),n("span",{class:"dl-spacer"}),n("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),xe(d,e?_("Parameters copied. The header protection key is in each device’s file."):_("Parameters copied"))}},_("Copy as config"))]),c])}function lr(t,e){if(/^\s*\[.+\]\s*$/.test(t))return n("span",{class:"dl-conf-sec"},t);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(t);if(!o)return document.createTextNode(t);let s=/^(\s*)(PrivateKey|PresharedKey)\b/.test(t);return n("span",{},[n("span",{class:"dl-conf-k"},o[1])," ",s&&!e?n("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function hl(t){let e=!1,o=n("pre",{class:"dl-conf"}),s=()=>dom.content(o,t.conf.split(`
|
|
||||||
`).flatMap((a,l)=>l?[`
|
|
||||||
`,lr(a,e)]:[lr(a,e)])),r=n("button",{type:"button",class:"dl-chipbtn",click:a=>{a.preventDefault(),e=!e,dom.content(r,[v(e?"x":"key"),e?_("Hide key"):_("Show key")]),s()}},[v("key"),_("Show key")]);s();let i=new Blob([t.conf]).size;return n("div",{class:"dl-stack gap8"},[n("div",{class:"dl-filecard"},[n("span",{class:"dl-filecard-ic"},".conf"),n("span",{class:"dl-stack"},[n("span",{class:"dl-mono dl-ellipsis"},t.filename),n("span",{class:"dl-sub"},`AmneziaWG · ${G(i,"%s byte","%s bytes")}`)]),H([v("download")," ",_("Download")],()=>Ae(t.filename,t.conf,"application/octet-stream"),"positive")]),n("details",{class:"dl-params"},[n("summary",{},[v("chevron"),n("span",{},_("Configuration")),n("span",{class:"dl-spacer"}),r,n("button",{type:"button",class:"dl-chipbtn",click:a=>{a.preventDefault(),xe(t.conf,_("Configuration copied"))}},[v("copy"),_("Copy")])]),o])])}function $o(t){let e=t.amnezia.obfuscation??{},o={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([s,r])=>r==null||r===""||r===(o[s]??"0"))}async function fl(t,e="file"){if(!t.has_private_key)return n("div",{class:"dl-hint"},_("This device generated its own keys in the browser, so its full configuration only exists on that device."));let o=await Po(t,t.server),s={qr:()=>n("div",{class:"dl-qr-pane"},[_n(t.conf),n("span",{class:"dl-sub"},$o(t)?_("Scan with AmneziaVPN or any WireGuard app on the device."):_("Scan with AmneziaVPN or AmneziaWG on the device."))]),key:()=>n("div",{class:"dl-stack gap8"},[n("div",{class:"dl-linkbox"},[n("span",{class:"dl-mono"},o),H(_("Copy"),()=>xe(o,_("Key copied")))]),n("span",{class:"dl-sub"},m(_("AmneziaVPN → %s. Keep it private."),["+",_("Insert","AmneziaVPN app"),_("Continue","AmneziaVPN app")].join(" → ")))]),file:()=>hl(t)},r=n("div",{class:"dl-connect-body"}),i=n("div",{class:"dl-seg"}),a=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(r,s[l]())};for(let[l,d]of[["file",_("File")],["key",_("Key")],["qr",_("QR code")]])i.appendChild(n("button",{type:"button","data-id":l,click:()=>a(l)},d));return a(e),n("div",{class:"dl-stack gap12"},[i,r])}async function gl(t,e,o,s){let r=Xt(o),a=t.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await pe(s?_("Generate new disguise values?"):m(_("Switch to %s?"),r.title),[G(a,"%s AmneziaWG device stops connecting until it imports its configuration again (from their personal link or from you).","%s AmneziaWG devices stop connecting until they import their configuration again (from their personal link or from you)."),o==="max"?_("They need an app with AmneziaWG 3.1."):o==="balanced"?_("They need an app with AmneziaWG 2.0 or newer."):"",t.st.servers.length===1&&a?_("To keep the old disguise for some people, add a second server and move them there."):""].filter(Boolean).join(" "),s?_("Generate and apply"):_("Switch and apply"),!0)&&await q(()=>N.serverObfuscation(e.id,o),s?_("New values applied"):m(_("%s applied"),r.title))&&(F(_("Devices are marked “Update config” until they import again."),"info",6e3),await t.refresh())}function vl(t,e){let o=t.st,s=ue(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=ue(e.mtu?String(e.mtu):"",{placeholder:_("Auto"),inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=ue(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=Xt(e.preset)?e.preset:void 0,l=a??$n(o.awg),d=H("",()=>gl(t,e,l,l===a),"neutral"),c=()=>dom.content(d,l===a?[v("reset")," ",_("Generate new values")]:[m(_("Switch to %s"),Xt(l).title)]);c();let p=o.awg_state?.tools!==!1,u=[],g=Ce(_("UDP port"),s,()=>Jt(Number(s.value),u,[_("Opened on the WAN firewall automatically."),Number(s.value)===4500?_("4500 is IPsec’s port: most networks let it through."):""].filter(Boolean).join(" ")));N.serverPorts(e.id).then(h=>{u=h.udp_taken??[],g.refresh()}).catch(()=>{});let M=Ce("MTU",r,()=>$s(r.value,e.mtus)),x=Ce(_("Keep-alive"),i,()=>Ds(i.value));return Vt("",[ir("AmneziaWG",e.ifname),ye("globe",_("Listening"),_("Where devices reach this core from the internet"),[g]),ye("file",_("In every device configuration"),_("Changing these marks devices “Update config” until they import again"),[M,x]),ye("shield",_("Disguise"),_("So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard"),[en(e.preset)?yt("warn",oe(_("%s is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to %s or %s: devices import their configuration again."),n("b",{},en(e.preset)),n("b",{},_("Balanced")),n("b",{},_("Maximum")))):"",Dn(o.awg,l,h=>{l=h,c()},a,p),p&&!o.awg.v3?yt("info",oe(_("This router runs an older AmneziaWG. %s becomes available with kmod-amneziawg and amneziawg-tools 3.1."),n("b",{},_("Maximum")))):"",ml(e.obf??{},e.hpk)??"",n("div",{class:"dl-row-end"},[n("span",{class:"dl-sub"},_("Applies at once: every AmneziaWG device imports its configuration again.")),d])]),n
Line truncated
|
|
||||||
`),_("Log copied")))]),p,u]),[g],"wide"),x([n("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?_("Checking…"):_("Working…"))]);let S=o??null,B=o?.id,P,R=0,w=T=>{B!==T.id&&(B=T.id,e.onJob?.(T))};if(o)e.onJob?.(o);else try{let T=await N.updatesStatus().catch(()=>null);P=T?.job?.id,R=T?.now??0;let C=await N.updatesRun(t);C.job&&C.job.state==="running"&&C.job.id!==P&&(S=C.job,w(C.job))}catch(T){return M=[_e(T)],p.textContent=M[0],dom.content(u,n("div",{class:"dl-comp-status warn"},[v("alert"),n("span",{},_e(T))])),x([h(!0)]),F(_e(T),"error"),null}let k=null,y=0;for(;;){if(await Vo(1e3),k=await N.updatesStatus().catch(()=>null),!k){if(++y>60)break;continue}y=0;let T=k.job;if(!T||!oi(T,B,P,R)){if(Date.now()-i>15e3)break;continue}if(w(T),S=T,T.log.length){M=T.log;let C=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=M.join(`
|
|
||||||
`),C&&(p.scrollTop=p.scrollHeight)}if(l.textContent=ti(T,e.version??""),!l.isConnected&&l.textContent&&a.after(l),c.textContent=ei((T.finished??k.now)-T.started),T.state==="running"){d.hidden=!T.phase,d.textContent=T.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!S||S.state==="running")return d.className="dl-pill warn",d.textContent=_("No answer"),dom.content(u,n("div",{class:"dl-comp-status warn"},[v("alert"),n("span",{},_("The router stopped answering. The job may still finish: reopen Components in a minute."))])),x([h()]),e.onDone?.(k),S;if(S.state==="failed")return d.className="dl-pill bad",d.textContent=_("Failed"),dom.content(u,n("div",{class:"dl-comp-status bad"},[v("x"),n("span",{},[n("b",{},(S.error??_("Operation failed")).replace(/\.$/,"")),r?"":`. ${_("Nothing else was changed.")}`])])),x([H(_("Copy log"),()=>xe(M.join(`
|
|
||||||
`),_("Log copied"))),h(!0)]),F(`${Un(s)??_("Update","noun")}: ${S.error??_("failed")}`,"error"),e.onDone?.(k),S;if(d.className="dl-pill ok",d.textContent=_("Finished"),r&&k){let T=ni(k,s);if(dom.content(u,n("div",{class:`dl-comp-status ${T.tone}`},[v(T.tone==="ok"?"check":T.tone==="warn"?"alert":"download"),n("span",{},T.text)])),F(T.text,T.tone==="warn"?"warning":"success"),e.onDone?.(k),T.update&&e.onUpdate){let C=k;x([h(),H(m(_("Update to %s"),T.update),()=>e.onUpdate(C),"positive")])}else x([h()]),T.tone==="ok"&&setTimeout(()=>u.isConnected&&le(),1200);return S}let O=/^app:(lang:|nolang$)/.exec(S.component??"");if(O){let T=()=>{ui.menu?.flushCache(),location.reload()};return dom.content(u,n("div",{class:"dl-comp-status ok"},[v("check"),n("span",{},[n("b",{},O[1]==="nolang"?_("The translation is removed."):_("The translation is installed."))," ",_("Reloading the page…")])])),x([h(),H(_("Reload now"),T,"positive")]),await Vo(4e3),u.isConnected&&T(),S}if(s==="app"&&S.to){let T=S.to,C=n("span",{},_("Waiting for the router to restart its services…"));dom.content(u,n("div",{class:"dl-comp-status ok"},[v("check"),n("span",{},[n("b",{},m(_("Dawnline %s is installed."),T))," ",C])]));let A=()=>{ui.menu?.flushCache(),location.reload()};x([h(),H(_("Reload now"),A,"positive")]),F(m(_("Dawnline updated to %s"),T),"success",6e3);for(let K=1;K<=30;K++)if(C.textContent=m(_("Waiting for the router to restart its services (%s of 30)…"),K),await Vo(1500),(await N.updatesStatus().catch(()=>null))?.version===T)return C.textContent=_("Services are back. Reloading…"),setTimeout(A,800),S;return C.textContent=_("Services restarted. Reload the page to use the new version."),S}let b=[...S.result?.pkgs?.updated??[],...S.result?.pkgs?.installed??[]],f=s==="pkgs"?b.length?m(_("Updated %s"),b.join(", ")):_("Updated system packages"):s==="amneziawg"?S.to?m(_("AmneziaWG %s is installed"),S.to):_("AmneziaWG is installed"):_("Operation completed");return dom.content(u,n("div",{class:"dl-comp-status ok"},[v("check"),n("span",{},f)])),x([h()]),F(f,"success"),e.onDone?.(k),S}function Kl(t){return{https:[_("Install HTTPS for the portal?"),_("Installing HTTPS for the portal")],acme:[_("Install ACME certificates?"),_("Installing ACME certificates")],home:[_("Install the home-like link?"),_("Installing the home-like link")],awg:[_("Install AmneziaWG?"),_("Installing AmneziaWG")]}[t]}async function si(t,e,o,s){let[r,i]=Kl(e);return!await pe(r,o,_("Install"))||(await dn(t,{title:i}))?.state!=="done"?!1:(setTimeout(()=>s?.(),4e3),!0)}function Gn(t){return si("amneziawg:auto","awg",_("Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds."),t)}async function cn(t,e,o){return t==="awg"?Gn(o):e.length?si(`pkgs:${e.join(",")}`,t,m(_("%s from the OpenWrt feeds. Dawnline sets the rest up when they arrive."),e.join(", ")),o):!0}async function ri(t,e){if(t==="awg")return Gn(e);let o=await q(()=>N.updatesStatus());return o?cn(t,o.needs?.[t]??[],e):!1}var Vl=()=>[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn",_("VPN & tunnels")],["other",_("Other")]],Yl={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Yo(t){let e=n("b",{},oe(_("add its interface %s to their source interfaces yourself"),n("span",{class:"dl-mono"},t)));return[...oe(_("Off: internet traffic goes straight to the WAN, the fastest way. DNS still goes through this router. Proxies and filters here handle the tunnel only if you %s."),e)," ",n("span",{class:"dl-warn"},_("If the router’s DNS hands out proxy addresses, those sites won’t open without it."))]}function Jo(){return wt(_("Slower: every packet crosses the router twice. On a dual-core router expect up to a third less speed, and lost packets at full load."))}function ii(t,e,o){let s=t.id,r=e,i=n("div",{class:"dl-stack gap16"},n("section",{class:"dl-setsec"},n("div",{class:"dl-setsec-body"},n("p",{class:"dl-muted"},_("Loading interfaces…"))))),a,l=!0,d="",c=!0,p=!0,u="all",g=!1,M=Zr(r,s,o),x=new Set,h="",S=()=>JSON.stringify([p,l,l?"":d,c,[...x].sort()]),B=()=>a.detected.lan||a.saved.lan||"",P=()=>(l?a.detected.wan||a.saved.wan:d)||"",R=()=>new Map(a.devices.map(j=>[j.name,j])),w=()=>{let j=R();return[...c&&B()?[B()]:[],...[...x].filter(te=>te!==B())].filter(te=>te!==P()).map(te=>j.get(te)??{name:te,nets:[],missing:!0})},k=(j,Z)=>{a=j,Z&&(l=j.config.auto_wan,d=j.config.wan_device||j.detected.wan||j.saved.wan||"",c=j.config.auto_lan,p=j.config.lan_like,u=j.config.mesh??(j.config.device_mesh?"all":"off"),x=new Set(j.config.lan_devices),h=S()),Y()},y=async j=>{let Z=await N.interfaces(s).catch(te=>(F(te.message,"error"),null));Z&&k(Z,j)};function O(j){let Z=c&&j.name===B(),te=!!j.own||!!j.master||j.name===P()||Z;return Z||x.has(j.name)||!te&&(j.nets.length>0||!!j.missing)}function b(j){let Z=c&&j.name===B(),te=j.name===P(),me=!Z&&x.has(j.name),U=!(!!j.own||!!j.maste
Line truncated
|
|
||||||
`).map(e=>zt(e)).join(`
|
|
||||||
`);function qn(t,e,o,s){let r=t.by==="admin",i=zt(t.msg),a=n("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${nd[t.level]??""}`}${t.detail?" has-detail":""}`},[r?n("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},v("admin")):n("span",{class:"dl-ev-tile sys",title:sd(t.level)},v(od[t.src]??"zap")),n("span",{class:"dl-row-main"},r?[...rd(t),t.note?n("span",{class:"dl-muted"},` · ${Xs(t.note)}`):"",t.detail?n("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",t.detail&&e?n("pre",{class:"dl-slog-detail"},ai(t.detail)):""]:[t.src==="awg"&&t.who&&t.who!=="AmneziaWG"?n("span",{class:"dl-ev-kind"},`${_("Server")} `):"",n("b",{class:"dl-sys-src",title:Qt(t.src)},t.who?t.src==="awg"?t.who:zt(t.who):Qt(t.src)),/^[:,]/.test(i)?"":" ",n("span",{class:"dl-muted"},i),t.detail?n("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",t.detail&&e?n("pre",{class:"dl-slog-detail"},ai(t.detail)):""]),n("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString(ie())},s)]);return t.detail&&a.addEventListener("click",l=>{l.target.closest("pre")||o()}),a}function li(t){let e=new Date(t*1e3),o=new Date,s=new Date;if(s.setDate(o.getDate()-1),e.toDateString()===o.toDateString())return _("Today");if(e.toDateString()===s.toDateString())return _("Yesterday");let r=e.toLocaleDateString(ie(),{weekday:"long",day:"numeric",month:"long"});return r.charAt(0).toLocaleUpperCase(ie())+r.slice(1)}var Ut=t=>Pt(t).toLocaleDateString(ie(),{day:"numeric",month:"short"}),pn=200,Wt=40;function di(t,e){let o=Math.max(1,...t.map(a=>Math.max(a[1],a[2]))),s=a=>t.map((l,d)=>`${e[d]*pn},${Wt-2-l[a]/o*(Wt-6)}`),r=s(2),i=s(1);return{area:`M${r.join(" L")} L${e[e.length-1]*pn},${Wt} L${e[0]*pn},${Wt}Z`,down:`M${r.join(" L")}`,up:`M${i.join(" L")}`}}var Kn=(t,e,o,s)=>n("div",{class:"dl-speed-col"},[n("span",{class:"dl-sub"},[n("span",{class:o},e),` ${t}`]),s]),ci=([t,e])=>[n("span",{},oe(_("Today %s"),n("b",{},se(t+e)))),n("span",{},[n("span",{class:"dl-dn"},"↓"),` ${se(e)} `,n("span",{class:"dl-up"},"↑"),` ${se(t)}`])];function pi(t,e,o,s=!1){let r=t.slice(-15),i=r[r.length-1],a=i&&e-i[0]<180,l=a?i[2]:0,d=a?i[1]:0,c;if(r.length>1&&!s){let u=di(r,r.map((g,M)=>M/(r.length-1)));c=kt(`<svg viewBox="0 0 ${pn} ${Wt}" preserveAspectRatio="none" class="dl-speed-chart" aria-hidden="true"><path d="${u.area}" class="area"/><path d="${u.down}" class="line"/><path d="${u.up}" class="line up"/></svg>`),we(c,()=>{let g=r[r.length-1];return[n("div",{class:"dl-tip-title"},new Date(g[0]*1e3).toLocaleTimeString(ie(),{hour:"2-digit",minute:"2-digit"})),n("div",{},`↓ ${We(g[2])} · ↑ ${We(g[1])}`)]})}else c=n("div",{class:"dl-speed-wait"},[n("i"),s?"":n("span",{},_("Collecting… 1 point a minute"))]);let p=u=>s?n("span",{class:"dl-speed-val off"},"—"):n("span",{class:"dl-speed-val"},We(u));return n("div",{class:"dl-bento-tile"},[n("div",{class:"dl-bento-head"},[n("span",{class:"dl-metric-label"},_("Speed now")),s?"":n("span",{class:"dl-sub"},_("last 15 min"))]),n("div",{class:"dl-speed-cols"},[Kn(_("Download","speed"),"↓","dl-dn",p(l)),Kn(_("Upload","speed"),"↑","dl-up",p(d))]),c,n("div",{class:"dl-speed-today"},ci(o))])}var Vn=class{constructor(){this.span=n("span",{class:"dl-sub"},_("last 2 min"));this.down=n("span",{class:"dl-speed-val"});this.up=n("span",{class:"dl-speed-val"});this.chart=kt(`<svg viewBox="0 0 ${pn} ${Wt}" preserveAspectRatio="none" class="dl-speed-chart" aria-hidden="true"><path class="area"/><path class="line"/><path class="line up"/></svg>`);this.wait=n("div",{class:"dl-speed-wait"});this.shown=this.wait;this.today=n("div",{class:"dl-speed-today"});this.el=n("div",{class:"dl-bento-tile"},[n("div",{class:"dl-bento-head"},[n("span",{class:"dl-metric-label"},_("Speed now")),this.span]),n("div",{class:"dl-speed-cols"},[Kn(_("Download","speed"),"↓","dl-dn",this.down),Kn(_("Upload","speed"),"↑","dl-up",this.up)]),this.wait,this.today])}update(e,o,s){let r=s||!!e.error;this.span.style.display=s?"none":"";for(let[l,d]of[[this.down,e.tx],[this.up,e.rx]])l.className=`dl-speed-val${r?" off":""}`,l.textContent=r?"—":We(d);let i=!r&&e.pts.length>1;if(i){let l=di(e.pts,e.xs),[d,c,p]=this.chart.querySelectorAll("path");d.setAttribute("d",l.area),c.setAttribute("d",l.down),p.setAttribute("d",l.up)}else dom.content(this.wait,[n("i"),s||e.early&&!e.error?"":n("span",{},e.error?m(_("Couldn't read the live speed: %s"),e.error):_("Collecting… 1 point a second"))]);let a=i?this.chart:this.wait;a!==this.shown&&(this.shown.replaceWith(a),this.shown=a),dom.content(this.today,ci(o))}};function Yn(t,e){let o=t.slice(-30),s=o.map(d=>d.rx+d.tx),r=Math.max(1,...s),i=s.reduce((d,c)=>d+c,0),a=s.reduce((d,c,p)=>c>s[d]?p:d,0),l=n("div",{class:"dl-bento-bars"},o.map((d,c)=>{let p=s[c],u=n("i",{class:c===o.length-1?"hi":"",style:`height:${Math.max(4,p/r*100)}%`}),g=n("span",{},[u]);return we(g,()=>[n("div",{class:"dl-tip-title"},c===o.length-1?`${_("Today")} · ${Ut(d.day)}`:Ut(d.day)),n("div",{},se(pLine truncated
|
|
||||||
`)){let d=l.trimEnd();if(i){/^```/.test(d.trim())?(e.push(n("pre",{},i.join(`
|
|
||||||
`))),i=null):i.push(l);continue}if(/^```/.test(d.trim())){a(),i=[];continue}let c=/^(#{1,6})\s+(.*)$/.exec(d),p=/^\s*[-*+]\s+(.*)$/.exec(d)??/^\s*\d+[.)]\s+(.*)$/.exec(d);c?(a(),e.push(n("h5",{},o(c[2])))):p?(r.length&&a(),s||(s=n("ul",{}),e.push(s)),s.appendChild(n("li",{},o(p[1])))):d.trim()?(s&&(s=null),r.push(d.trim())):a()}return i&&e.push(n("pre",{},i.join(`
|
|
||||||
`))),a(),e}function Si(t){let e=[],o=!1;for(let s of t.replace(/\r/g,"").split(`
|
|
||||||
`)){let r=/^#{1,6}\s+(.*)$/.exec(s);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(s)&&(o=!1);o||e.push(s)}return e.join(`
|
|
||||||
`).replace(/\n{3,}/g,`
|
|
||||||
|
|
||||||
`).trim()}async function mn(t,e,o,s){let r=n("div",{class:"dl-notes"},n("p",{class:"dl-muted dl-loading"},_("Loading release notes…"))),i=n("div",{class:"dl-op-head"}),a="";ae(o,[i,r],[H([v("copy")," ",_("Copy")],()=>xe(a,_("Release notes copied")))," ",de(_("Close"))],"wide");try{let l=await N.updatesNotes(t,e,s??"");a=Si(l.body||"");let d=Ei(l.url);dom.content(i,[l.published?n("span",{class:"dl-pill"},Ie(l.published)):"",l.prerelease?n("span",{class:"dl-pill warn"},_("Pre-release")):"",n("span",{class:"dl-spacer"}),d?n("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},[_("On GitHub")," ",v("open")]):""]),dom.content(r,a.trim()?Ti(a):n("p",{class:"dl-muted"},_("This release has no notes.")))}catch(l){dom.content(r,n("p",{class:"dl-muted"},_e(l)))}}function hd(t){let e={"6h":_("checks every 6 h"),"12h":_("checks every 12 h"),"1d":_("checks daily"),"7d":_("checks weekly")};return e[t]??e["1d"]}var ns=t=>t?Ie(t):"";function fd(t){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(t)?.[1];return e||(t.length<=90?t:`${t.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function $i(t,e){let o=t.st,s=o.policy,r=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,a=g=>()=>mn("app",g,m(_("What’s new in Dawnline %s"),g.replace(/^v/,""))),l=e?.tag&&(e.update||e.status==="latest")?gd(t,e.tag,e.update?o.version:""):null,d=e?.tag??i,c=s.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[s.interval]??24)*3600:0,p=(g,M)=>n("div",{class:"dl-stack gap4"},[n("span",{class:"dl-metric-label"},g),n("span",{class:"dl-comp-side-v"},M)]),u=[{label:_("What’s new"),ic:"file",run:a(i)},{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:m(_("Reinstall %s"),o.version),ic:"reset",warn:!0,run:()=>t.op("app:reinstall",_("Reinstalling Dawnline"),o.version)},r?{label:m(_("Roll back to %s"),r.version),ic:"archive",warn:!0,run:async()=>{await pe(m(_("Roll back to Dawnline %s?"),r.version),m(_("The copy kept on the router replaces %s. A backup of the settings is made first."),o.version),_("Roll back"))&&t.op("app:rollback",_("Rolling back Dawnline"),o.version)}}:null];return n("section",{class:"dl-panel flush dl-comp-hero"},[n("div",{class:"dl-comp-hero-main"},[n("div",{class:"dl-comp-hero-head"},[n("span",{class:"dl-group-ic"},v("sunrise")),n("b",{class:"dl-comp-name"},"Dawnline"),t.state("app",e,e?.latest??""),n("span",{class:"dl-spacer"}),t.round(()=>t.op("check:app",_("Checking Dawnline"),o.version),u,!0)]),n("div",{class:"dl-comp-verrow"},[n("div",{class:"dl-stack"},[n("div",{class:"dl-comp-big"},[o.version,e?.update?n("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?n("small",{class:"dl-faint"},m(_("release %s"),e.latest)):""]),n("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?m(_("released %s"),ns(e.published)):"":e?.status==="dev"?_("ahead of the latest release"):e?[_("latest release"),e.published?m(_("released %s"),ns(e.published)):""].filter(Boolean).join(" · "):_("not checked yet"))])]),l?.items.length?n("div",{class:"dl-stack gap4"},[n("ul",{class:"dl-comp-bullets"},l.items.map(g=>n("li",{},g))),l.total>l.items.length?n("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:a(d)},G(l.total-l.items.length,"+%s more in What’s new","+%s more in What’s new")):""]):"",e?.error?n("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?n("div",{class:"dl-comp-btns"},[H(_("Update now"),()=>t.op("app",_("Updating Dawnline"),o.version),"positive",{disabled:t.busy}),H(_("What’s new"),a(i))]):"",bd(t),vd(t)]),n("div",{class:"dl-comp-hero-side"},[p(_("Source"),[v("globe"),n("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p(_("Auto-update"),[s.auto?Se("ok",_("On")):Se("",_("Off")),n("span",{class:"dl-muted"},s.auto?s.mode==="immediate"?_("as soon as found"):m(s.interval==="7d"?_("weekly at %s"):_("daily at %s"),s.time):s.check?hd(s.interval):_("checks off"))]),p(_("Last check"),o.check?[ce(o.check.time,o.now),c>o.now?n("span",{class:"dl-faint"},`· ${m(_("next in %s"),st(c-o.now))}`):""]:[_("Never")]),p(_("Rollback"),r?[n("span",{class:"dl-mono"},r.version),n("span",{class:"dl-faint"},_("kept on flash"))]:[n("span",{class:"dl-muted"},s.keep?_("Kept after the next update"):_("Off"))])])])}function gd(t,e,o){if(t.notes.has(e))return t.notes.get(e)??null;t.notes.set(e,null);let s=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,a)=>a??"").trim();return(async()=>{let i=((await N.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(`
|
|
||||||
`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await N.updatesChanges(o,e).catch(()=>null))?.items??[]);let a={items:i.slice(0,3).map(l=>fd(s(l))),total:i.length};t.notes.set(e,a),a.items.length&&t.root.isConnected&&t.paint()})(),null}function Xn(t){return t==="ru"?_("Russian translation"):t}function vd(t){let e=(t.st.translations??[]).includes("ru"),o=be(e,Xn("ru"),r=>{t.op(r?"app:lang:ru":"app:nolang",r?_("Adding the Russian translation"):_("Removing the Russian translation"),t.st.version)});o.disabled=t.busy;let s=n("details",{class:"dl-params dl-comp-fold",open:t.langOpen?"open":null},[n("summary",{},[v("chevron"),n("span",{},_("Translation")),n("span",{class:"dl-sub"},e?_("Russian"):_("English only"))]),n("div",{class:"dl-params-body"},[n("div",{class:"dl-list"},[n("div",{class:"dl-row"},[n("span",{class:"dl-row-main dl-stack"},[n("b",{},Xn("ru")),n("span",{class:"dl-sub"},_("LuCI pages for Dawnline"))]),n("span",{class:"dl-comp-bact"},o)])])])]);return s.addEventListener("toggle",()=>t.langOpen=s.open),s}function bd(t){let e=n("div",{class:"dl-params-body"}),o=n("details",{class:"dl-params dl-comp-vers",open:t.versOpen?"open":null},[n("summary",{},[v("chevron"),n("span",{},_("Versions")),n("span",{class:"dl-sub"},_("install any release"))]),e]);return o.addEventListener("toggle",()=>{t.versOpen=o.open,t.versOpen&&eo(t,e)}),t.versOpen&&eo(t,e),o}async function eo(t,e){let o=ue("",{placeholder:_("Tag, e.g. 0.3.1"),class:"cbi-input-text dl-mono","aria-label":_("Release tag")}),s=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return F(_("Enter a release tag like 0.3.1"),"warning");Pi(t,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),s(o.value))});let r=n("div",{class:"dl-comp-tag"},[o,H(_("Install"),()=>s(o.value),"neutral",{disabled:t.busy})]),i=t.versPage,a=p=>{t.versPage=Math.max(1,t.versPage+p),eo(t,e)},l=p=>n("div",{class:"dl-comp-pager"},[n("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>a(-1)},_("← Newer")),n("span",{class:"dl-faint"},m(_("Page %s"),i)),n("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>a(1)},_("Older →"))]),d=t.versCache.get(i);if(!d){dom.content(e,[r,n("p",{class:"dl-muted dl-loading"},_("Loading versions…"))]);try{d=(await N.updatesReleases(i)).releases}catch(p){if(i!==t.versPage||!e.isConnected)return;dom.content(e,[r,n("div",{class:"dl-row-actions"},[n("span",{class:"dl-muted"},m(_("Failed to load versions: %s"),_e(p))),H(_("Try again"),()=>eo(t,e))]),l(!1)]);return}if(t.versCache.set(i,d),i!==t.versPage||!e.isConnected)return}if(!d.length)return dom.content(e,[r,n("p",{class:"dl-muted"},i>1?_("No more versions."):_("No versions found.")),l(!1)]);let c=t.st.version;dom.content(e,[r,...d.map(p=>{let u=p.tag.replace(/^v/,"");return n("div",{class:"dl-comp-ver"},[n("span",{class:"dl-mono"},u),n("span",{class:"dl-sub"},ns(p.published)),p.prerelease?Se("warn",_("Pre-release")):"",n("span",{class:"dl-comp-ic"},Pe("file",_("What’s new"),()=>mn("app",p.tag,m(_("What’s new in Dawnline %s"),u)))),u===c?Se("ok",_("Installed")):H(_("Install"),()=>Pi(t,p.tag),"neutral",{disabled:t.busy})])}),l(d.length>=5)])}async function Pi(t,e){let o=e.replace(/^v/,"");o.localeCompare(t.st.version,void 0,{numeric:!0})<0&&!await pe(m(_("Install Dawnline %s?"),o),m(_("It is older than %s. A backup of the settings is made first; restore it from Settings if something looks wrong."),t.st.version),_("Install"))||t.op(`app@${e}`,m(_("Installing Dawnline %s"),o),t.st.version)}function Di(t,e){let o=t.st,s=o.kept?.amneziawg,r=e?.sources??{},i=Object.keys(r),a=e?.current??null,l=a?r[a]:void 0,d=!!e?.ru,c=o.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];a&&p&&u.push({label:_("Reinstall this build"),warn:!0,ic:"reset",run:()=>t.op(`amneziawg:${a}${d?":ru":""}`,_("Reinstalling AmneziaWG"),p)}),s&&u.push({label:m(_("Roll back to %s"),s.version),ic:"archive",warn:!0,run:async()=>{await pe(m(_("Roll back AmneziaWG to %s?"),s.version),_("The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."),_("Roll back"))&&t.op("amneziawg:rollback",_("Rolling back AmneziaWG"),p??void 0)}});let g=[e?.release?{label:_("What’s new"),ic:"file",run:()=>mn("amneziawg",e.release,m(_("What’s new in the %s build"),l?.label??"AmneziaWG"),a??"slava")}:null,{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((b,f,T)=>b!==null||f>0&&T[f-1]!==null),M=o.tunnels??[],x=M.length?M.length===1?m(_("Switching restarts the tunnel for a few seconds: %s. Devices keep their configurations."),M[0]):m(N_(M.length,"Switching restarts %s tunnel for a few seconds: %s. Devices keep their configurations.","Switching restarts %s tunnels for a few seconds: %s. Devices keep their configurations."),V(M.length),M.join(", ")):_("Switching takes a few
Line truncated
|
|
||||||
`)}r.push(p),l+=c-1}let a=H([v("more")],()=>Te(a,[{label:_("Export CSV"),icon:v("download"),run:()=>Xe(o,s,"csv",e.id)},{label:_("Export JSON"),icon:v("download"),run:()=>Xe(o,s,"json",e.id)},null,{label:m(_("Clear %s's activity"),e.name),icon:v("trash"),danger:!0,run:()=>dt(m(_("Clear %s's activity"),e.name),m(_("Removes events about %s and their devices."),e.name),{person:e.id},()=>t.refresh())}]),"neutral",{title:_("Export or clear"),class:"cbi-button cbi-button-neutral dl-icon-only"});return n("div",{class:"dl-panel flush"},[n("div",{class:"dl-panel-head pad"},[n("h3",{},_("Activity")),n("span",{class:"dl-sub"},s.length>10?m(_("latest 10 of %s"),V(s.length)):""),n("span",{class:"dl-spacer"}),a]),r.length?r:n("div",{class:"dl-row dl-muted"},_("Nothing yet."))])}var no=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,s,r]=await Promise.all([N.status(30),e?N.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?N.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:s?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(a=>a.id===this.id);if(!o)return n("div",{class:"dl-empty"},[n("h3",{},_("Person not found")),n("p",{},_("They may have been removed.")),n("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},_("Back to Servers"))]);this.p=o;for(let a of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[a]=n("div",{});this.parts.devices.className="dl-person-devices";let s=n("div",{},[this.parts.crumbs,this.parts.head,n("div",{class:"dl-grid-person"},[n("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),n("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(a=>a.id===r.get("device"));return i?setTimeout(()=>Ye(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>pt(this.p,this.deviceOpts()),50),this.poller=nt({fetch:a=>{let l=a||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>s.isConnected,apply:(a,l)=>this.apply(a,l)}),s}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let s=this.st.people.find(r=>r.id===this.id);if(!s){o||(location.href=jt(this.p?.server));return}this.p=s,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let s=await q(()=>N.personUpdate(this.p.id,e),o);if(!s)return!1;this.poller?.claim();let r=this.st.people.findIndex(a=>a.id===this.p.id);return(i=s.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=s.person),this.p=s.person,this.paint(),!0}get today(){return Ge(this.series.length?this.series:this.st.series)}get core(){return Ot(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,server:this.st.servers.find(e=>e.id===this.p.server),events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return n("nav",{class:"dl-crumbs","aria-label":_("Breadcrumb")},[n("a",{href:jt(e.server)},this.st.servers.find(o=>o.id===e.server)?.name??_("Servers")),n("span",{},"/"),n("a",{href:jt(e.server)},_("People")),n("span",{},"/"),n("span",{},e.name)])}paint(e=!1){Ne(this.parts.crumbs,this.crumbs(),e),Ne(this.parts.head,Ui(this),e),Ne(this.parts.traffic,Wi(this),e),Ne(this.parts.devices,Gi(this),e),Ne(this.parts.limits,Zi(this),e),this.paintPlaces(e),Ne(this.parts.activity,Xi(this),e)}paintPlaces(e=!1){let o=Qi(this);o&&Ne(this.parts.places,o,e&&!this.mapOpen)}};var Sd={ok:"check",warn:"alert",error:"x",skip:"pause"},oo=class{constructor(e,o,s,r){this.el=n("div",{});this.wdEl=n("div",{});this.checksEl=n("div",{class:"dl-panel"});this.recentEl=n("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=n("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=s,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,n("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,s)}async run(e){let o=e?await Jn(e):await N.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[n("div",{class:"dl-panel-head"},[n("h3",{},_("Checks"))]),n("p",{class:"dl-muted dl-loading"},_("Running checks…"))]);return}let o=e.filter(a=>a.status==="error").length,s=e.filter(a=>a.status==="
Line truncated
|
|
||||||
`);function fa(){let t=document.createElement("style");return t.dataset.dawnline="1",t.textContent=Vd,t}function Lt(t){return()=>{let e=new t;return Object.assign({load:()=>e.load(),render:async s=>{let r=await e.render(s),i=document.createElement("div");return i.className="dl-root",i.append(fa(),r),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var ux=Lt(un),mx=Lt(Ct),hx=Lt(un),fx=Lt(Qn),gx=Lt(no),vx=Lt(io),bx=Lt(to);function ga(t){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${t?`?tab=${t}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var xx=ga(""),wx=ga("log");return baseclass.extend({ activity: wx, diagnostics: vx, health: xx, overview: ux, people: mx, person: gx, server: hx, settings: fx, updates: bx });
|
|
||||||
@@ -126,6 +126,10 @@ msgstr[2] "%s устройств AmneziaWG перестанут подключа
|
|||||||
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
||||||
msgstr "Свободно %s МБ: настройки могут перестать сохраняться. Удалите старые резервные копии («Настройки» → «Резервные копии») или сократите историю."
|
msgstr "Свободно %s МБ: настройки могут перестать сохраняться. Удалите старые резервные копии («Настройки» → «Резервные копии») или сократите историю."
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "%s a day lately"
|
||||||
|
msgstr "%s в день за последние дни"
|
||||||
|
|
||||||
#: web/src/admin/access.ts
|
#: web/src/admin/access.ts
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s added"
|
msgid "%s added"
|
||||||
@@ -263,6 +267,13 @@ msgstr "Сервер %s не может использовать сетевой
|
|||||||
msgid "%s check failed"
|
msgid "%s check failed"
|
||||||
msgstr "%s: ошибка проверки"
|
msgstr "%s: ошибка проверки"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "%s city"
|
||||||
|
msgid_plural "%s cities"
|
||||||
|
msgstr[0] "%s город"
|
||||||
|
msgstr[1] "%s города"
|
||||||
|
msgstr[2] "%s городов"
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s copied"
|
msgid "%s copied"
|
||||||
msgstr "Скопировано: %s"
|
msgstr "Скопировано: %s"
|
||||||
@@ -378,6 +389,10 @@ msgstr "Интерфейса %s нет."
|
|||||||
msgid "%s does not overlap other networks."
|
msgid "%s does not overlap other networks."
|
||||||
msgstr "%s не пересекается с другими сетями."
|
msgstr "%s не пересекается с другими сетями."
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "%s does not resolve right now, and V2RayTun on Android connects by IP address only."
|
||||||
|
msgstr "Сейчас не удаётся узнать IP-адрес %s, а V2RayTun на Android подключается только по IP-адресу."
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "%s does not resolve."
|
msgid "%s does not resolve."
|
||||||
msgstr "%s не разрешается в IP-адрес."
|
msgstr "%s не разрешается в IP-адрес."
|
||||||
@@ -696,6 +711,10 @@ msgstr "осталось %s"
|
|||||||
msgid "%s may not contain # or a line break."
|
msgid "%s may not contain # or a line break."
|
||||||
msgstr "%s не может содержать # или перенос строки."
|
msgstr "%s не может содержать # или перенос строки."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s min %s s ago"
|
||||||
|
msgstr "%s мин %s с назад"
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "%s min ago"
|
msgid "%s min ago"
|
||||||
msgstr "%s мин назад"
|
msgstr "%s мин назад"
|
||||||
@@ -912,6 +931,10 @@ msgstr "%s: доступ возобновлён"
|
|||||||
msgid "%s s"
|
msgid "%s s"
|
||||||
msgstr "%s с"
|
msgstr "%s с"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s s ago"
|
||||||
|
msgstr "%s с назад"
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/logs.ts
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
msgid "%s since %s"
|
msgid "%s since %s"
|
||||||
msgstr "%s с %s"
|
msgstr "%s с %s"
|
||||||
@@ -1068,6 +1091,10 @@ msgstr "%s: %s из 4"
|
|||||||
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
||||||
msgstr "%s: тег <%s> не примут приложения AmneziaWG: используйте <b 0x…> с чётным числом шестнадцатеричных цифр, <r N>, <rc N> или <rd N> с N от 1 до 1000 либо <t>."
|
msgstr "%s: тег <%s> не примут приложения AmneziaWG: используйте <b 0x…> с чётным числом шестнадцатеричных цифр, <r N>, <rc N> или <rd N> с N от 1 до 1000 либо <t>."
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "%s: automatic"
|
||||||
|
msgstr "%s: автоматически"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc
|
||||||
msgid "%s: the device's own network handles it."
|
msgid "%s: the device's own network handles it."
|
||||||
msgstr "%s: этот трафик идёт через собственную сеть устройства."
|
msgstr "%s: этот трафик идёт через собственную сеть устройства."
|
||||||
@@ -1107,6 +1134,10 @@ msgstr[0] "Ещё %s пункт в «Что нового»"
|
|||||||
msgstr[1] "Ещё %s пункта в «Что нового»"
|
msgstr[1] "Ещё %s пункта в «Что нового»"
|
||||||
msgstr[2] "Ещё %s пунктов в «Что нового»"
|
msgstr[2] "Ещё %s пунктов в «Что нового»"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "+%s%% vs average"
|
||||||
|
msgstr "+%s%% к среднему"
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "+1 month"
|
msgid "+1 month"
|
||||||
msgstr "+1 месяц"
|
msgstr "+1 месяц"
|
||||||
@@ -1140,6 +1171,10 @@ msgstr "1 год"
|
|||||||
msgid "15 min"
|
msgid "15 min"
|
||||||
msgstr "15 мин"
|
msgstr "15 мин"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "2 min"
|
||||||
|
msgstr "2 мин"
|
||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
msgid "24h"
|
msgid "24h"
|
||||||
msgstr "24 ч"
|
msgstr "24 ч"
|
||||||
@@ -1239,6 +1274,13 @@ msgstr "Срок доступа"
|
|||||||
msgid "Access ends %s"
|
msgid "Access ends %s"
|
||||||
msgstr "Окончание доступа: %s"
|
msgstr "Окончание доступа: %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access ends in %s day"
|
||||||
|
msgid_plural "Access ends in %s days"
|
||||||
|
msgstr[0] "Доступ закончится через %s день"
|
||||||
|
msgstr[1] "Доступ закончится через %s дня"
|
||||||
|
msgstr[2] "Доступ закончится через %s дней"
|
||||||
|
|
||||||
#: web/src/admin/netcheck.ts
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends in %s day (%s)."
|
msgid "Access ends in %s day (%s)."
|
||||||
msgid_plural "Access ends in %s days (%s)."
|
msgid_plural "Access ends in %s days (%s)."
|
||||||
@@ -1246,6 +1288,10 @@ msgstr[0] "Доступ закончится через %s день (%s)."
|
|||||||
msgstr[1] "Доступ закончится через %s дня (%s)."
|
msgstr[1] "Доступ закончится через %s дня (%s)."
|
||||||
msgstr[2] "Доступ закончится через %s дней (%s)."
|
msgstr[2] "Доступ закончится через %s дней (%s)."
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access ends in a few days"
|
||||||
|
msgstr "Доступ закончится через несколько дней"
|
||||||
|
|
||||||
#: web/src/admin/netcheck.ts
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends today (%s)."
|
msgid "Access ends today (%s)."
|
||||||
msgstr "Доступ закончится сегодня (%s)."
|
msgstr "Доступ закончится сегодня (%s)."
|
||||||
@@ -1254,6 +1300,22 @@ msgstr "Доступ закончится сегодня (%s)."
|
|||||||
msgid "Access must be lan, internet or both."
|
msgid "Access must be lan, internet or both."
|
||||||
msgstr "Доступ должен быть lan, internet или both."
|
msgstr "Доступ должен быть lan, internet или both."
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access paused"
|
||||||
|
msgstr "Доступ на паузе"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access paused - %s"
|
||||||
|
msgstr "Доступ на паузе: %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access resumed"
|
||||||
|
msgstr "Доступ возобновлён"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access resumed - %s"
|
||||||
|
msgstr "Доступ возобновлён: %s"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
||||||
@@ -1441,6 +1503,10 @@ msgstr "Все проверки пройдены."
|
|||||||
msgid "All components"
|
msgid "All components"
|
||||||
msgstr "Все компоненты"
|
msgstr "Все компоненты"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "All devices removed, end date reached"
|
||||||
|
msgstr "Все устройства удалены: срок доступа закончился"
|
||||||
|
|
||||||
#: web/src/admin/pages/overview.ts
|
#: web/src/admin/pages/overview.ts
|
||||||
msgid "All good. Nothing needs you right now."
|
msgid "All good. Nothing needs you right now."
|
||||||
msgstr "Всё в порядке. Сейчас ничего не требует вашего внимания."
|
msgstr "Всё в порядке. Сейчас ничего не требует вашего внимания."
|
||||||
@@ -2124,6 +2190,10 @@ msgstr "Выберите свободный порт от 1 до 65535 (кром
|
|||||||
msgid "Choose a server on their page"
|
msgid "Choose a server on their page"
|
||||||
msgstr "Выберите сервер на странице человека"
|
msgstr "Выберите сервер на странице человека"
|
||||||
|
|
||||||
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
||||||
|
msgid "Choose a system log level: errors, warnings, normal or verbose."
|
||||||
|
msgstr "Выберите уровень системного журнала: ошибки, предупреждения, обычный или подробный."
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "Choose another interface name in the server settings."
|
msgid "Choose another interface name in the server settings."
|
||||||
msgstr "Выберите другое имя интерфейса в настройках сервера."
|
msgstr "Выберите другое имя интерфейса в настройках сервера."
|
||||||
@@ -2205,10 +2275,6 @@ msgstr "Часы не настроены"
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr "Закрыть"
|
msgstr "Закрыть"
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Collecting… 1 point a minute"
|
|
||||||
msgstr "Сбор данных… 1 точка в минуту"
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "Collecting… 1 point a second"
|
msgid "Collecting… 1 point a second"
|
||||||
msgstr "Сбор данных… 1 точка в секунду"
|
msgstr "Сбор данных… 1 точка в секунду"
|
||||||
@@ -2526,6 +2592,10 @@ msgstr "Dawnline обновлён до %s"
|
|||||||
msgid "Dawnline was updated to %s: reload the page."
|
msgid "Dawnline was updated to %s: reload the page."
|
||||||
msgstr "Dawnline обновлён до версии %s: перезагрузите страницу."
|
msgstr "Dawnline обновлён до версии %s: перезагрузите страницу."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Days this device was used"
|
||||||
|
msgstr "Дни с трафиком на устройстве"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
||||||
msgid "Default device limit must be 1-32."
|
msgid "Default device limit must be 1-32."
|
||||||
msgstr "Лимит устройств по умолчанию: от 1 до 32."
|
msgstr "Лимит устройств по умолчанию: от 1 до 32."
|
||||||
@@ -2579,10 +2649,26 @@ msgstr "Сведения"
|
|||||||
msgid "Device"
|
msgid "Device"
|
||||||
msgstr "Устройство"
|
msgstr "Устройство"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s added"
|
||||||
|
msgstr "Устройство %s добавлено"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s added on the portal"
|
||||||
|
msgstr "Устройство %s добавлено через портал"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s changed"
|
||||||
|
msgstr "Устройство %s: настройки изменены"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s changed network %s"
|
msgid "Device %s changed network %s"
|
||||||
msgstr "Устройство %s сменило сеть %s"
|
msgstr "Устройство %s сменило сеть %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s changed on the portal"
|
||||||
|
msgstr "Устройство %s: настройки изменены через портал"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s connected"
|
msgid "Device %s connected"
|
||||||
msgstr "Устройство %s подключилось"
|
msgstr "Устройство %s подключилось"
|
||||||
@@ -2643,6 +2729,30 @@ msgstr "Устройство %s (%s): публичный ключ некорре
|
|||||||
msgid "Device %s of %s: the public key is the server's own."
|
msgid "Device %s of %s: the public key is the server's own."
|
||||||
msgstr "Устройство %s (%s): публичный ключ совпадает с ключом сервера."
|
msgstr "Устройство %s (%s): публичный ключ совпадает с ключом сервера."
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s removed"
|
||||||
|
msgstr "Устройство %s удалено"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s removed on the portal"
|
||||||
|
msgstr "Устройство %s удалено через портал"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s renamed"
|
||||||
|
msgstr "Устройство %s: название изменено"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s renamed on the portal"
|
||||||
|
msgstr "Устройство %s: название изменено через портал"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s turned off"
|
||||||
|
msgstr "Устройство %s выключено"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s turned on"
|
||||||
|
msgstr "Устройство %s включено"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s went offline"
|
msgid "Device %s went offline"
|
||||||
msgstr "Устройство %s отключилось"
|
msgstr "Устройство %s отключилось"
|
||||||
@@ -2935,6 +3045,10 @@ msgstr "Дата окончания"
|
|||||||
msgid "End date must be YYYY-MM-DD."
|
msgid "End date must be YYYY-MM-DD."
|
||||||
msgstr "Дата окончания должна быть в формате ГГГГ-ММ-ДД."
|
msgstr "Дата окончания должна быть в формате ГГГГ-ММ-ДД."
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "End date passed (%s) · access kept"
|
||||||
|
msgstr "Срок доступа закончился (%s) · доступ сохранён"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "End dates and quotas use the router clock."
|
msgid "End dates and quotas use the router clock."
|
||||||
msgstr "Даты окончания и лимиты трафика считаются по часам роутера."
|
msgstr "Даты окончания и лимиты трафика считаются по часам роутера."
|
||||||
@@ -2983,6 +3097,10 @@ msgstr "Укажите оба времени, например 07:00 и 23:00."
|
|||||||
msgid "Error: %s"
|
msgid "Error: %s"
|
||||||
msgstr "Ошибка: %s"
|
msgstr "Ошибка: %s"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Errors only"
|
||||||
|
msgstr "Только ошибки"
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/logs.ts
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
msgid "Every 10 min"
|
msgid "Every 10 min"
|
||||||
msgstr "Каждые 10 мин"
|
msgstr "Каждые 10 мин"
|
||||||
@@ -3429,6 +3547,21 @@ msgstr "Импортировать"
|
|||||||
msgid "Import JSON"
|
msgid "Import JSON"
|
||||||
msgstr "Импорт JSON"
|
msgstr "Импорт JSON"
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Import config from Clipboard"
|
||||||
|
msgstr "Импорт из буфера обмена"
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Import config from QRcode"
|
||||||
|
msgstr "Импорт из QR-кода"
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Import from clipboard"
|
||||||
|
msgstr "Импорт из буфера обмена"
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/backups.ts
|
#: web/src/admin/pages/settings/backups.ts
|
||||||
msgid "Import?"
|
msgid "Import?"
|
||||||
msgstr "Импортировать?"
|
msgstr "Импортировать?"
|
||||||
@@ -3830,11 +3963,20 @@ msgstr "Не удалось создать ключ."
|
|||||||
msgid "LAN Bypass"
|
msgid "LAN Bypass"
|
||||||
msgstr "Обход локальной сети"
|
msgstr "Обход локальной сети"
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "LAN Bypass off"
|
||||||
|
msgstr "обход локальной сети выкл."
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "LAN Bypass on"
|
||||||
|
msgstr "обход локальной сети вкл."
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "Last 30 days"
|
msgid "Last 30 days"
|
||||||
msgstr "За 30 дней"
|
msgstr "За 30 дней"
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
|
#: web/src/admin/widgets/spark.ts
|
||||||
msgid "Last 7 days"
|
msgid "Last 7 days"
|
||||||
msgstr "За 7 дней"
|
msgstr "За 7 дней"
|
||||||
|
|
||||||
@@ -3876,6 +4018,7 @@ msgstr "Сертификат Let’s Encrypt для портала"
|
|||||||
msgid "Limit hours"
|
msgid "Limit hours"
|
||||||
msgstr "Ограничить часы"
|
msgstr "Ограничить часы"
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
#: web/src/admin/invite.ts
|
#: web/src/admin/invite.ts
|
||||||
msgid "Link copied"
|
msgid "Link copied"
|
||||||
msgstr "Ссылка скопирована"
|
msgstr "Ссылка скопирована"
|
||||||
@@ -4099,6 +4242,10 @@ msgstr "Метод не поддерживается."
|
|||||||
msgid "Missing: %s."
|
msgid "Missing: %s."
|
||||||
msgstr "Не хватает: %s."
|
msgstr "Не хватает: %s."
|
||||||
|
|
||||||
|
#: web/src/shared/format.ts
|
||||||
|
msgid "Mobile"
|
||||||
|
msgstr "Мобильный"
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "Monthly"
|
msgid "Monthly"
|
||||||
msgstr "В месяц"
|
msgstr "В месяц"
|
||||||
@@ -4278,6 +4425,10 @@ msgstr "Ключи обновлены %s"
|
|||||||
msgid "New keys generated"
|
msgid "New keys generated"
|
||||||
msgstr "Новые ключи созданы"
|
msgstr "Новые ключи созданы"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "New keys issued for device %s on the portal"
|
||||||
|
msgstr "Для устройства %s выпущены новые ключи через портал"
|
||||||
|
|
||||||
#: web/src/admin/pages/person/header.ts
|
#: web/src/admin/pages/person/header.ts
|
||||||
msgid "New link"
|
msgid "New link"
|
||||||
msgstr "Новая ссылка"
|
msgstr "Новая ссылка"
|
||||||
@@ -4544,6 +4695,10 @@ msgstr "Бессрочно"
|
|||||||
msgid "None: without the tunnel those devices have no DNS."
|
msgid "None: without the tunnel those devices have no DNS."
|
||||||
msgstr "Нет: без туннеля у этих устройств не будет DNS."
|
msgstr "Нет: без туннеля у этих устройств не будет DNS."
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Normal"
|
||||||
|
msgstr "Обычный"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
||||||
msgid "Not a Dawnline export."
|
msgid "Not a Dawnline export."
|
||||||
msgstr "Файл не является экспортом Dawnline."
|
msgstr "Файл не является экспортом Dawnline."
|
||||||
@@ -4618,6 +4773,10 @@ msgstr "Не настроено."
|
|||||||
msgid "Not set: the certificate is picked automatically."
|
msgid "Not set: the certificate is picked automatically."
|
||||||
msgstr "Не заданы: сертификат выбирается автоматически."
|
msgstr "Не заданы: сертификат выбирается автоматически."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Not used"
|
||||||
|
msgstr "Без трафика"
|
||||||
|
|
||||||
#: web/src/admin/pages/diagnostics/health.ts
|
#: web/src/admin/pages/diagnostics/health.ts
|
||||||
msgid "Not working"
|
msgid "Not working"
|
||||||
msgstr "Не работает"
|
msgstr "Не работает"
|
||||||
@@ -5051,6 +5210,10 @@ msgstr "%s: добавлено устройство %s"
|
|||||||
msgid "Person %s added device %s on their portal"
|
msgid "Person %s added device %s on their portal"
|
||||||
msgstr "%s: добавлено устройство %s через портал"
|
msgstr "%s: добавлено устройство %s через портал"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Person %s changed device %s on their portal"
|
||||||
|
msgstr "Пользователь %s изменил настройки устройства %s в личном портале"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Person %s issued new keys for device %s on their portal"
|
msgid "Person %s issued new keys for device %s on their portal"
|
||||||
msgstr "%s: выпущены новые ключи для устройства %s через портал"
|
msgstr "%s: выпущены новые ключи для устройства %s через портал"
|
||||||
@@ -5071,6 +5234,10 @@ msgstr "%s: удалено устройство %s"
|
|||||||
msgid "Person %s removed device %s on their portal"
|
msgid "Person %s removed device %s on their portal"
|
||||||
msgstr "%s: удалено устройство %s через портал"
|
msgstr "%s: удалено устройство %s через портал"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Person %s renamed device %s on their portal"
|
||||||
|
msgstr "Пользователь %s изменил название устройства %s в личном портале"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Person %s resumed"
|
msgid "Person %s resumed"
|
||||||
msgstr "%s: доступ возобновлён"
|
msgstr "%s: доступ возобновлён"
|
||||||
@@ -6088,6 +6255,10 @@ msgstr "Скорость"
|
|||||||
msgid "Speed now"
|
msgid "Speed now"
|
||||||
msgstr "Скорость сейчас"
|
msgstr "Скорость сейчас"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Speed over the last 2 minutes"
|
||||||
|
msgstr "Скорость за последние 2 минуты"
|
||||||
|
|
||||||
#: web/src/admin/disguise.ts
|
#: web/src/admin/disguise.ts
|
||||||
msgid "Standard (old)"
|
msgid "Standard (old)"
|
||||||
msgstr "Стандартная (старая)"
|
msgstr "Стандартная (старая)"
|
||||||
@@ -6195,6 +6366,10 @@ msgstr "Переход на AmneziaWG %s"
|
|||||||
msgid "System"
|
msgid "System"
|
||||||
msgstr "Система"
|
msgstr "Система"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "System log"
|
||||||
|
msgstr "Системный журнал"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/libexec/dawnline/updater
|
#: package/luci-app-dawnline/root/usr/libexec/dawnline/updater
|
||||||
#: web/src/admin/pages/components/activity.ts
|
#: web/src/admin/pages/components/activity.ts
|
||||||
#: web/src/admin/pages/settings/updates.ts
|
#: web/src/admin/pages/settings/updates.ts
|
||||||
@@ -6299,6 +6474,10 @@ msgstr "Резервная копия (%s) будет удалена с роут
|
|||||||
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
||||||
msgstr "Снова установится сборка, сохранённая на роутере. Все туннели AmneziaWG перезапустятся на несколько секунд."
|
msgstr "Снова установится сборка, сохранённая на роутере. Все туннели AmneziaWG перезапустятся на несколько секунд."
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "The busiest of the %s days"
|
||||||
|
msgstr "Самый загруженный из %s дней"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
||||||
msgid "The configuration in this file cannot be read."
|
msgid "The configuration in this file cannot be read."
|
||||||
msgstr "Не удаётся прочитать конфигурацию из этого файла."
|
msgstr "Не удаётся прочитать конфигурацию из этого файла."
|
||||||
@@ -6379,6 +6558,10 @@ msgstr "Модуль ядра не загружается: %s Переустан
|
|||||||
msgid "The latest release is %s"
|
msgid "The latest release is %s"
|
||||||
msgstr "Последний релиз - %s"
|
msgstr "Последний релиз - %s"
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "The link has the server’s IP address, not its name: if the address changes, set the device up again."
|
||||||
|
msgstr "В ссылке IP-адрес сервера, а не его имя: если адрес сменится, настройте устройство заново."
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "The link is up but not attached to %s."
|
msgid "The link is up but not attached to %s."
|
||||||
msgstr "Домашний маршрут поднят, но не подключён к %s."
|
msgstr "Домашний маршрут поднят, но не подключён к %s."
|
||||||
@@ -6680,8 +6863,7 @@ msgstr "Чтобы оставить старую маскировку части
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Today"
|
msgid "Today"
|
||||||
msgstr "Сегодня"
|
msgstr "Сегодня"
|
||||||
|
|
||||||
@@ -6718,6 +6900,10 @@ msgstr "История трафика"
|
|||||||
msgid "Traffic history reset"
|
msgid "Traffic history reset"
|
||||||
msgstr "История трафика сброшена"
|
msgstr "История трафика сброшена"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Traffic, last 30 days"
|
||||||
|
msgstr "Трафик за последние 30 дней"
|
||||||
|
|
||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "Translation"
|
msgid "Translation"
|
||||||
msgstr "Перевод"
|
msgstr "Перевод"
|
||||||
@@ -6746,6 +6932,11 @@ msgstr "Пробуем зеркало %s"
|
|||||||
msgid "Tunnel"
|
msgid "Tunnel"
|
||||||
msgstr "Туннель"
|
msgstr "Туннель"
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Tunnel"
|
||||||
|
msgstr "Туннель"
|
||||||
|
|
||||||
#: web/src/admin/pages/overview.ts
|
#: web/src/admin/pages/overview.ts
|
||||||
msgid "Tunnel %s is down."
|
msgid "Tunnel %s is down."
|
||||||
msgstr "Туннель %s не работает."
|
msgstr "Туннель %s не работает."
|
||||||
@@ -6876,6 +7067,10 @@ msgstr "Неизвестный город"
|
|||||||
msgid "Unknown component %s"
|
msgid "Unknown component %s"
|
||||||
msgstr "Неизвестный компонент: %s"
|
msgstr "Неизвестный компонент: %s"
|
||||||
|
|
||||||
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
|
msgid "Unknown device type."
|
||||||
|
msgstr "Неизвестный тип устройства."
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc
|
||||||
@@ -7129,6 +7324,13 @@ msgstr "Порт занят: %s. Выберите другой."
|
|||||||
msgid "Used for HTTPS links"
|
msgid "Used for HTTPS links"
|
||||||
msgstr "Для ссылок HTTPS"
|
msgstr "Для ссылок HTTPS"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Used on %s of %s day"
|
||||||
|
msgid_plural "Used on %s of %s days"
|
||||||
|
msgstr[0] "С трафиком %s из %s дня"
|
||||||
|
msgstr[1] "С трафиком %s из %s дней"
|
||||||
|
msgstr[2] "С трафиком %s из %s дней"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "Using a self-signed certificate: browsers will show a warning."
|
msgid "Using a self-signed certificate: browsers will show a warning."
|
||||||
msgstr "Используется самоподписанный сертификат: браузеры покажут предупреждение."
|
msgstr "Используется самоподписанный сертификат: браузеры покажут предупреждение."
|
||||||
@@ -7137,10 +7339,22 @@ msgstr "Используется самоподписанный сертифик
|
|||||||
msgid "Using a self-signed certificate: browsers will show a warning. ACME can get a free Let’s Encrypt one."
|
msgid "Using a self-signed certificate: browsers will show a warning. ACME can get a free Let’s Encrypt one."
|
||||||
msgstr "Используется самоподписанный сертификат: браузеры покажут предупреждение. Через ACME можно получить бесплатный сертификат Let’s Encrypt."
|
msgstr "Используется самоподписанный сертификат: браузеры покажут предупреждение. Через ACME можно получить бесплатный сертификат Let’s Encrypt."
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "V2RayTun on Android: %s, or copy the link and %s."
|
||||||
|
msgstr "V2RayTun на Android: %s или скопируйте ссылку и %s."
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "V2RayTun on Windows: %s, then set its mode to %s and connect. That mode needs administrator rights: the app offers to restart with them."
|
||||||
|
msgstr "V2RayTun на Windows: %s, затем выберите режим «%s» и подключитесь. Для этого режима нужны права администратора: приложение предложит перезапуститься с ними."
|
||||||
|
|
||||||
#: web/src/admin/interfaces.ts
|
#: web/src/admin/interfaces.ts
|
||||||
msgid "VPN & tunnels"
|
msgid "VPN & tunnels"
|
||||||
msgstr "VPN и туннели"
|
msgstr "VPN и туннели"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Verbose (debug)"
|
||||||
|
msgstr "Подробный (отладка)"
|
||||||
|
|
||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "Versions"
|
msgid "Versions"
|
||||||
msgstr "Версии"
|
msgstr "Версии"
|
||||||
@@ -7182,6 +7396,10 @@ msgstr "Внимание: не удалось сохранить %s: %s"
|
|||||||
msgid "Warning: the installed build is no longer published, nothing to keep for rollback"
|
msgid "Warning: the installed build is no longer published, nothing to keep for rollback"
|
||||||
msgstr "Внимание: установленная сборка больше не публикуется, сохранить для отката нечего"
|
msgstr "Внимание: установленная сборка больше не публикуется, сохранить для отката нечего"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Warnings and errors"
|
||||||
|
msgstr "Предупреждения и ошибки"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
||||||
#: web/src/admin/pages/diagnostics/health.ts
|
#: web/src/admin/pages/diagnostics/health.ts
|
||||||
msgid "Watchdog"
|
msgid "Watchdog"
|
||||||
@@ -7211,6 +7429,10 @@ msgstr "Раз в неделю"
|
|||||||
msgid "Went offline"
|
msgid "Went offline"
|
||||||
msgstr "Вышло из сети"
|
msgstr "Вышло из сети"
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "What Dawnline writes to the router’s system log (logread -e dawnline). Verbose adds each step of a start and of applying settings."
|
||||||
|
msgstr "Что Dawnline пишет в системный журнал роутера (logread -e dawnline). Подробный добавляет каждый шаг запуска и применения настроек."
|
||||||
|
|
||||||
#: web/src/admin/pages/server.ts
|
#: web/src/admin/pages/server.ts
|
||||||
#: web/src/admin/pages/settings/portal.ts
|
#: web/src/admin/pages/settings/portal.ts
|
||||||
msgid "What people see"
|
msgid "What people see"
|
||||||
@@ -7318,7 +7540,7 @@ msgstr "По неверной ссылке откроется просто «Not
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "Yesterday"
|
msgid "Yesterday"
|
||||||
msgstr "Вчера"
|
msgstr "Вчера"
|
||||||
|
|
||||||
@@ -7334,6 +7556,10 @@ msgstr "Вы"
|
|||||||
msgid "You added circle %s"
|
msgid "You added circle %s"
|
||||||
msgstr "Вы добавили круг %s"
|
msgstr "Вы добавили круг %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added device %s"
|
||||||
|
msgstr "Вы добавили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You added device %s for %s"
|
msgid "You added device %s for %s"
|
||||||
msgstr "Вы добавили устройство %s (%s)"
|
msgstr "Вы добавили устройство %s (%s)"
|
||||||
@@ -7342,10 +7568,18 @@ msgstr "Вы добавили устройство %s (%s)"
|
|||||||
msgid "You added person %s"
|
msgid "You added person %s"
|
||||||
msgstr "Вы добавили человека %s"
|
msgstr "Вы добавили человека %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added this person"
|
||||||
|
msgstr "Вы добавили этого человека"
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed circle %s"
|
msgid "You changed circle %s"
|
||||||
msgstr "Вы изменили круг %s"
|
msgstr "Вы изменили круг %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed device %s"
|
||||||
|
msgstr "Вы изменили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You changed device %s of %s"
|
msgid "You changed device %s of %s"
|
||||||
msgstr "Вы изменили устройство %s (%s)"
|
msgstr "Вы изменили устройство %s (%s)"
|
||||||
@@ -7358,6 +7592,10 @@ msgstr "Вы изменили настройки: %s"
|
|||||||
msgid "You changed server %s"
|
msgid "You changed server %s"
|
||||||
msgstr "Вы изменили сервер %s"
|
msgstr "Вы изменили сервер %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed settings"
|
||||||
|
msgstr "Вы изменили настройки"
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed the personal portal"
|
msgid "You changed the personal portal"
|
||||||
msgstr "Вы изменили настройки личного портала"
|
msgstr "Вы изменили настройки личного портала"
|
||||||
@@ -7386,10 +7624,22 @@ msgstr "Вы импортировали настройки из файла"
|
|||||||
msgid "You issued a new link for person %s"
|
msgid "You issued a new link for person %s"
|
||||||
msgstr "Вы выпустили новую личную ссылку: %s"
|
msgstr "Вы выпустили новую личную ссылку: %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You issued a new personal link"
|
||||||
|
msgstr "Вы выпустили новую личную ссылку"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You issued new keys for device %s"
|
||||||
|
msgstr "Вы выпустили новые ключи для устройства %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You issued new keys for device %s of %s"
|
msgid "You issued new keys for device %s of %s"
|
||||||
msgstr "Вы выпустили новые ключи для устройства %s (%s)"
|
msgstr "Вы выпустили новые ключи для устройства %s (%s)"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You paused access"
|
||||||
|
msgstr "Вы приостановили доступ"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You paused person %s"
|
msgid "You paused person %s"
|
||||||
msgstr "Вы приостановили доступ: %s"
|
msgstr "Вы приостановили доступ: %s"
|
||||||
@@ -7398,6 +7648,10 @@ msgstr "Вы приостановили доступ: %s"
|
|||||||
msgid "You removed circle %s"
|
msgid "You removed circle %s"
|
||||||
msgstr "Вы удалили круг %s"
|
msgstr "Вы удалили круг %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You removed device %s"
|
||||||
|
msgstr "Вы удалили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You removed device %s from %s"
|
msgid "You removed device %s from %s"
|
||||||
msgstr "Вы удалили устройство %s (%s)"
|
msgstr "Вы удалили устройство %s (%s)"
|
||||||
@@ -7410,6 +7664,14 @@ msgstr "Вы удалили человека %s"
|
|||||||
msgid "You removed server %s"
|
msgid "You removed server %s"
|
||||||
msgstr "Вы удалили сервер %s"
|
msgstr "Вы удалили сервер %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You removed this person"
|
||||||
|
msgstr "Вы удалили этого человека"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You renamed device %s"
|
||||||
|
msgstr "Вы изменили название устройства %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You renamed device %s of %s"
|
msgid "You renamed device %s of %s"
|
||||||
msgstr "Вы переименовали устройство %s (%s)"
|
msgstr "Вы переименовали устройство %s (%s)"
|
||||||
@@ -7430,10 +7692,18 @@ msgstr "Вы восстановили резервную копию из фай
|
|||||||
msgid "You restored backup %s"
|
msgid "You restored backup %s"
|
||||||
msgstr "Вы восстановили резервную копию %s"
|
msgstr "Вы восстановили резервную копию %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You resumed access"
|
||||||
|
msgstr "Вы возобновили доступ"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You resumed person %s"
|
msgid "You resumed person %s"
|
||||||
msgstr "Вы возобновили доступ: %s"
|
msgstr "Вы возобновили доступ: %s"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned off device %s"
|
||||||
|
msgstr "Вы выключили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned off device %s of %s"
|
msgid "You turned off device %s of %s"
|
||||||
msgstr "Вы выключили устройство %s (%s)"
|
msgstr "Вы выключили устройство %s (%s)"
|
||||||
@@ -7450,6 +7720,10 @@ msgstr "Вы выключили личный портал"
|
|||||||
msgid "You turned off the watchdog"
|
msgid "You turned off the watchdog"
|
||||||
msgstr "Вы выключили автовосстановление"
|
msgstr "Вы выключили автовосстановление"
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned on device %s"
|
||||||
|
msgstr "Вы включили устройство %s"
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned on device %s of %s"
|
msgid "You turned on device %s of %s"
|
||||||
msgstr "Вы включили устройство %s (%s)"
|
msgstr "Вы включили устройство %s (%s)"
|
||||||
@@ -7514,6 +7788,14 @@ msgstr "без имени"
|
|||||||
msgid "a new build needs a manual switch in Components"
|
msgid "a new build needs a manual switch in Components"
|
||||||
msgstr ": новую сборку нужно включить вручную в «Компонентах»"
|
msgstr ": новую сборку нужно включить вручную в «Компонентах»"
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "about %s by the reset on %s"
|
||||||
|
msgstr "около %s к сбросу %s"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "about average"
|
||||||
|
msgstr "около среднего"
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "access"
|
msgid "access"
|
||||||
msgstr "доступ"
|
msgstr "доступ"
|
||||||
@@ -7818,6 +8100,13 @@ msgstr ": ошибка (%s)"
|
|||||||
msgid "from the portal"
|
msgid "from the portal"
|
||||||
msgstr "через портал"
|
msgstr "через портал"
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "full in about %s day, %s"
|
||||||
|
msgid_plural "full in about %s days, %s"
|
||||||
|
msgstr[0] "закончится примерно через %s день, %s"
|
||||||
|
msgstr[1] "закончится примерно через %s дня, %s"
|
||||||
|
msgstr[2] "закончится примерно через %s дней, %s"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "has an invalid interface name \"%s\""
|
msgid "has an invalid interface name \"%s\""
|
||||||
msgstr ": недопустимое имя интерфейса «%s»"
|
msgstr ": недопустимое имя интерфейса «%s»"
|
||||||
@@ -7950,6 +8239,10 @@ msgstr "сохранить доступ"
|
|||||||
msgid "keep-alive"
|
msgid "keep-alive"
|
||||||
msgstr "keep-alive"
|
msgstr "keep-alive"
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "keep-alive %s s"
|
||||||
|
msgstr "keep-alive %s с"
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "kept in memory only (lost on reboot)"
|
msgid "kept in memory only (lost on reboot)"
|
||||||
msgstr "только в памяти (пропадают при перезагрузке)"
|
msgstr "только в памяти (пропадают при перезагрузке)"
|
||||||
@@ -7966,10 +8259,6 @@ msgstr ": модуль ядра не установлен, туннели не
|
|||||||
msgid "kernel module isn't loaded"
|
msgid "kernel module isn't loaded"
|
||||||
msgstr ": модуль ядра не загружен"
|
msgstr ": модуль ядра не загружен"
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "last 15 min"
|
|
||||||
msgstr "за 15 мин"
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "last 2 min"
|
msgid "last 2 min"
|
||||||
msgstr "за 2 мин"
|
msgstr "за 2 мин"
|
||||||
@@ -8104,6 +8393,7 @@ msgstr "не настроено"
|
|||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
#: web/src/admin/places/render.ts
|
#: web/src/admin/places/render.ts
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "now"
|
msgid "now"
|
||||||
msgstr "сейчас"
|
msgstr "сейчас"
|
||||||
|
|
||||||
@@ -8163,10 +8453,6 @@ msgstr "приостановить доступ"
|
|||||||
msgid "paused by admin"
|
msgid "paused by admin"
|
||||||
msgstr "приостановлено администратором"
|
msgstr "приостановлено администратором"
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "peak %s"
|
|
||||||
msgstr "пик %s"
|
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "port %s"
|
msgid "port %s"
|
||||||
msgstr "порт %s"
|
msgstr "порт %s"
|
||||||
@@ -8311,6 +8597,10 @@ msgstr "настраиваем заново"
|
|||||||
msgid "sha256 matches the release (%s…)"
|
msgid "sha256 matches the release (%s…)"
|
||||||
msgstr "sha256 совпадает с релизом (%s…)"
|
msgstr "sha256 совпадает с релизом (%s…)"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "so far"
|
||||||
|
msgstr "пока"
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
||||||
msgid "started"
|
msgid "started"
|
||||||
msgstr ": запущен"
|
msgstr ": запущен"
|
||||||
@@ -8385,6 +8675,14 @@ msgstr "сегодня %s"
|
|||||||
msgid "tunnel network"
|
msgid "tunnel network"
|
||||||
msgstr "сеть туннеля"
|
msgstr "сеть туннеля"
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "type"
|
||||||
|
msgstr "тип"
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "type: %s"
|
||||||
|
msgstr "тип: %s"
|
||||||
|
|
||||||
#: web/src/admin/pages/people.ts
|
#: web/src/admin/pages/people.ts
|
||||||
#: web/src/admin/pages/settings/portal.ts
|
#: web/src/admin/pages/settings/portal.ts
|
||||||
msgid "until %s"
|
msgid "until %s"
|
||||||
@@ -8488,3 +8786,7 @@ msgstr "«%s» - не IP-адрес. Несколько адресов разд
|
|||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "← Newer"
|
msgid "← Newer"
|
||||||
msgstr "← Новее"
|
msgstr "← Новее"
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "−%s%% vs average"
|
||||||
|
msgstr "−%s%% к среднему"
|
||||||
@@ -117,6 +117,10 @@ msgstr[1] ""
|
|||||||
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
msgid "%s MB free: settings may stop saving. Remove old backups (Settings → Backups) or shorten the history."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "%s a day lately"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/access.ts
|
#: web/src/admin/access.ts
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s added"
|
msgid "%s added"
|
||||||
@@ -250,6 +254,12 @@ msgstr ""
|
|||||||
msgid "%s check failed"
|
msgid "%s check failed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "%s city"
|
||||||
|
msgid_plural "%s cities"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
msgid "%s copied"
|
msgid "%s copied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -353,6 +363,10 @@ msgstr ""
|
|||||||
msgid "%s does not overlap other networks."
|
msgid "%s does not overlap other networks."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "%s does not resolve right now, and V2RayTun on Android connects by IP address only."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "%s does not resolve."
|
msgid "%s does not resolve."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -665,6 +679,10 @@ msgstr ""
|
|||||||
msgid "%s may not contain # or a line break."
|
msgid "%s may not contain # or a line break."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s min %s s ago"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/shared/format.ts
|
#: web/src/shared/format.ts
|
||||||
msgid "%s min ago"
|
msgid "%s min ago"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -869,6 +887,10 @@ msgstr ""
|
|||||||
msgid "%s s"
|
msgid "%s s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "%s s ago"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/logs.ts
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
msgid "%s since %s"
|
msgid "%s since %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1017,6 +1039,10 @@ msgstr ""
|
|||||||
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
msgid "%s: <%s> is not a tag AmneziaWG apps accept: use <b 0x…> with an even number of hex digits, <r N>, <rc N> or <rd N> with N from 1 to 1000, or <t>."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "%s: automatic"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc
|
||||||
msgid "%s: the device's own network handles it."
|
msgid "%s: the device's own network handles it."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1055,6 +1081,10 @@ msgid_plural "+%s more in What’s new"
|
|||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "+%s%% vs average"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "+1 month"
|
msgid "+1 month"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1088,6 +1118,10 @@ msgstr ""
|
|||||||
msgid "15 min"
|
msgid "15 min"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/overview.ts
|
||||||
|
msgid "2 min"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
msgid "24h"
|
msgid "24h"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1187,12 +1221,22 @@ msgstr ""
|
|||||||
msgid "Access ends %s"
|
msgid "Access ends %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access ends in %s day"
|
||||||
|
msgid_plural "Access ends in %s days"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: web/src/admin/netcheck.ts
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends in %s day (%s)."
|
msgid "Access ends in %s day (%s)."
|
||||||
msgid_plural "Access ends in %s days (%s)."
|
msgid_plural "Access ends in %s days (%s)."
|
||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access ends in a few days"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/netcheck.ts
|
#: web/src/admin/netcheck.ts
|
||||||
msgid "Access ends today (%s)."
|
msgid "Access ends today (%s)."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1201,6 +1245,22 @@ msgstr ""
|
|||||||
msgid "Access must be lan, internet or both."
|
msgid "Access must be lan, internet or both."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access paused"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access paused - %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access resumed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Access resumed - %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc
|
||||||
@@ -1387,6 +1447,10 @@ msgstr ""
|
|||||||
msgid "All components"
|
msgid "All components"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "All devices removed, end date reached"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/overview.ts
|
#: web/src/admin/pages/overview.ts
|
||||||
msgid "All good. Nothing needs you right now."
|
msgid "All good. Nothing needs you right now."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2068,6 +2132,10 @@ msgstr ""
|
|||||||
msgid "Choose a server on their page"
|
msgid "Choose a server on their page"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
||||||
|
msgid "Choose a system log level: errors, warnings, normal or verbose."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "Choose another interface name in the server settings."
|
msgid "Choose another interface name in the server settings."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2149,10 +2217,6 @@ msgstr ""
|
|||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Collecting… 1 point a minute"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "Collecting… 1 point a second"
|
msgid "Collecting… 1 point a second"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2470,6 +2534,10 @@ msgstr ""
|
|||||||
msgid "Dawnline was updated to %s: reload the page."
|
msgid "Dawnline was updated to %s: reload the page."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Days this device was used"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc
|
||||||
msgid "Default device limit must be 1-32."
|
msgid "Default device limit must be 1-32."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2523,10 +2591,26 @@ msgstr ""
|
|||||||
msgid "Device"
|
msgid "Device"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s added"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s added on the portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s changed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s changed network %s"
|
msgid "Device %s changed network %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s changed on the portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s connected"
|
msgid "Device %s connected"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2587,6 +2671,30 @@ msgstr ""
|
|||||||
msgid "Device %s of %s: the public key is the server's own."
|
msgid "Device %s of %s: the public key is the server's own."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s removed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s removed on the portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s renamed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s renamed on the portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s turned off"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Device %s turned on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Device %s went offline"
|
msgid "Device %s went offline"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2879,6 +2987,10 @@ msgstr ""
|
|||||||
msgid "End date must be YYYY-MM-DD."
|
msgid "End date must be YYYY-MM-DD."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "End date passed (%s) · access kept"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "End dates and quotas use the router clock."
|
msgid "End dates and quotas use the router clock."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -2927,6 +3039,10 @@ msgstr ""
|
|||||||
msgid "Error: %s"
|
msgid "Error: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Errors only"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/logs.ts
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
msgid "Every 10 min"
|
msgid "Every 10 min"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -3373,6 +3489,21 @@ msgstr ""
|
|||||||
msgid "Import JSON"
|
msgid "Import JSON"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Import config from Clipboard"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Import config from QRcode"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Import from clipboard"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/settings/backups.ts
|
#: web/src/admin/pages/settings/backups.ts
|
||||||
msgid "Import?"
|
msgid "Import?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -3774,11 +3905,20 @@ msgstr ""
|
|||||||
msgid "LAN Bypass"
|
msgid "LAN Bypass"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "LAN Bypass off"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "LAN Bypass on"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "Last 30 days"
|
msgid "Last 30 days"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/device.ts
|
#: web/src/admin/device.ts
|
||||||
|
#: web/src/admin/widgets/spark.ts
|
||||||
msgid "Last 7 days"
|
msgid "Last 7 days"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -3820,6 +3960,7 @@ msgstr ""
|
|||||||
msgid "Limit hours"
|
msgid "Limit hours"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
#: web/src/admin/invite.ts
|
#: web/src/admin/invite.ts
|
||||||
msgid "Link copied"
|
msgid "Link copied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -4043,6 +4184,10 @@ msgstr ""
|
|||||||
msgid "Missing: %s."
|
msgid "Missing: %s."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/format.ts
|
||||||
|
msgid "Mobile"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/person/limits.ts
|
#: web/src/admin/pages/person/limits.ts
|
||||||
msgid "Monthly"
|
msgid "Monthly"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -4222,6 +4367,10 @@ msgstr ""
|
|||||||
msgid "New keys generated"
|
msgid "New keys generated"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "New keys issued for device %s on the portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/person/header.ts
|
#: web/src/admin/pages/person/header.ts
|
||||||
msgid "New link"
|
msgid "New link"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -4487,6 +4636,10 @@ msgstr ""
|
|||||||
msgid "None: without the tunnel those devices have no DNS."
|
msgid "None: without the tunnel those devices have no DNS."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Normal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
||||||
msgid "Not a Dawnline export."
|
msgid "Not a Dawnline export."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -4561,6 +4714,10 @@ msgstr ""
|
|||||||
msgid "Not set: the certificate is picked automatically."
|
msgid "Not set: the certificate is picked automatically."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Not used"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/diagnostics/health.ts
|
#: web/src/admin/pages/diagnostics/health.ts
|
||||||
msgid "Not working"
|
msgid "Not working"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -4993,6 +5150,10 @@ msgstr ""
|
|||||||
msgid "Person %s added device %s on their portal"
|
msgid "Person %s added device %s on their portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Person %s changed device %s on their portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Person %s issued new keys for device %s on their portal"
|
msgid "Person %s issued new keys for device %s on their portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -5013,6 +5174,10 @@ msgstr ""
|
|||||||
msgid "Person %s removed device %s on their portal"
|
msgid "Person %s removed device %s on their portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "Person %s renamed device %s on their portal"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "Person %s resumed"
|
msgid "Person %s resumed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6026,6 +6191,10 @@ msgstr ""
|
|||||||
msgid "Speed now"
|
msgid "Speed now"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Speed over the last 2 minutes"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/disguise.ts
|
#: web/src/admin/disguise.ts
|
||||||
msgid "Standard (old)"
|
msgid "Standard (old)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6132,6 +6301,10 @@ msgstr ""
|
|||||||
msgid "System"
|
msgid "System"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "System log"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/libexec/dawnline/updater
|
#: package/luci-app-dawnline/root/usr/libexec/dawnline/updater
|
||||||
#: web/src/admin/pages/components/activity.ts
|
#: web/src/admin/pages/components/activity.ts
|
||||||
#: web/src/admin/pages/settings/updates.ts
|
#: web/src/admin/pages/settings/updates.ts
|
||||||
@@ -6236,6 +6409,10 @@ msgstr ""
|
|||||||
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
msgid "The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "The busiest of the %s days"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/backup.uc
|
||||||
msgid "The configuration in this file cannot be read."
|
msgid "The configuration in this file cannot be read."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6316,6 +6493,10 @@ msgstr ""
|
|||||||
msgid "The latest release is %s"
|
msgid "The latest release is %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "The link has the server’s IP address, not its name: if the address changes, set the device up again."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "The link is up but not attached to %s."
|
msgid "The link is up but not attached to %s."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6614,8 +6795,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "Today"
|
msgid "Today"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -6652,6 +6832,10 @@ msgstr ""
|
|||||||
msgid "Traffic history reset"
|
msgid "Traffic history reset"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/tiles.ts
|
||||||
|
msgid "Traffic, last 30 days"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "Translation"
|
msgid "Translation"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6680,6 +6864,11 @@ msgstr ""
|
|||||||
msgid "Tunnel"
|
msgid "Tunnel"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgctxt "V2RayTun app"
|
||||||
|
msgid "Tunnel"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/overview.ts
|
#: web/src/admin/pages/overview.ts
|
||||||
msgid "Tunnel %s is down."
|
msgid "Tunnel %s is down."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -6810,6 +6999,10 @@ msgstr ""
|
|||||||
msgid "Unknown component %s"
|
msgid "Unknown component %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
|
msgid "Unknown device type."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc
|
||||||
@@ -7062,6 +7255,12 @@ msgstr ""
|
|||||||
msgid "Used for HTTPS links"
|
msgid "Used for HTTPS links"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "Used on %s of %s day"
|
||||||
|
msgid_plural "Used on %s of %s days"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc
|
||||||
msgid "Using a self-signed certificate: browsers will show a warning."
|
msgid "Using a self-signed certificate: browsers will show a warning."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7070,10 +7269,22 @@ msgstr ""
|
|||||||
msgid "Using a self-signed certificate: browsers will show a warning. ACME can get a free Let’s Encrypt one."
|
msgid "Using a self-signed certificate: browsers will show a warning. ACME can get a free Let’s Encrypt one."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "V2RayTun on Android: %s, or copy the link and %s."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/cores/awg.ts
|
||||||
|
msgid "V2RayTun on Windows: %s, then set its mode to %s and connect. That mode needs administrator rights: the app offers to restart with them."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/interfaces.ts
|
#: web/src/admin/interfaces.ts
|
||||||
msgid "VPN & tunnels"
|
msgid "VPN & tunnels"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Verbose (debug)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "Versions"
|
msgid "Versions"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7115,6 +7326,10 @@ msgstr ""
|
|||||||
msgid "Warning: the installed build is no longer published, nothing to keep for rollback"
|
msgid "Warning: the installed build is no longer published, nothing to keep for rollback"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "Warnings and errors"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
#: package/luci-app-dawnline/root/usr/libexec/dawnline/agent
|
||||||
#: web/src/admin/pages/diagnostics/health.ts
|
#: web/src/admin/pages/diagnostics/health.ts
|
||||||
msgid "Watchdog"
|
msgid "Watchdog"
|
||||||
@@ -7144,6 +7359,10 @@ msgstr ""
|
|||||||
msgid "Went offline"
|
msgid "Went offline"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/pages/settings/logs.ts
|
||||||
|
msgid "What Dawnline writes to the router’s system log (logread -e dawnline). Verbose adds each step of a start and of applying settings."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/server.ts
|
#: web/src/admin/pages/server.ts
|
||||||
#: web/src/admin/pages/settings/portal.ts
|
#: web/src/admin/pages/settings/portal.ts
|
||||||
msgid "What people see"
|
msgid "What people see"
|
||||||
@@ -7250,7 +7469,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
#: web/src/admin/places/model.ts
|
#: web/src/admin/places/model.ts
|
||||||
#: web/src/admin/widgets/spark.ts
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "Yesterday"
|
msgid "Yesterday"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -7266,6 +7485,10 @@ msgstr ""
|
|||||||
msgid "You added circle %s"
|
msgid "You added circle %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You added device %s for %s"
|
msgid "You added device %s for %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7274,10 +7497,18 @@ msgstr ""
|
|||||||
msgid "You added person %s"
|
msgid "You added person %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You added this person"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed circle %s"
|
msgid "You changed circle %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You changed device %s of %s"
|
msgid "You changed device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7290,6 +7521,10 @@ msgstr ""
|
|||||||
msgid "You changed server %s"
|
msgid "You changed server %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You changed settings"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "You changed the personal portal"
|
msgid "You changed the personal portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7318,10 +7553,22 @@ msgstr ""
|
|||||||
msgid "You issued a new link for person %s"
|
msgid "You issued a new link for person %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You issued a new personal link"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You issued new keys for device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You issued new keys for device %s of %s"
|
msgid "You issued new keys for device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You paused access"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You paused person %s"
|
msgid "You paused person %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7330,6 +7577,10 @@ msgstr ""
|
|||||||
msgid "You removed circle %s"
|
msgid "You removed circle %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You removed device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You removed device %s from %s"
|
msgid "You removed device %s from %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7342,6 +7593,14 @@ msgstr ""
|
|||||||
msgid "You removed server %s"
|
msgid "You removed server %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You removed this person"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You renamed device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You renamed device %s of %s"
|
msgid "You renamed device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7362,10 +7621,18 @@ msgstr ""
|
|||||||
msgid "You restored backup %s"
|
msgid "You restored backup %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You resumed access"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You resumed person %s"
|
msgid "You resumed person %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned off device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned off device %s of %s"
|
msgid "You turned off device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7382,6 +7649,10 @@ msgstr ""
|
|||||||
msgid "You turned off the watchdog"
|
msgid "You turned off the watchdog"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/render.ts
|
||||||
|
msgid "You turned on device %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/render.ts
|
#: web/src/admin/events/render.ts
|
||||||
msgid "You turned on device %s of %s"
|
msgid "You turned on device %s of %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7446,6 +7717,14 @@ msgstr ""
|
|||||||
msgid "a new build needs a manual switch in Components"
|
msgid "a new build needs a manual switch in Components"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "about %s by the reset on %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "about average"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "access"
|
msgid "access"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7749,6 +8028,12 @@ msgstr ""
|
|||||||
msgid "from the portal"
|
msgid "from the portal"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/shared/pace.ts
|
||||||
|
msgid "full in about %s day, %s"
|
||||||
|
msgid_plural "full in about %s days, %s"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc
|
||||||
msgid "has an invalid interface name \"%s\""
|
msgid "has an invalid interface name \"%s\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7881,6 +8166,10 @@ msgstr ""
|
|||||||
msgid "keep-alive"
|
msgid "keep-alive"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "keep-alive %s s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "kept in memory only (lost on reboot)"
|
msgid "kept in memory only (lost on reboot)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -7897,10 +8186,6 @@ msgstr ""
|
|||||||
msgid "kernel module isn't loaded"
|
msgid "kernel module isn't loaded"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "last 15 min"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
#: web/src/admin/widgets/tiles.ts
|
||||||
msgid "last 2 min"
|
msgid "last 2 min"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -8035,6 +8320,7 @@ msgstr ""
|
|||||||
|
|
||||||
#: web/src/admin/map.ts
|
#: web/src/admin/map.ts
|
||||||
#: web/src/admin/places/render.ts
|
#: web/src/admin/places/render.ts
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
msgid "now"
|
msgid "now"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -8093,10 +8379,6 @@ msgstr ""
|
|||||||
msgid "paused by admin"
|
msgid "paused by admin"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/widgets/tiles.ts
|
|
||||||
msgid "peak %s"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/admin/events/model.ts
|
#: web/src/admin/events/model.ts
|
||||||
msgid "port %s"
|
msgid "port %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -8241,6 +8523,10 @@ msgstr ""
|
|||||||
msgid "sha256 matches the release (%s…)"
|
msgid "sha256 matches the release (%s…)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "so far"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
#: package/luci-app-dawnline/root/usr/bin/dawnline
|
||||||
msgid "started"
|
msgid "started"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -8315,6 +8601,14 @@ msgstr ""
|
|||||||
msgid "tunnel network"
|
msgid "tunnel network"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "type"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/events/model.ts
|
||||||
|
msgid "type: %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/admin/pages/people.ts
|
#: web/src/admin/pages/people.ts
|
||||||
#: web/src/admin/pages/settings/portal.ts
|
#: web/src/admin/pages/settings/portal.ts
|
||||||
msgid "until %s"
|
msgid "until %s"
|
||||||
@@ -8416,3 +8710,7 @@ msgstr ""
|
|||||||
#: web/src/admin/pages/components/hero.ts
|
#: web/src/admin/pages/components/hero.ts
|
||||||
msgid "← Newer"
|
msgid "← Newer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/admin/widgets/readouts.ts
|
||||||
|
msgid "−%s%% vs average"
|
||||||
|
msgstr ""
|
||||||
@@ -8,15 +8,33 @@ USE_PROCD=1
|
|||||||
|
|
||||||
PORTAL_ROOT=/usr/share/dawnline/portal/www
|
PORTAL_ROOT=/usr/share/dawnline/portal/www
|
||||||
|
|
||||||
|
# A line in syslog as dawnline.util syslog() writes them: "dawnline: [info] [service] …" at the
|
||||||
|
# matching priority, when the admin's level (settings.log_level: error|warn|info|debug) takes it.
|
||||||
|
log() {
|
||||||
|
local lvl="$1" want rank prio
|
||||||
|
shift
|
||||||
|
want="$(uci -q get dawnline.settings.log_level)"
|
||||||
|
case "$lvl" in error) rank=0 prio=err ;; warn) rank=1 prio=warning ;; debug) rank=3 prio=debug ;; *) rank=2 prio=info ;; esac
|
||||||
|
case "$want" in error) want=0 ;; warn) want=1 ;; debug) want=3 ;; *) want=2 ;; esac
|
||||||
|
[ "$rank" -le "$want" ] || return 0
|
||||||
|
logger -t dawnline -p "daemon.$prio" "[$lvl] [service] $*"
|
||||||
|
}
|
||||||
|
|
||||||
start_portal() {
|
start_portal() {
|
||||||
local enabled port certs cert key hport http
|
local enabled port certs cert key hport http
|
||||||
config_get_bool enabled settings portal_enabled 0
|
config_get_bool enabled settings portal_enabled 0
|
||||||
[ "$enabled" = 1 ] || return 0
|
if [ "$enabled" != 1 ]; then
|
||||||
|
log info "personal portal is off"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
config_get port settings portal_port 8443
|
config_get port settings portal_port 8443
|
||||||
certs="$(/usr/bin/dawnline portal-cert 2>/dev/null)"
|
certs="$(/usr/bin/dawnline portal-cert 2>/dev/null)"
|
||||||
cert="${certs% *}"
|
cert="${certs% *}"
|
||||||
key="${certs#* }"
|
key="${certs#* }"
|
||||||
[ -f "$cert" ] && [ -f "$key" ] || return 0
|
if ! [ -f "$cert" ] || ! [ -f "$key" ]; then
|
||||||
|
log warn "personal portal not started: no certificate (${cert:-none}): choose one in Settings, or save the portal settings again"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
# IP addresses in links get plain HTTP on the next port (names stay HTTPS-only).
|
# IP addresses in links get plain HTTP on the next port (names stay HTTPS-only).
|
||||||
hport="$(/usr/bin/dawnline portal-http-port 2>/dev/null)"
|
hport="$(/usr/bin/dawnline portal-http-port 2>/dev/null)"
|
||||||
[ -n "$hport" ] && http="-p 0.0.0.0:$hport -p [::]:$hport"
|
[ -n "$hport" ] && http="-p 0.0.0.0:$hport -p [::]:$hport"
|
||||||
@@ -34,23 +52,30 @@ start_portal() {
|
|||||||
procd_set_param file "$cert"
|
procd_set_param file "$cert"
|
||||||
procd_set_param respawn 3600 5 0
|
procd_set_param respawn 3600 5 0
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
|
log info "personal portal on port $port (HTTPS${hport:+, plain HTTP on $hport for links with an IP address}) · certificate $cert$(openssl x509 -enddate -noout -in "$cert" 2>/dev/null | sed 's/^notAfter=/ until /') · $procs processes"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Plain DNS for Home-only tunnel devices (config written by `dawnline apply`).
|
# Plain DNS for Home-only tunnel devices (config written by `dawnline apply`).
|
||||||
start_resolver() {
|
start_resolver() {
|
||||||
[ -f /var/etc/dawnline-dns.conf ] || return 0
|
if ! [ -f /var/etc/dawnline-dns.conf ]; then
|
||||||
|
log debug "no DNS for Home-only devices (nobody needs it)"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
procd_open_instance dns
|
procd_open_instance dns
|
||||||
procd_set_param command /usr/libexec/dawnline/resolver
|
procd_set_param command /usr/libexec/dawnline/resolver
|
||||||
procd_set_param file /var/etc/dawnline-dns.conf
|
procd_set_param file /var/etc/dawnline-dns.conf
|
||||||
# A new config kills it (dawnline.resolver): back within a second, not five.
|
# A new config kills it (dawnline.resolver): back within a second, not five.
|
||||||
procd_set_param respawn 3600 1 0
|
procd_set_param respawn 3600 1 0
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
|
log info "DNS for Home-only devices started (/var/etc/dawnline-dns.conf)"
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
config_load dawnline
|
config_load dawnline
|
||||||
mkdir -p /var/run/dawnline
|
mkdir -p /var/run/dawnline
|
||||||
/usr/bin/dawnline apply >/dev/null 2>&1
|
log info "starting"
|
||||||
|
# The apply writes its own lines: what it came to and how long it took (each step at debug).
|
||||||
|
/usr/bin/dawnline apply >/dev/null 2>&1 || log error "applying the configuration failed: run \"dawnline apply\" to see why"
|
||||||
|
|
||||||
procd_open_instance agent
|
procd_open_instance agent
|
||||||
procd_set_param command /usr/libexec/dawnline/agent
|
procd_set_param command /usr/libexec/dawnline/agent
|
||||||
@@ -60,10 +85,12 @@ start_service() {
|
|||||||
|
|
||||||
start_portal
|
start_portal
|
||||||
start_resolver
|
start_resolver
|
||||||
|
log info "started"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Noted for the service log: the next agent start is a restart, not a crash or a boot.
|
# Noted for the service log: the next agent start is a restart, not a crash or a boot.
|
||||||
stop_service() {
|
stop_service() {
|
||||||
|
log info "stopping"
|
||||||
mkdir -p /var/run/dawnline
|
mkdir -p /var/run/dawnline
|
||||||
date +%s > /var/run/dawnline/agent.stopped
|
date +%s > /var/run/dawnline/agent.stopped
|
||||||
# Copies procd doesn't know about (started by hand, or left by an older version) go too.
|
# Copies procd doesn't know about (started by hand, or left by an older version) go too.
|
||||||
@@ -71,10 +98,15 @@ stop_service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reload_service() {
|
reload_service() {
|
||||||
/usr/bin/dawnline apply >/dev/null 2>&1
|
log info "reloading: settings changed"
|
||||||
|
/usr/bin/dawnline apply >/dev/null 2>&1 || log error "applying the configuration failed: run \"dawnline apply\" to see why"
|
||||||
start
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
service_triggers() {
|
service_triggers() {
|
||||||
procd_add_reload_trigger dawnline
|
procd_add_reload_trigger dawnline
|
||||||
|
# The portal's uhttpd reads its certificate once: an issued or renewed one needs a
|
||||||
|
# reload (procd restarts the portal alone, its cert file having changed).
|
||||||
|
procd_add_raw_trigger acme.issue 5000 /etc/init.d/dawnline reload
|
||||||
|
procd_add_raw_trigger acme.renew 5000 /etc/init.d/dawnline reload
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ import * as store from 'dawnline.store';
|
|||||||
import * as devices from 'dawnline.devices';
|
import * as devices from 'dawnline.devices';
|
||||||
import { L_ } from 'dawnline.i18n';
|
import { L_ } from 'dawnline.i18n';
|
||||||
import {
|
import {
|
||||||
VERSION, slog, slog_read, sh_out, q, take_iface_intent, read_json, write_json, ensure_dir, with_lock, RUN_DIR
|
VERSION, slog, syslog, slog_read, sh_out, q, take_iface_intent, read_json, write_json, ensure_dir, with_lock, RUN_DIR
|
||||||
} from 'dawnline.util';
|
} from 'dawnline.util';
|
||||||
|
|
||||||
/** Options that take no value. */
|
/** Options that take no value. */
|
||||||
@@ -338,5 +338,7 @@ try {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
warn(`dawnline: ${e.message}\n`);
|
warn(`dawnline: ${e.message}\n`);
|
||||||
|
// Run from the init script or cron, stderr goes nowhere: syslog keeps why.
|
||||||
|
syslog('error', 'cli', `dawnline ${cmd} failed: ${e.message}`);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
import * as uloop from 'uloop';
|
import * as uloop from 'uloop';
|
||||||
import { open, readfile, writefile, stat, unlink } from 'fs';
|
import { open, readfile, writefile, stat, unlink } from 'fs';
|
||||||
import {
|
import {
|
||||||
read_json, write_json, ensure_dir, sh_out, q, uniq, slog, slog_trim, slog_restore, date_end, DATA_DIR, RUN_DIR, VERSION
|
read_json, write_json, ensure_dir, sh_out, q, uniq, slog, syslog, slog_trim, slog_restore, date_end, DATA_DIR, RUN_DIR, VERSION
|
||||||
} from 'dawnline.util';
|
} from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as live from 'dawnline.live';
|
import * as live from 'dawnline.live';
|
||||||
@@ -641,8 +641,9 @@ function nightly_backup() {
|
|||||||
let st = read_json(`${DATA_DIR}/backup-state.json`, {});
|
let st = read_json(`${DATA_DIR}/backup-state.json`, {});
|
||||||
if (sum && sum != st.auto) {
|
if (sum && sum != st.auto) {
|
||||||
try {
|
try {
|
||||||
backup.backup_create('auto');
|
let b = backup.backup_create('auto');
|
||||||
write_json(`${DATA_DIR}/backup-state.json`, { auto: sum }, 0o600);
|
write_json(`${DATA_DIR}/backup-state.json`, { auto: sum }, 0o600);
|
||||||
|
syslog('info', 'backup', `nightly backup saved${b ? ': ' + b : ''}`);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// Tried again tomorrow; meanwhile the admin should know (a full flash, mostly).
|
// Tried again tomorrow; meanwhile the admin should know (a full flash, mostly).
|
||||||
@@ -794,9 +795,11 @@ function step(i, s, fn) {
|
|||||||
delete step_err[i];
|
delete step_err[i];
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
system(`logger -t dawnline-agent ${q(`${s.who}: ${e.message}`)}`);
|
// A new error goes to the service log (and from there to syslog); a repeat, or a quiet step's, to syslog alone.
|
||||||
if (!s.quiet && step_err[i] != e.message)
|
if (!s.quiet && step_err[i] != e.message)
|
||||||
slog('dawnline', 'error', sprintf(L_('failed: %s'), e.message), e.stacktrace?.[0]?.context, s.who);
|
slog('dawnline', 'error', sprintf(L_('failed: %s'), e.message), e.stacktrace?.[0]?.context, s.who);
|
||||||
|
else
|
||||||
|
syslog('error', 'agent', `${s.who}: ${e.message}`);
|
||||||
step_err[i] = e.message;
|
step_err[i] = e.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -835,7 +838,14 @@ function tick() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Once: a signal ends the loop and calls it, and so does the line after uloop.run().
|
||||||
|
let stopping = false;
|
||||||
|
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
|
if (stopping)
|
||||||
|
return;
|
||||||
|
stopping = true;
|
||||||
|
syslog('info', 'agent', 'stopping · saving the counters and the logs');
|
||||||
live.save_usage(usage, true);
|
live.save_usage(usage, true);
|
||||||
live.persist_events();
|
live.persist_events();
|
||||||
geo.flush();
|
geo.flush();
|
||||||
@@ -876,6 +886,7 @@ else if (live.uptime() < 600)
|
|||||||
slog('dawnline', 'info', sprintf(L_('started with the router · version %s'), VERSION), null, 'Dawnline');
|
slog('dawnline', 'info', sprintf(L_('started with the router · version %s'), VERSION), null, 'Dawnline');
|
||||||
else
|
else
|
||||||
slog('dawnline', 'info', sprintf(L_('started · version %s'), VERSION), null, 'Dawnline');
|
slog('dawnline', 'info', sprintf(L_('started · version %s'), VERSION), null, 'Dawnline');
|
||||||
|
syslog('debug', 'agent', sprintf('watching connections every %d ms, checking the rest every %d ms', WATCH, TICK));
|
||||||
// A module Dawnline did not install has no record of its kernel: without one
|
// A module Dawnline did not install has no record of its kernel: without one
|
||||||
// Health cannot tell a firmware upgrade from a missing module.
|
// Health cannot tell a firmware upgrade from a missing module.
|
||||||
builds.adopt();
|
builds.adopt();
|
||||||
|
|||||||
@@ -29,4 +29,4 @@ else detail="It never completed a check."; fi
|
|||||||
msg="stopped responding — restarted"
|
msg="stopped responding — restarted"
|
||||||
mkdir -p /var/run/dawnline
|
mkdir -p /var/run/dawnline
|
||||||
printf '{"ts":%s,"src":"dawnline","level":"repair","who":"Dawnline","msg":"%s","detail":"%s"}\n' "$now" "$msg" "$detail" >> /var/run/dawnline/service.log
|
printf '{"ts":%s,"src":"dawnline","level":"repair","who":"Dawnline","msg":"%s","detail":"%s"}\n' "$now" "$msg" "$detail" >> /var/run/dawnline/service.log
|
||||||
logger -t dawnline "Dawnline $msg"
|
logger -t dawnline -p daemon.warning "[warn] [agent] Dawnline $msg - $detail"
|
||||||
@@ -31,13 +31,13 @@ while [ "$i" -lt 12 ]; do
|
|||||||
up && exit 0
|
up && exit 0
|
||||||
done
|
done
|
||||||
|
|
||||||
logger -t dawnline "update to $to failed its check: luci.dawnline or the agent is not up"
|
logger -t dawnline -p daemon.err "[error] [update] update to $to failed its check: luci.dawnline or the agent is not up"
|
||||||
set --
|
set --
|
||||||
for f in "$KEEP"/*.ipk "$KEEP"/*.apk; do
|
for f in "$KEEP"/*.ipk "$KEEP"/*.apk; do
|
||||||
[ -f "$f" ] && set -- "$@" "$f"
|
[ -f "$f" ] && set -- "$@" "$f"
|
||||||
done
|
done
|
||||||
if [ "$#" -eq 0 ]; then
|
if [ "$#" -eq 0 ]; then
|
||||||
logger -t dawnline "no previous version is kept: nothing to roll back to"
|
logger -t dawnline -p daemon.err "[error] [update] no previous version is kept: nothing to roll back to"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if command -v apk >/dev/null 2>&1; then
|
if command -v apk >/dev/null 2>&1; then
|
||||||
@@ -50,5 +50,5 @@ fi
|
|||||||
mkdir -p "$RUN"
|
mkdir -p "$RUN"
|
||||||
# The restored agent reports it in the service log on its start.
|
# The restored agent reports it in the service log on its start.
|
||||||
echo "$to" > "$RUN/update-rolled-back"
|
echo "$to" > "$RUN/update-rolled-back"
|
||||||
logger -t dawnline "rolled back from $to to the kept version"
|
logger -t dawnline -p daemon.warning "[warn] [update] rolled back from $to to the kept version"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -360,7 +360,7 @@ let LOCK = null;
|
|||||||
for (let i = 0; i < 10 && !LOCK; i++) {
|
for (let i = 0; i < 10 && !LOCK; i++) {
|
||||||
LOCK = upd.try_lock();
|
LOCK = upd.try_lock();
|
||||||
if (!LOCK)
|
if (!LOCK)
|
||||||
system('usleep 100000 2>/dev/null || sleep 1');
|
sleep(100);
|
||||||
}
|
}
|
||||||
if (!LOCK)
|
if (!LOCK)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
Geist and Geist Mono are licensed under the SIL Open Font License, Version 1.1.
|
|
||||||
Copyright (c) 2023 Vercel, in collaboration with basement.studio.
|
|
||||||
https://github.com/vercel/geist-font/blob/main/OFL.txt
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><style>.t{fill:#0a0a0a}.g{fill:#fff}@media (prefers-color-scheme:dark){.t{fill:#fff}.g{fill:#0a0a0a}}</style><rect class="t" width="64" height="64" rx="16"/><path class="g" d="M14 38a18 18 0 0 1 36 0z"/><rect class="g" x="12" y="43" width="40" height="4" rx="2" opacity=".5"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 343 B |
@@ -1 +0,0 @@
|
|||||||
@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{color-scheme:dark;--bg: #080808;--raised: #121212;--field: #161616;--knob: #232323;--seg: rgba(237, 237, 237, .05);--seg-shadow: none;--line: rgba(255, 255, 255, .06);--text: #ededed;--text-2: #8c8c8a;--text-3: #4f4f4e;--accent: #4eafff;--accent-ink: #ffffff;--accent-soft: rgba(78, 175, 255, .13);--ok: #57d64b;--ok-soft: rgba(87, 214, 75, .14);--warn: #ff8a3d;--bad: #ff5c5c;--bad-soft: rgba(255, 92, 92, .13);--sel-bg: rgba(131, 209, 255, .25);--sel-fg: #64c6ff;--scrim: rgba(8, 8, 8, .8);--line-glass: rgba(255, 255, 255, .07);--pop-shadow: 0 18px 48px -14px rgba(0, 0, 0, .75);--sheet-shadow: 0 24px 64px -16px rgba(0, 0, 0, .6);--bar: rgba(237, 237, 237, .13);--toast: #232323;--toast-fg: #ededed;--qr-bg: #0a0a0a;--gi-a: rgba(255, 255, 255, .58);--gi-b: rgba(255, 255, 255, .14);--gi-rim: rgba(255, 255, 255, .5);--gi-edge: rgba(0, 0, 0, 0);--gi-detail: #ffffff;--t-grey-a: #cfcfcd;--t-grey-b: #5a5a59;--t-blue-a: #a6d9ff;--t-blue-b: #1d84e6;--t-green-a: #a8f29c;--t-green-b: #3aa32c;--t-red-a: #ffadad;--t-red-b: #dc3a3a;--t-orange-a: #ffc08f;--t-orange-b: #ec6a12;--font: Geist, -apple-system, system-ui, "Segoe UI", sans-serif;--mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;--r-sheet: 36px;--r-card: 28px;--r-row: 20px;--r-field: 16px;--r-tile: 12px;--ease-out: cubic-bezier(.23, 1, .32, 1);--gutter-l: max(16px, env(safe-area-inset-left, 0px));--gutter-r: max(16px, env(safe-area-inset-right, 0px))}@media(prefers-color-scheme:light){:root{color-scheme:light;--bg: #f2f2f1;--raised: #ffffff;--field: #f3f3f2;--knob: #e8e8e7;--seg: #ffffff;--seg-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 .5px rgba(0, 0, 0, .05);--line: rgba(0, 0, 0, .07);--text: #0b0b0b;--text-2: #6d6d6b;--text-3: #a6a6a4;--accent: #2b9dff;--accent-soft: rgba(43, 157, 255, .12);--ok: #33a328;--ok-soft: rgba(51, 163, 40, .12);--warn: #ee6a12;--bad: #e5484d;--bad-soft: rgba(229, 72, 77, .1);--sel-bg: rgba(78, 175, 255, .22);--sel-fg: #0a76cf;--scrim: rgba(236, 236, 235, .62);--line-glass: rgba(0, 0, 0, .07);--pop-shadow: 0 18px 44px -14px rgba(0, 0, 0, .2);--sheet-shadow: 0 24px 64px -18px rgba(0, 0, 0, .22);--bar: rgba(11, 11, 11, .11);--toast: #0b0b0b;--toast-fg: #f2f2f1;--qr-bg: #ffffff;--gi-a: rgba(250, 250, 249, .72);--gi-b: rgba(206, 206, 204, .5);--gi-rim: rgba(255, 255, 255, .9);--gi-edge: rgba(0, 0, 0, .11);--gi-detail: rgba(28, 28, 28, .72);--t-grey-a: #a9a9a7;--t-grey-b: #3d3d3c;--t-blue-a: #7cc4ff;--t-blue-b: #0a6fd6;--t-green-a: #82e070;--t-green-b: #2e8a22;--t-red-a: #ff9090;--t-red-b: #c92a2a}}*{box-sizing:border-box}html{-webkit-text-size-adjust:100%;scrollbar-gutter:stable;overflow-anchor:none}body{margin:0;background:var(--bg);color:var(--text);font:400 15px/22px var(--font);letter-spacing:-.011em;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh;cursor:default}body.locked{overflow:hidden}input,textarea,.linkrow .mono,.conf{cursor:text}::selection{background:var(--sel-bg);color:var(--sel-fg)}button{font:inherit;color:inherit;letter-spacing:inherit;background:none;border:0;padding:0;margin:0;cursor:pointer;-webkit-tap-highlight-color:transparent}button:disabled{cursor:default}a{color:inherit;text-decoration:none}:focus{outline:none}:focus-visible{outline:2px solid color-mix(in srgb,var(--accent) 65%,transparent);outline-offset:2px}[hidden]{display:none!important}.offscreen{position:fixed;left:-9999px;top:0;opacity:0}.mono{font-family:var(--mono);letter-spacing:0}.num{font-variant-numeric:tabular-nums}.ok-t{color:var(--ok)}.warn-t{color:var(--warn)}.bad-t{color:var(--bad)}.here-t{color:var(--accent)}.i{width:18px;height:18px;flex:none}.gi{width:24px;height:24px;flex:none;overflow:visible;--ta: var(--t-grey-a);--tb: var(--t-grey-b)}.gi.t-blue{--ta: var(--t-blue-a);--tb: var(--t-blue-b)}.gi.t-green{--ta: var(--t-green-a);--tb: var(--t-green-b)}.gi.t-red{--ta: var(--t-red-a);--tb: var(--t-red-b)}.gi.t-orange{--ta: var(--t-orange-a);--tb: var(--t-orange-b)}.gi .ta{stop-color:var(--ta)}.gi .tb{stop-color:var(--tb)}.gi .fa{stop-color:var(--gi-a)}.gi .fb{stop-color:var(--gi-b)}.gi .fc{stop-color:var(--ta);stop-opacity:.28}.gi .ge{stroke:var(--gi-edge)}.gi .gr{stroke:var(--gi-rim)}.gi .gd{stroke:var(--gi-detail)}.gi .gdf{color:var(--gi-detail)}.knob{width:32px;height:32px;border-radius:50%;background:var(--knob);color:var(--text);display:grid;place-items:center;flex:none;transition:transform .15s var(--ease-out),background-color .15s}.knob:hoveLine truncated
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
"use strict";(()=>{var Si=Object.create;var Oo=Object.defineProperty;var Ai=Object.getOwnPropertyDescriptor;var Hi=Object.getOwnPropertyNames;var Di=Object.getPrototypeOf,$i=Object.prototype.hasOwnProperty;var Pi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Oi=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Hi(t))!$i.call(e,r)&&r!==n&&Oo(e,r,{get:()=>t[r],enumerable:!(o=Ai(t,r))||o.enumerable});return e};var Ri=(e,t,n)=>(n=e!=null?Si(Di(e)):{},Oi(t||!e||!e.__esModule?Oo(n,"default",{value:e,enumerable:!0}):n,e));var Lr=Pi((kr,Cr)=>{"use strict";var Er=(function(){var e=function(y,w){var p=236,u=17,l=y,v=n[w],h=null,d=0,L=null,M=[],H={},q=function(k,T){d=l*4+17,h=(function(E){for(var D=new Array(E),$=0;$<E;$+=1){D[$]=new Array(E);for(var I=0;I<E;I+=1)D[$][I]=null}return D})(d),R(0,0),R(d-7,0),R(0,d-7),U(),N(),oe(k,T),l>=7&&Z(k),L==null&&(L=nn(l,v,M)),de(L,T)},R=function(k,T){for(var E=-1;E<=7;E+=1)if(!(k+E<=-1||d<=k+E))for(var D=-1;D<=7;D+=1)T+D<=-1||d<=T+D||(0<=E&&E<=6&&(D==0||D==6)||0<=D&&D<=6&&(E==0||E==6)||2<=E&&E<=4&&2<=D&&D<=4?h[k+E][T+D]=!0:h[k+E][T+D]=!1)},W=function(){for(var k=0,T=0,E=0;E<8;E+=1){q(!0,E);var D=r.getLostPoint(H);(E==0||k>D)&&(k=D,T=E)}return T},N=function(){for(var k=8;k<d-8;k+=1)h[k][6]==null&&(h[k][6]=k%2==0);for(var T=8;T<d-8;T+=1)h[6][T]==null&&(h[6][T]=T%2==0)},U=function(){for(var k=r.getPatternPosition(l),T=0;T<k.length;T+=1)for(var E=0;E<k.length;E+=1){var D=k[T],$=k[E];if(h[D][$]==null)for(var I=-2;I<=2;I+=1)for(var B=-2;B<=2;B+=1)I==-2||I==2||B==-2||B==2||I==0&&B==0?h[D+I][$+B]=!0:h[D+I][$+B]=!1}},Z=function(k){for(var T=r.getBCHTypeNumber(l),E=0;E<18;E+=1){var D=!k&&(T>>E&1)==1;h[Math.floor(E/3)][E%3+d-8-3]=D}for(var E=0;E<18;E+=1){var D=!k&&(T>>E&1)==1;h[E%3+d-8-3][Math.floor(E/3)]=D}},oe=function(k,T){for(var E=v<<3|T,D=r.getBCHTypeInfo(E),$=0;$<15;$+=1){var I=!k&&(D>>$&1)==1;$<6?h[$][8]=I:$<8?h[$+1][8]=I:h[d-15+$][8]=I}for(var $=0;$<15;$+=1){var I=!k&&(D>>$&1)==1;$<8?h[8][d-$-1]=I:$<9?h[8][15-$-1+1]=I:h[8][15-$-1]=I}h[d-8][8]=!k},de=function(k,T){for(var E=-1,D=d-1,$=7,I=0,B=r.getMaskFunction(T),G=d-1;G>0;G-=2)for(G==6&&(G-=1);;){for(var X=0;X<2;X+=1)if(h[D][G-X]==null){var ne=!1;I<k.length&&(ne=(k[I]>>>$&1)==1);var Y=B(D,G-X);Y&&(ne=!ne),h[D][G-X]=ne,$-=1,$==-1&&(I+=1,$=7)}if(D+=E,D<0||d<=D){D-=E,E=-E;break}}},ke=function(k,T){for(var E=0,D=0,$=0,I=new Array(T.length),B=new Array(T.length),G=0;G<T.length;G+=1){var X=T[G].dataCount,ne=T[G].totalCount-X;D=Math.max(D,X),$=Math.max($,ne),I[G]=new Array(X);for(var Y=0;Y<I[G].length;Y+=1)I[G][Y]=255&k.getBuffer()[Y+E];E+=X;var fe=r.getErrorCorrectPolynomial(ne),ce=i(I[G],fe.getLength()-1),Do=ce.mod(fe);B[G]=new Array(fe.getLength()-1);for(var Y=0;Y<B[G].length;Y+=1){var $o=Y+Do.getLength()-B[G].length;B[G][Y]=$o>=0?Do.getAt($o):0}}for(var Po=0,Y=0;Y<T.length;Y+=1)Po+=T[Y].totalCount;for(var Qn=new Array(Po),on=0,Y=0;Y<D;Y+=1)for(var G=0;G<T.length;G+=1)Y<I[G].length&&(Qn[on]=I[G][Y],on+=1);for(var Y=0;Y<$;Y+=1)for(var G=0;G<T.length;G+=1)Y<B[G].length&&(Qn[on]=B[G][Y],on+=1);return Qn},nn=function(k,T,E){for(var D=c.getRSBlocks(k,T),$=m(),I=0;I<E.length;I+=1){var B=E[I];$.put(B.getMode(),4),$.put(B.getLength(),r.getLengthInBits(B.getMode(),k)),B.write($)}for(var G=0,I=0;I<D.length;I+=1)G+=D[I].dataCount;if($.getLengthInBits()>G*8)throw"code length overflow. ("+$.getLengthInBits()+">"+G*8+")";for($.getLengthInBits()+4<=G*8&&$.put(0,4);$.getLengthInBits()%8!=0;)$.putBit(!1);for(;!($.getLengthInBits()>=G*8||($.put(p,8),$.getLengthInBits()>=G*8));)$.put(u,8);return ke($,D)};H.addData=function(k,T){T=T||"Byte";var E=null;switch(T){case"Numeric":E=f(k);break;case"Alphanumeric":E=C(k);break;case"Byte":E=g(k);break;case"Kanji":E=b(k);break;default:throw"mode:"+T}M.push(E),L=null},H.isDark=function(k,T){if(k<0||d<=k||T<0||d<=T)throw k+","+T;return h[k][T]},H.getModuleCount=function(){return d},H.make=function(){if(l<1){for(var k=1;k<40;k++){for(var T=c.getRSBlocks(k,v),E=m(),D=0;D<M.length;D++){var $=M[D];E.put($.getMode(),4),E.put($.getLength(),r.getLengthInBits($.getMode(),k)),$.write(E)}for(var I=0,D=0;D<T.length;D++)I+=T[D].dataCount;if(E.getLengthInBits()<=I*8)break}l=k}q(!1,W())},H.createTableTag=function(k,T){k=k||2,T=typeof T=="undefined"?k*4:T;var E="";E+='<table style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: "+T+"px;",E+='">',E+="<tbody>";for(var D=0;D<H.getModuleCount();D+=1){E+="<tr>";for(var $=0;$<H.getModuleCount();$+=1)E+='<td style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: 0px;",E+=" width: "+k+"px;",E+=" height: "+k+"px;",E+=" background-color: ",E+=H.isDark(D,$)?"#000000":"#ffffff",E+=";",E+='"/>';E+="</tr>"}return E+="</tbody>",E+="</table>",E},H.createSvgTag=function(k,T,E,D){var $={};typeof arguments[0]=="object"&&($=arguments[0],k=$.cellSize,T=$.margin,E=$.alt,D=$.title),k=k||2,T=typeof T=="undefined"?k*4:T,E=typeof E=="string"?{text:E}:E||{Line truncated
|
|
||||||
`}return E%2&&k>0?ce.substring(0,ce.length-E-1)+Array(E+1).join("▀"):ce.substring(0,ce.length-1)};return H.createASCII=function(k,T){if(k=k||1,k<2)return et(T);k-=1,T=typeof T=="undefined"?k*2:T;var E=H.getModuleCount()*k+T*2,D=T,$=E-T,I,B,G,X,ne=Array(k+1).join("██"),Y=Array(k+1).join(" "),fe="",ce="";for(I=0;I<E;I+=1){for(G=Math.floor((I-D)/k),ce="",B=0;B<E;B+=1)X=1,D<=B&&B<$&&D<=I&&I<$&&H.isDark(G,Math.floor((B-D)/k))&&(X=0),ce+=X?ne:Y;for(G=0;G<k;G+=1)fe+=ce+`
|
|
||||||
`}return fe.substring(0,fe.length-1)},H.renderTo2dContext=function(k,T){T=T||2;for(var E=H.getModuleCount(),D=0;D<E;D++)for(var $=0;$<E;$++)k.fillStyle=H.isDark(D,$)?"black":"white",k.fillRect(D*T,$*T,T,T)},H};e.stringToBytesFuncs={default:function(y){for(var w=[],p=0;p<y.length;p+=1){var u=y.charCodeAt(p);w.push(u&255)}return w}},e.stringToBytes=e.stringToBytesFuncs.default,e.createStringToBytes=function(y,w){var p=(function(){for(var l=P(y),v=function(){var N=l.read();if(N==-1)throw"eof";return N},h=0,d={};;){var L=l.read();if(L==-1)break;var M=v(),H=v(),q=v(),R=String.fromCharCode(L<<8|M),W=H<<8|q;d[R]=W,h+=1}if(h!=w)throw h+" != "+w;return d})(),u=63;return function(l){for(var v=[],h=0;h<l.length;h+=1){var d=l.charCodeAt(h);if(d<128)v.push(d);else{var L=p[l.charAt(h)];typeof L=="number"?(L&255)==L?v.push(L):(v.push(L>>>8),v.push(L&255)):v.push(u)}}return v}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var y=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],w=1335,p=7973,u=21522,l={},v=function(h){for(var d=0;h!=0;)d+=1,h>>>=1;return d};return l.getBCHTypeInfo=function(h){for(var d=h<<10;v(d)-v(w)>=0;)d^=w<<v(d)-v(w);return(h<<10|d)^u},l.getBCHTypeNumber=function(h){for(var d=h<<12;v(d)-v(p)>=0;)d^=p<<v(d)-v(p);return h<<12|d},l.getPatternPosition=function(h){return y[h-1]},l.getMaskFunction=function(h){switch(h){case o.PATTERN000:return function(d,L){return(d+L)%2==0};case o.PATTERN001:return function(d,L){return d%2==0};case o.PATTERN010:return function(d,L){return L%3==0};case o.PATTERN011:return function(d,L){return(d+L)%3==0};case o.PATTERN100:return function(d,L){return(Math.floor(d/2)+Math.floor(L/3))%2==0};case o.PATTERN101:return function(d,L){return d*L%2+d*L%3==0};case o.PATTERN110:return function(d,L){return(d*L%2+d*L%3)%2==0};case o.PATTERN111:return function(d,L){return(d*L%3+(d+L)%2)%2==0};default:throw"bad maskPattern:"+h}},l.getErrorCorrectPolynomial=function(h){for(var d=i([1],0),L=0;L<h;L+=1)d=d.multiply(i([1,s.gexp(L)],0));return d},l.getLengthInBits=function(h,d){if(1<=d&&d<10)switch(h){case t.MODE_NUMBER:return 10;case t.MODE_ALPHA_NUM:return 9;case t.MODE_8BIT_BYTE:return 8;case t.MODE_KANJI:return 8;default:throw"mode:"+h}else if(d<27)switch(h){case t.MODE_NUMBER:return 12;case t.MODE_ALPHA_NUM:return 11;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 10;default:throw"mode:"+h}else if(d<41)switch(h){case t.MODE_NUMBER:return 14;case t.MODE_ALPHA_NUM:return 13;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 12;default:throw"mode:"+h}else throw"type:"+d},l.getLostPoint=function(h){for(var d=h.getModuleCount(),L=0,M=0;M<d;M+=1)for(var H=0;H<d;H+=1){for(var q=0,R=h.isDark(M,H),W=-1;W<=1;W+=1)if(!(M+W<0||d<=M+W))for(var N=-1;N<=1;N+=1)H+N<0||d<=H+N||W==0&&N==0||R==h.isDark(M+W,H+N)&&(q+=1);q>5&&(L+=3+q-5)}for(var M=0;M<d-1;M+=1)for(var H=0;H<d-1;H+=1){var U=0;h.isDark(M,H)&&(U+=1),h.isDark(M+1,H)&&(U+=1),h.isDark(M,H+1)&&(U+=1),h.isDark(M+1,H+1)&&(U+=1),(U==0||U==4)&&(L+=3)}for(var M=0;M<d;M+=1)for(var H=0;H<d-6;H+=1)h.isDark(M,H)&&!h.isDark(M,H+1)&&h.isDark(M,H+2)&&h.isDark(M,H+3)&&h.isDark(M,H+4)&&!h.isDark(M,H+5)&&h.isDark(M,H+6)&&(L+=40);for(var H=0;H<d;H+=1)for(var M=0;M<d-6;M+=1)h.isDark(M,H)&&!h.isDark(M+1,H)&&h.isDark(M+2,H)&&h.isDark(M+3,H)&&h.isDark(M+4,H)&&!h.isDark(M+5,H)&&h.isDark(M+6,H)&&(L+=40);for(var Z=0,H=0;H<d;H+=1)for(var M=0;M<d;M+=1)h.isDark(M,H)&&(Z+=1);var oe=Math.abs(100*Z/d/d-50)/5;return L+=oe*10,L},l})(),s=(function(){for(var y=new Array(256),w=new Array(256),p=0;p<8;p+=1)y[p]=1<<p;for(var p=8;p<256;p+=1)y[p]=y[p-4]^y[p-5]^y[p-6]^y[p-8];for(var p=0;p<255;p+=1)w[y[p]]=p;var u={};return u.glog=function(l){if(l<1)throw"glog("+l+")";return w[l]},u.gexp=function(l){for(;l<0;)l+=255;for(;l>=256;)l-=255;return y[l]},u})();function i(y,w){if(typeof y.length=="undefined")throw y.length+"/"+w;var p=(function(){for(var l=0;l<y.length&&y[l]==0;)l+=1;for(var v=new Array(y.length-l+w),h=0;h<y.length-l;h+=1)v[h]=y[h+l];return v})(),u={};return u.getAt=function(l){return p[l]},u.getLength=function(){return p.length},u.multiply=function(l){for(var v=new Array(u.getLength()+l.getLength()-1),h=0;h<u.getLength();h+=1)for(var d=0;d<l.getLength();d+=1)v[h+d]^=s.gexp(s.glog(u.getAt(h))+s.glog(l.getAt(d)));return i(v,0)},u.mod=function(l){if(u.ge
Line truncated
|
|
||||||
`),hostName:s,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},c={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(i),port:String(n.port),protocol_version:o.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:s};return n.dns[0]&&(c.dns1=n.dns[0],c.dns2=n.dns[1]||n.dns[0]),c}function Fa(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Ga(e){let t=globalThis;if(typeof t.CompressionStream=="undefined")return null;try{let n=new t.Blob([e]).stream().pipeThrough(new t.CompressionStream("deflate")),o=new Uint8Array(await new t.Response(n).arrayBuffer()),r=new Uint8Array(4+o.length);return new DataView(r.buffer).setUint32(0,e.length,!1),r.set(o,4),r}catch{return null}}async function wo(e,t,n=!0){let o=new TextEncoder().encode(JSON.stringify(Wa(e,t))),r=n?await Ga(o):null;return`vpn://${Fa(r!=null?r:o)}`}var ks=e=>e.replace(/^vpn:\/\//,"");var Cs=["height","marginTop","marginBottom","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],qa={opacity:0,filter:"blur(2px)"};function Ls(e,t,n){let o=e.getAnimations();O(e,t,n),o.forEach(r=>r.cancel())}var Ka=new Set(["offset","computedOffset","easing","composite"]),Va=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);function Dt(...e){let t=[],n=[],o=new Set;for(let s of e)for(let i=s;i&&!o.has(i);i=i.parentElement)if(o.add(i),!(!(i instanceof HTMLElement)||i.classList.contains("closing")))for(let c of i.getAnimations()){let m=c.playState==="running"&&c.effect instanceof KeyframeEffect?c.effect.getKeyframes():[],f=m[m.length-1];if(f&&("width"in f||"maxWidth"in f)&&n.push({a:c,t:c.currentTime}),!(f!=null&&f.height)||f.height==="0px")continue;let C=getComputedStyle(i),g={},b={};for(let x of Object.keys(f))Ka.has(x)||(g[x]=C.getPropertyValue(Va(x)),b[x]=f[x]);t.push({el:i,a:c,t:c.currentTime,cur:g,to:b})}if(!t.length)return;[...t,...n].forEach(s=>s.a.cancel());let r=t.map(s=>getComputedStyle(s.el).height);for(let s of n)s.a.play(),s.a.currentTime=s.t;t.forEach((s,i)=>{s.a.play(),Math.abs(parseFloat(r[i])-parseFloat(String(s.to.height)))<.5?s.a.currentTime=s.t:s.a.effect.setKeyframes([s.cur,{...s.to,height:r[i]}])})}function ze(e,t={}){let n=a("div",{class:`acc${t.inset?" inset":""}`}),o=e.map((g,b)=>{var w;let x=g.body.filter(p=>!!p),S=!x.length,P=[g.icon,a("span",{class:"acc-title"},a("span",{class:"t"},g.title),(w=g.tag)!=null?w:null),g.val?a("span",{class:`acc-val${g.valHide?" hide-open":""}`},g.val):null],F=b===t.open&&!S,A=S?a("div",{class:"acc-head"},...P):a("button",{type:"button",class:"acc-head","aria-expanded":String(F),onclick:()=>C(y)},...P,z("chevron","i acc-chev")),y=a("div",{class:`acc-row${S?" still":""}${F?" open":""}`},A,a("div",{class:"acc-body"},...x));return n.appendChild(y),y}),r=g=>g.querySelector(".acc-body"),s=()=>o.forEach((g,b)=>{let x=g.classList.contains("open");g.classList.toggle("rt",b===0||x||o[b-1].classList.contains("open")),g.classList.toggle("rb",b===o.length-1||x||o[b+1].classList.contains("open"))}),i=g=>{let b=getComputedStyle(g),x={};for(let S of Cs)x[S]=S==="height"?`${g.getBoundingClientRect().height}px`:b[S];return x},c=()=>o.forEach(g=>{var b;return(b=g.querySelector("button.acc-head"))==null?void 0:b.setAttribute("aria-expanded",String(g.classList.contains("open")))}),m=g=>g.classList.contains("open")||g.classList.contains("closing"),f=g=>{if(!m(g))return qa;let b=getComputedStyle(r(g));return{opacity:b.opacity,filter:b.filter==="none"?"blur(0px)":b.filter}};function C(g){var w,p;let b=o.map(i),x=o.map(f),S=(w=t.hold)==null?void 0:w.call(t);o.forEach(u=>u.getAnimations().forEach(l=>l.cancel()));let P=!g.classList.contains("open"),F=o.filter(u=>m(u)&&!(u===g&&P));o.forEach(u=>{u.classList.remove("closing"),u!==g&&u.classList.remove("open")}),g.classList.toggle("open",P),P&&g.classList.add("opened"),s();let A=Lt(),y=o.map(i);if(S==null||S(),Dt(n.parentElement),o.forEach((u,l)=>{let v=()=>{u.classList.remove("closing"),u.classList.contains("open")||u.classList.remove("opened")};if(!Cs.some(h=>b[l][h]!==y[l][h]))return v();F.includes(u)&&u.classList.add("closing"),O(u,[b[l],y[l]],{duration:Le.duration,easing:Le.easing}).onfinish=v}),F.forEach(u=>{let l=x[o.indexOf(u)];Ls(r(u),[l,{opacity:0,filter:"blur(2px)"}],{duration:160*Number(l.opacity),easing:J,fill:"forwards"})}),P){let u=x[o.indexOf(g)];Ls(r(g),[u,{opacity:1,filter:"blur(0px)"}],{duration:300*(1-Number(u.opacity)),easing:"cubic-bezier(0,0,.58,1)"})}Tt(A),c(),(p=t.onToggle)==null||p.call(t,o.indexOf(g),P,!1)}return s(),{el:n,openIndex:()=>o.findIndex(g=>g.classList.contains("open")),setOpen(g){o.forEach((b,x)=>{[b,r(b)].forEach(P=>P.getAnimations().forEach(F=>F.cancel()));let S=x===g&&!b.classList.contains("still");b.classList.toggle(
Line truncated
|
|
||||||
`).flatMap((g,b)=>b?[`
|
|
||||||
`,Hs(g)]:[Hs(g)])),o=!!st(e.filename,e.conf),r=z("key"),s=z("x"),i=a("span",{},_("Show key")),c=a("button",{type:"button",class:"btn soft sm",onclick:()=>{t=!t,te(i,t?_("Hide key"):_("Show key")),n.querySelectorAll(".secret").forEach(g=>Wn(g,t,Ss)),n.querySelectorAll(".mask").forEach(g=>Wn(g,!t,Ss)),Wn(r,!t,As),Wn(s,t,As)}},Is(r,s),i),m=a("button",{type:"button",class:"btn soft sm",onclick:g=>be(e.conf,_("Configuration copied"),g.currentTarget)},z("copy"),a("span",{class:"lbl"},_("Copy"))),f=a("div",{class:"filecard"},a("div",{class:"fc-row"},a("span",{class:"filecard-ic"},".conf"),a("span",{class:"t"},a("span",{class:"mono"},e.filename),a("span",{},_("For computers and routers")))),a("button",{type:"button",class:"btn accent sm block",onclick:()=>Gt(e.filename,e.conf)},z(o?"open":"download"),a("span",{},o?_("Share file"):_("Download")))),C=ze([{icon:ee("file"),title:_("Configuration"),body:[a("div",{class:"confbar"},c,m),n]}],{inset:!0});return a("div",{class:"step-box"},f,C.el)}function Fs(e){let t=a("span",{class:"osm-p"},he[e]),n=Ur(Rt(e,"ios"),Rt(e,"android"));return{el:a("span",{class:"scanline"},a("span",{},...ut(_("In %s:"),t)),n.el),set(o){te(t,he[o],void 0,{whole:!0}),n.set(Rt(o,"ios"),Rt(o,"android"))}}}function Gs(e){let t=a("span",{class:"tt"}),n=a("span",{class:"tt-m"}),o=a("span",{class:"hp-tip","aria-hidden":"true"},t,n),r=a("button",{type:"button",class:"hp-b",onclick:()=>Gt(e().file,e().text)},z("download")),s=a("button",{type:"button",class:"hp-b"},z("copy")),i=a("div",{class:"hpill",role:"group","aria-label":_("The connection"),"data-key":"conn"},r,s,o),c=null,m=0,f=0,C=l=>{var v;return l===s&&s.classList.contains("done")?_("Copied"):(v=l.getAttribute("aria-label"))!=null?v:""},g=(l,v)=>{n.textContent=v;let h=n.offsetWidth+20;return Math.min(l.offsetLeft+l.offsetWidth/2,i.offsetWidth+46-h/2)},b=l=>`translateX(${l}px) translateX(-50%)`,x=()=>{let l=getComputedStyle(o);return{opacity:l.opacity,filter:l.filter==="none"?"blur(0px)":l.filter,transform:l.transform}},S=(l,v)=>{let h=o.getAnimations();O(o,l,v),h.forEach(d=>d.cancel())},P=l=>{let v=x();o.style.transform=b(l),S([v,{opacity:1,filter:"blur(0px)",transform:b(l)}],{duration:K.duration,easing:K.easing})},F=l=>te(t,l),A=l=>{if(clearTimeout(m),c===l&&o.classList.contains("on"))return;if(c=l,o.classList.contains("on")||+getComputedStyle(o).opacity>0){let h=C(l);return o.classList.add("on"),P(g(l,h)),F(h)}let v=()=>{let h=C(l);ae(t,h);let d=g(l,h);o.style.transform=b(d),o.classList.add("on"),S([{opacity:0,transform:`${b(d)} translateY(-3px) scale(.96)`,filter:"blur(3px)"},{opacity:1,transform:b(d),filter:"blur(0px)"}],{duration:220,easing:Q})};performance.now()<f?v():m=window.setTimeout(v,420)},y=()=>{if(clearTimeout(m),c=null,!o.classList.contains("on"))return;f=performance.now()+500;let l=x();o.classList.remove("on"),S([l,{...l,opacity:0}],{duration:120,easing:"ease-out"})};for(let l of[r,s])l.addEventListener("pointerenter",v=>{v.pointerType==="mouse"&&A(l)}),l.addEventListener("focus",()=>{l.matches(":focus-visible")&&A(l)}),l.addEventListener("blur",v=>{i.contains(v.relatedTarget)||y()});i.addEventListener("pointerleave",y);let w=l=>{let v=z(l);s.querySelector("svg").replaceWith(v),O(v,[{opacity:0,transform:"scale(.6)",filter:"blur(3px)"},{opacity:1,transform:"none",filter:"none"}],{duration:Te.duration,easing:Te.easing})},p=()=>{if(c!==s||!o.classList.contains("on"))return;let l=C(s);P(g(s,l)),F(l)},u=0;return s.addEventListener("click",()=>{let l=e();be(l.text,l.msg),clearTimeout(u),s.classList.contains("done")||(s.classList.add("done"),w("check"),p()),u=window.setTimeout(()=>{s.classList.remove("done"),w("copy"),p()},1600)}),{el:i,sync(){let l=e().app;r.setAttribute("aria-label",V(_("Download %s config"),l)),s.setAttribute("aria-label",V(_("Copy %s config"),l))}}}function qs(e,t){var n,o,r;return e?((n=e.setup)==null?void 0:n.state)==="trying"?"trying":e.handshake<=t?"waiting":((o=e.setup)==null?void 0:o.state)==="flowing"?"connected":((r=e.setup)==null?void 0:r.state)==="nodata"?"nodata":"waiting":"waiting"}function ja(e,t){switch(e){case"trying":return[_("Unable to complete the handshake"),_("Your network may be blocking the connection.")];case"connected":return[V(_("%s connected"),t.name),""];case"nodata":return[_("Handshake complete, but no data"),_("This device is using an outdated configuration.")];case"waiting":return[_("Waiting for the connection"),""]}}var Ks={waiting:"",trying:"trying",connected:"done",nodata:"nodata"};function Us(e){let t=a("b",{},_("Waiting for the connection")),n=a("span",{class:"ws",hidden:!0}),o=a("span",{class:"t"},t,n),r=a("div",{class:"way-text"},o),s=a("span",{class:"way-track"},a("span",{class:"way-glow"},a("span",{class:"run"},a("i")),a("span",{class:"knock"},a("i"))),a("span",{class:"way-fill"}),a("span",{class:"way-break"},a("i"))),i=a("div",{class:"way",role:"status","aria-live":"polite"},a("div",{class:"way-row"},a("span",{class:"way-end"},z(e.kind)),s,a("span",{class:"way-end home"},z("se
Line truncated
|
|
||||||
@@ -9,7 +9,7 @@ import { serve } from 'dawnline.portal';
|
|||||||
|
|
||||||
let env = {};
|
let env = {};
|
||||||
for (let k in [ 'REQUEST_METHOD', 'REQUEST_URI', 'REMOTE_ADDR', 'HTTPS', 'CONTENT_LENGTH', 'CONTENT_TYPE',
|
for (let k in [ 'REQUEST_METHOD', 'REQUEST_URI', 'REMOTE_ADDR', 'HTTPS', 'CONTENT_LENGTH', 'CONTENT_TYPE',
|
||||||
'HTTP_HOST', 'HTTP_ORIGIN', 'HTTP_USER_AGENT', 'HTTP_ACCEPT', 'HTTP_ACCEPT_LANGUAGE',
|
'HTTP_HOST', 'HTTP_ORIGIN', 'HTTP_USER_AGENT', 'HTTP_ACCEPT', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_ACCEPT_ENCODING',
|
||||||
// The visitor behind Cloudflare (believed only when REMOTE_ADDR is Cloudflare's).
|
// The visitor behind Cloudflare (believed only when REMOTE_ADDR is Cloudflare's).
|
||||||
'HTTP_CF_CONNECTING_IP' ])
|
'HTTP_CF_CONNECTING_IP' ])
|
||||||
env[k] = getenv(k);
|
env[k] = getenv(k);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"admin/network/dawnline": {
|
"admin/services/dawnline": {
|
||||||
"title": "Dawnline",
|
"title": "Dawnline",
|
||||||
"order": 65,
|
"order": 65,
|
||||||
"action": {
|
"action": {
|
||||||
"type": "alias",
|
"type": "alias",
|
||||||
"path": "admin/network/dawnline/server"
|
"path": "admin/services/dawnline/server"
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
"acl": [
|
"acl": [
|
||||||
@@ -15,31 +15,31 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/overview": {
|
"admin/services/dawnline/overview": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/server"
|
"path": "dawnline/server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/people": {
|
"admin/services/dawnline/people": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/people"
|
"path": "dawnline/people"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/activity": {
|
"admin/services/dawnline/activity": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/activity"
|
"path": "dawnline/activity"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/person": {
|
"admin/services/dawnline/person": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/person"
|
"path": "dawnline/person"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/server": {
|
"admin/services/dawnline/server": {
|
||||||
"title": "Servers",
|
"title": "Servers",
|
||||||
"order": 10,
|
"order": 10,
|
||||||
"action": {
|
"action": {
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"path": "dawnline/server"
|
"path": "dawnline/server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/diagnostics": {
|
"admin/services/dawnline/diagnostics": {
|
||||||
"title": "Diagnostics",
|
"title": "Diagnostics",
|
||||||
"order": 40,
|
"order": 40,
|
||||||
"action": {
|
"action": {
|
||||||
@@ -55,13 +55,13 @@
|
|||||||
"path": "dawnline/diagnostics"
|
"path": "dawnline/diagnostics"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/health": {
|
"admin/services/dawnline/health": {
|
||||||
"action": {
|
"action": {
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"path": "dawnline/health"
|
"path": "dawnline/health"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/settings": {
|
"admin/services/dawnline/settings": {
|
||||||
"title": "Settings",
|
"title": "Settings",
|
||||||
"order": 60,
|
"order": 60,
|
||||||
"action": {
|
"action": {
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
"path": "dawnline/settings"
|
"path": "dawnline/settings"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/network/dawnline/updates": {
|
"admin/services/dawnline/updates": {
|
||||||
"title": "Components",
|
"title": "Components",
|
||||||
"order": 70,
|
"order": 70,
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
// (dawnline.store) is never taken while 'apply' is held.
|
// (dawnline.store) is never taken while 'apply' is held.
|
||||||
|
|
||||||
import { readfile, writefile, stat, unlink } from 'fs';
|
import { readfile, writefile, stat, unlink } from 'fs';
|
||||||
import { ensure_dir, write_file, write_json, with_lock, ip2int, slog, RUN_DIR } from 'dawnline.util';
|
import { ensure_dir, write_file, write_json, with_lock, ip2int, slog, syslog, log_on, RUN_DIR } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as net from 'dawnline.net';
|
import * as net from 'dawnline.net';
|
||||||
import * as loop from 'dawnline.loop';
|
import * as loop from 'dawnline.loop';
|
||||||
@@ -54,8 +54,10 @@ export function sync_hosts(m) {
|
|||||||
let body = length(lines) ? join('\n', lines) + '\n' : '';
|
let body = length(lines) ? join('\n', lines) + '\n' : '';
|
||||||
// dnsmasq runs as its own user; rpcd's umask would leave the file 0600.
|
// dnsmasq runs as its own user; rpcd's umask would leave the file 0600.
|
||||||
let readable = ((stat(HOSTS_FILE)?.perm?.other_read) ?? false);
|
let readable = ((stat(HOSTS_FILE)?.perm?.other_read) ?? false);
|
||||||
if ((readfile(HOSTS_FILE) ?? '') == body && (body == '' || readable))
|
if ((readfile(HOSTS_FILE) ?? '') == body && (body == '' || readable)) {
|
||||||
|
syslog('debug', 'dns', `${HOSTS_FILE}: unchanged · ${length(lines)} names`);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
ensure_dir('/tmp/hosts');
|
ensure_dir('/tmp/hosts');
|
||||||
if (body == '')
|
if (body == '')
|
||||||
unlink(HOSTS_FILE);
|
unlink(HOSTS_FILE);
|
||||||
@@ -63,6 +65,7 @@ export function sync_hosts(m) {
|
|||||||
writefile(HOSTS_FILE, body);
|
writefile(HOSTS_FILE, body);
|
||||||
system(`chmod 644 ${HOSTS_FILE}`);
|
system(`chmod 644 ${HOSTS_FILE}`);
|
||||||
}
|
}
|
||||||
|
syslog('info', 'dns', body == '' ? `${HOSTS_FILE}: removed (no device names)` : `${HOSTS_FILE}: ${length(lines)} names written (*.${m.settings.domain}) · killall -HUP dnsmasq`);
|
||||||
system('killall -HUP dnsmasq 2>/dev/null');
|
system('killall -HUP dnsmasq 2>/dev/null');
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -154,6 +157,21 @@ function sync_warning(m, table, peers) {
|
|||||||
return length(out) ? join(' ', [ ...out, _('Open Diagnostics → Health.') ]) : null;
|
return length(out) ? join(' ', [ ...out, _('Open Diagnostics → Health.') ]) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The same as sync_warning for syslog: in English whatever the admin's
|
||||||
|
* language (a log is read by anyone, searched and sent on), with what nft or
|
||||||
|
* awg said. Null when all went in.
|
||||||
|
*/
|
||||||
|
function sync_facts(m, table, peers) {
|
||||||
|
let out = [];
|
||||||
|
if (table != null)
|
||||||
|
push(out, `access rules ${nft.present() ? 'not updated, the previous ones stay' : 'not loaded, no device loaded'}: ${table}`);
|
||||||
|
for (let id, r in peers)
|
||||||
|
if (r != 'ok' && r != 'down')
|
||||||
|
push(out, `${m.servers[id]?.name ?? id}: devices not loaded: ${r}`);
|
||||||
|
return length(out) ? join(' · ', out) : null;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* With the lock held: access sets first, then devices into the tunnels.
|
* With the lock held: access sets first, then devices into the tunnels.
|
||||||
* Fail closed: without the table the firewall would let every loaded device
|
* Fail closed: without the table the firewall would let every loaded device
|
||||||
@@ -226,24 +244,60 @@ export function sync_loop(m, usage, force) {
|
|||||||
|
|
||||||
/* ---------- entry points ---------- */
|
/* ---------- entry points ---------- */
|
||||||
|
|
||||||
/** Full reconcile: router configuration + runtime state. */
|
/** Milliseconds on the monotonic clock, for how long an apply's steps take. */
|
||||||
|
function ms() {
|
||||||
|
let c = clock(true);
|
||||||
|
return c[0] * 1000 + c[1] / 1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full reconcile: router configuration + runtime state. In syslog: what it
|
||||||
|
* came to, with how long it took (info; warn when it did not fully take), and
|
||||||
|
* each step with its result at the debug level.
|
||||||
|
*/
|
||||||
export function apply(opts) {
|
export function apply(opts) {
|
||||||
opts ??= {};
|
opts ??= {};
|
||||||
|
let t0 = ms();
|
||||||
|
let debug = log_on('debug');
|
||||||
|
// One step, timed; `show` picks what of its result goes in the line (never the model: it holds keys).
|
||||||
|
let step = (name, fn, show) => {
|
||||||
|
let t = ms();
|
||||||
|
let out = fn();
|
||||||
|
let what = show ? show(out) : out;
|
||||||
|
if (debug)
|
||||||
|
syslog('debug', 'apply', sprintf('%s done in %d ms%s', name, ms() - t,
|
||||||
|
what == null ? '' : ` · ${type(what) == 'string' ? what : sprintf('%J', what)}`));
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
if (debug)
|
||||||
|
syslog('debug', 'apply', 'applying the configuration');
|
||||||
migrate.run();
|
migrate.run();
|
||||||
let r = with_lock('apply', () => {
|
let r = with_lock('apply', () => {
|
||||||
let m = core.load();
|
let m = core.load();
|
||||||
let usage = core.load_usage();
|
let usage = core.load_usage();
|
||||||
let network = netifd.sync(m);
|
let changed = (x) => x ? 'changed' : 'unchanged';
|
||||||
let firewall = fw.sync(m);
|
let network = step('network (netifd)', () => netifd.sync(m), changed);
|
||||||
let lp = loop.ensure(m, true);
|
let firewall = step('firewall (fw4)', () => fw.sync(m), changed);
|
||||||
loop.sync_resolver(m);
|
let lp = step('internet like a home device', () => loop.ensure(m, true));
|
||||||
fw.sync_reply_routes(m);
|
step('resolver for Home-only devices', () => { loop.sync_resolver(m); });
|
||||||
let s = locked_sync(m, usage, true);
|
step('reply routes', () => { fw.sync_reply_routes(m); });
|
||||||
|
let s = step('access rules and devices', () => locked_sync(m, usage, true), (x) => ({ table: x.table, peers: x.peers }));
|
||||||
ensure_dir(RUN_DIR);
|
ensure_dir(RUN_DIR);
|
||||||
write_file(NET_SIG, net_signature(m), 0o644);
|
write_file(NET_SIG, net_signature(m), 0o644);
|
||||||
return { network, firewall, lp, peers: s.peers, warning: s.warning };
|
return { network, firewall, lp, peers: s.peers, warning: s.warning, facts: sync_facts(m, s.table, s.peers),
|
||||||
|
counts: [ length(keys(m.servers)), length(keys(m.people)), length(keys(m.devices)) ] };
|
||||||
});
|
});
|
||||||
loop.remember(r.lp);
|
loop.remember(r.lp);
|
||||||
|
let n = (k, one, many) => `${k} ${k == 1 ? one : many}`;
|
||||||
|
let took = sprintf('configuration applied in %d ms · %s, %s, %s', ms() - t0,
|
||||||
|
n(r.counts[0], 'server', 'servers'), n(r.counts[1], 'person', 'people'), n(r.counts[2], 'device', 'devices'));
|
||||||
|
// Syslog in English (sync_facts, loop.error_note); the admin's answer carries the words in their language.
|
||||||
|
if (r.facts)
|
||||||
|
syslog('warn', 'apply', `${took} · ${r.facts}`);
|
||||||
|
else
|
||||||
|
syslog('info', 'apply', took);
|
||||||
|
if (r.lp.error)
|
||||||
|
syslog('warn', 'apply', `internet like a home device: ${type(r.lp.error) == 'object' ? loop.error_note(r.lp.error) : r.lp.error}`);
|
||||||
return { network: r.network, firewall: r.firewall, like_home: r.lp.error ? { error: loop.error_text(r.lp.error) } : !r.lp.off, peers: r.peers, warning: r.warning };
|
return { network: r.network, firewall: r.firewall, like_home: r.lp.error ? { error: loop.error_text(r.lp.error) } : !r.lp.off, peers: r.peers, warning: r.warning };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import { readfile, stat, unlink } from 'fs';
|
import { readfile, stat, unlink } from 'fs';
|
||||||
import {
|
import {
|
||||||
q, sh, sh_out, rand_int, rand_bytes, valid_key, ip2int, tunnel_name, ensure_dir, write_file, read_json, write_json, lock, unlock,
|
q, sh, sh_out, rand_int, rand_bytes, valid_key, ip2int, tunnel_name, ensure_dir, write_file, read_json, write_json, lock, unlock,
|
||||||
slog, iface_status, DATA_DIR, RUN_DIR
|
slog, syslog, some_of, iface_status, DATA_DIR, RUN_DIR
|
||||||
} from 'dawnline.util';
|
} from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as net from 'dawnline.net';
|
import * as net from 'dawnline.net';
|
||||||
@@ -763,32 +763,58 @@ export function peer_diff(devs, dmp, ifname) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Push the peer list of every server to the kernel without restarting it. */
|
/** Push the peer list of every server to the kernel without restarting it. */
|
||||||
|
// Each tunnel's peers as last loaded ({ ifname: [ "Person · Device (address)" ] }), so a log line can say who came and went.
|
||||||
|
const PEERS_SEEN = `${RUN_DIR}/peers-seen.json`;
|
||||||
|
|
||||||
export function sync_peers(m, states) {
|
export function sync_peers(m, states) {
|
||||||
ensure_dir(RUN_DIR);
|
ensure_dir(RUN_DIR);
|
||||||
let res = {};
|
let res = {};
|
||||||
|
let seen = read_json(PEERS_SEEN, {}), now = {};
|
||||||
for (let id, srv in m.servers) {
|
for (let id, srv in m.servers) {
|
||||||
// Only Dawnline's own interfaces: never another tunnel of the same name (core.tunnels).
|
// Only Dawnline's own interfaces: never another tunnel of the same name (core.tunnels).
|
||||||
if (!srv.enabled || !length(core.tunnels(srv)))
|
if (!srv.enabled || !length(core.tunnels(srv)))
|
||||||
continue;
|
continue;
|
||||||
if (system(`awg show ${q(srv.ifname)} public-key >/dev/null 2>&1`) != 0) {
|
if (system(`awg show ${q(srv.ifname)} public-key >/dev/null 2>&1`) != 0) {
|
||||||
res[id] = 'down';
|
res[id] = 'down';
|
||||||
|
syslog('debug', 'awg', `interface ${srv.ifname} (${srv.name}): down, no devices to load`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let lines = [ '[Interface]', `PrivateKey = ${srv.private_key}`, `ListenPort = ${srv.port}`, '' ];
|
let lines = [ '[Interface]', `PrivateKey = ${srv.private_key}`, `ListenPort = ${srv.port}`, '' ];
|
||||||
|
let who = [];
|
||||||
for (let d in tunnel_devices(m, id, states)) {
|
for (let d in tunnel_devices(m, id, states)) {
|
||||||
push(lines, '[Peer]', `PublicKey = ${d.public_key}`);
|
push(lines, '[Peer]', `PublicKey = ${d.public_key}`);
|
||||||
if (d.preshared_key)
|
if (d.preshared_key)
|
||||||
push(lines, `PresharedKey = ${d.preshared_key}`);
|
push(lines, `PresharedKey = ${d.preshared_key}`);
|
||||||
push(lines, `AllowedIPs = ${d.address}/32`, '');
|
push(lines, `AllowedIPs = ${d.address}/32`, '');
|
||||||
|
push(who, `${m.people[d.person]?.name ?? d.person} · ${d.name} (${d.address})`);
|
||||||
}
|
}
|
||||||
let f = `${RUN_DIR}/${srv.ifname}.conf`;
|
let f = `${RUN_DIR}/${srv.ifname}.conf`;
|
||||||
write_file(f, join('\n', lines));
|
write_file(f, join('\n', lines));
|
||||||
let r = sh(`awg syncconf ${q(srv.ifname)} ${f}`);
|
let r = sh(`awg syncconf ${q(srv.ifname)} ${f}`);
|
||||||
unlink(f);
|
unlink(f);
|
||||||
res[id] = r.code == 0 ? 'ok' : trim(r.out);
|
res[id] = r.code == 0 ? 'ok' : trim(r.out);
|
||||||
if (r.code != 0)
|
if (r.code != 0) {
|
||||||
slog('awg', 'error', L_("couldn't load devices into the tunnel"), trim(r.out), srv.name);
|
slog('awg', 'error', L_("couldn't load devices into the tunnel"), trim(r.out), srv.name);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
// Who came in and who left since the last load: info; the same peers: debug.
|
||||||
|
now[srv.ifname] = who;
|
||||||
|
let was = seen[srv.ifname];
|
||||||
|
let head = `interface ${srv.ifname} (${srv.name}): awg syncconf · listen port ${srv.port} · ${length(who)} ${length(who) == 1 ? 'peer' : 'peers'}`;
|
||||||
|
// The first load since the router started (or since the tunnel came up): how many, the names at debug.
|
||||||
|
if (was == null) {
|
||||||
|
syslog('info', 'awg', `${head} loaded`);
|
||||||
|
syslog('debug', 'awg', `interface ${srv.ifname}: ${join(', ', who)}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let add = filter(who, (x) => index(was, x) < 0), del = filter(was, (x) => index(who, x) < 0);
|
||||||
|
if (length(add) || length(del))
|
||||||
|
syslog('info', 'awg', `${head}${length(add) ? ' · added ' + some_of(add) : ''}${length(del) ? ' · removed ' + some_of(del) : ''}`);
|
||||||
|
else
|
||||||
|
syslog('debug', 'awg', `${head}, unchanged`);
|
||||||
|
}
|
||||||
|
if (sprintf('%J', now) != sprintf('%J', seen))
|
||||||
|
write_json(PEERS_SEEN, now, 0o600);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ export function load(c) {
|
|||||||
hostnames: g('hostnames'),
|
hostnames: g('hostnames'),
|
||||||
domain: g('domain'),
|
domain: g('domain'),
|
||||||
log_connections: g('log_connections'),
|
log_connections: g('log_connections'),
|
||||||
|
// What goes to syslog (dawnline.util syslog).
|
||||||
|
log_level: g('log_level'),
|
||||||
// Repair tunnels and services on its own (the agent, every minute).
|
// Repair tunnels and services on its own (the agent, every minute).
|
||||||
watchdog: g('watchdog'),
|
watchdog: g('watchdog'),
|
||||||
// Second DNS for "home names" devices, used by the device when the tunnel is down.
|
// Second DNS for "home names" devices, used by the device when the tunnel is down.
|
||||||
@@ -789,6 +791,24 @@ export function set_device_link(c, m, id, a) {
|
|||||||
return changed;
|
return changed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change what a device is (one of KINDS): true when it changed, false when it
|
||||||
|
* already was. Its configuration follows (device_mtu: phones and tablets take
|
||||||
|
* smaller packets); nothing on the router changes.
|
||||||
|
*/
|
||||||
|
export function set_device_kind(c, m, id, kind) {
|
||||||
|
let d = m.devices[id];
|
||||||
|
if (!d)
|
||||||
|
fail(_('Unknown device.'));
|
||||||
|
if (index(KINDS, kind) < 0)
|
||||||
|
fail(_('Unknown device type.'));
|
||||||
|
if (kind == d.kind)
|
||||||
|
return false;
|
||||||
|
c.set(CONFIG, id, 'kind', kind);
|
||||||
|
d.kind = kind;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
export function delete_device(c, m, id) {
|
export function delete_device(c, m, id) {
|
||||||
let d = m.devices[id];
|
let d = m.devices[id];
|
||||||
if (!d)
|
if (!d)
|
||||||
|
|||||||
@@ -29,6 +29,22 @@ export function need_awg() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What a device_changed event says changed: each option with its new value
|
||||||
|
* ("lan_bypass=on", "mtu=1400", "keepalive=auto": '' is the server's again,
|
||||||
|
* "kind=phone"), so the activity log can say what it became.
|
||||||
|
*/
|
||||||
|
function change_detail(names, ch) {
|
||||||
|
return join(', ', map(names, (k) => {
|
||||||
|
if (k == 'lan_bypass')
|
||||||
|
return `lan_bypass=${ch.lan_bypass === true ? 'on' : 'off'}`;
|
||||||
|
if (k == 'kind')
|
||||||
|
return `kind=${ch.kind}`;
|
||||||
|
let v = trim(`${ch[k] ?? ''}`);
|
||||||
|
return `${k}=${v == '' ? 'auto' : v}`;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
/** The device `id` as `opts` may touch it (inside a transaction's model). */
|
/** The device `id` as `opts` may touch it (inside a transaction's model). */
|
||||||
function own(m, id, opts) {
|
function own(m, id, opts) {
|
||||||
let d = m.devices[id];
|
let d = m.devices[id];
|
||||||
@@ -58,9 +74,11 @@ export function add(person, name, kind, opts) {
|
|||||||
/**
|
/**
|
||||||
* Rename and/or turn a device off or on, or change how it connects (`ch` =
|
* Rename and/or turn a device off or on, or change how it connects (`ch` =
|
||||||
* { name?, disabled?, mtu?, keepalive?, lan_bypass? }, see
|
* { name?, disabled?, mtu?, keepalive?, lan_bypass? }, see
|
||||||
* core.set_device_link); only the admin turns devices off or changes the
|
* core.set_device_link); only the admin turns devices off or sets the MTU and
|
||||||
* rest. Returns the runtime sync ({} after a change of the link values alone:
|
* keep-alive, the portal may switch LAN Bypass (the device then takes its
|
||||||
* they are in the device's configuration, nothing on the router changes).
|
* updated configuration, keys unchanged). Returns the runtime sync ({} after a
|
||||||
|
* change of the link values alone: they are in the device's configuration,
|
||||||
|
* nothing on the router changes).
|
||||||
*/
|
*/
|
||||||
export function update(id, ch, opts) {
|
export function update(id, ch, opts) {
|
||||||
opts ??= {};
|
opts ??= {};
|
||||||
@@ -68,7 +86,7 @@ export function update(id, ch, opts) {
|
|||||||
if (ch.disabled != null && by != 'admin')
|
if (ch.disabled != null && by != 'admin')
|
||||||
die(_('Only the admin can turn devices off.'));
|
die(_('Only the admin can turn devices off.'));
|
||||||
let link = ch.mtu != null || ch.keepalive != null || ch.lan_bypass != null;
|
let link = ch.mtu != null || ch.keepalive != null || ch.lan_bypass != null;
|
||||||
if (link && by != 'admin')
|
if ((ch.mtu != null || ch.keepalive != null) && by != 'admin')
|
||||||
die(_('Only the admin can change how a device connects.'));
|
die(_('Only the admin can change how a device connects.'));
|
||||||
let linked = [];
|
let linked = [];
|
||||||
let d0 = store.transact((c, m) => {
|
let d0 = store.transact((c, m) => {
|
||||||
@@ -91,9 +109,9 @@ export function update(id, ch, opts) {
|
|||||||
live.add_event({ type: 'device_changed', person: d0.person, device: id, detail: ch.disabled ? 'turned off' : 'turned on', by });
|
live.add_event({ type: 'device_changed', person: d0.person, device: id, detail: ch.disabled ? 'turned off' : 'turned on', by });
|
||||||
else if (ch.name != null && ch.name != d0.name)
|
else if (ch.name != null && ch.name != d0.name)
|
||||||
live.add_event({ type: 'device_changed', person: d0.person, device: id, detail: `renamed from ${d0.name}`, by });
|
live.add_event({ type: 'device_changed', person: d0.person, device: id, detail: `renamed from ${d0.name}`, by });
|
||||||
// The option names, as person_changed lists a person's.
|
// The options with what they became (change_detail).
|
||||||
if (length(linked))
|
if (length(linked))
|
||||||
live.add_event({ type: 'device_changed', person: d0.person, device: id, detail: join(', ', linked), by });
|
live.add_event({ type: 'device_changed', person: d0.person, device: id, detail: change_detail(linked, ch), by });
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,10 +124,19 @@ export function update(id, ch, opts) {
|
|||||||
function rotate(id, opts) {
|
function rotate(id, opts) {
|
||||||
opts ??= {};
|
opts ??= {};
|
||||||
let by = opts.by ?? 'admin';
|
let by = opts.by ?? 'admin';
|
||||||
store.transact((c, m) => {
|
let changed = [];
|
||||||
own(m, id, opts);
|
let person = store.transact((c, m) => {
|
||||||
|
let d = own(m, id, opts);
|
||||||
|
if (opts.kind != null && core.set_device_kind(c, m, id, opts.kind))
|
||||||
|
push(changed, 'kind');
|
||||||
|
if (opts.lan_bypass != null)
|
||||||
|
push(changed, ...core.set_device_link(c, m, id, { lan_bypass: opts.lan_bypass === true }));
|
||||||
core.rotate_device(c, m, id, awg.new_keys());
|
core.rotate_device(c, m, id, awg.new_keys());
|
||||||
|
return d.person;
|
||||||
});
|
});
|
||||||
|
if (length(changed))
|
||||||
|
live.add_event({ type: 'device_changed', person, device: id, by,
|
||||||
|
detail: change_detail(changed, { kind: opts.kind, lan_bypass: opts.lan_bypass === true }) });
|
||||||
// The device a portal page came through would lose its tunnel before the
|
// The device a portal page came through would lose its tunnel before the
|
||||||
// answer gets out: load the new key a moment after answering.
|
// answer gets out: load the new key a moment after answering.
|
||||||
let s = null;
|
let s = null;
|
||||||
@@ -132,8 +159,10 @@ function rotate(id, opts) {
|
|||||||
* the admin changed; the portal's Reconnect and the admin's New keys): new
|
* the admin changed; the portal's Reconnect and the admin's New keys): new
|
||||||
* keys, so the configuration it holds stops working with the sync, and it
|
* keys, so the configuration it holds stops working with the sync, and it
|
||||||
* counts as not set up until it connects with the new one. The usage keeps
|
* counts as not set up until it connects with the new one. The usage keeps
|
||||||
* the old keys' last handshake: awg.handshake_since hides it. Returns the new
|
* the old keys' last handshake: awg.handshake_since hides it. `opts.kind` and
|
||||||
* configuration (with `warning` when the sync did not fully take).
|
* `opts.lan_bypass` (the portal's Reconnect: what it is, LAN Bypass) change
|
||||||
|
* with the keys, in the same write. Returns the new configuration (with
|
||||||
|
* `warning` when the sync did not fully take).
|
||||||
*/
|
*/
|
||||||
export function reconnect(id, opts) {
|
export function reconnect(id, opts) {
|
||||||
opts ??= {};
|
opts ??= {};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
// named dawnline_* are ever changed.
|
// named dawnline_* are ever changed.
|
||||||
|
|
||||||
import { readfile, unlink } from 'fs';
|
import { readfile, unlink } from 'fs';
|
||||||
import { q, sh, sh_out, uniq, in_nets, uci_put, uci_section, ack_config, write_file, RUN_DIR } from 'dawnline.util';
|
import { sh, sh_out, uniq, in_nets, uci_put, uci_section, ack_config, write_file, syslog, opts_text, RUN_DIR } from 'dawnline.util';
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as net from 'dawnline.net';
|
import * as net from 'dawnline.net';
|
||||||
@@ -33,12 +33,21 @@ export function sync(m, dry) {
|
|||||||
let c = cursor();
|
let c = cursor();
|
||||||
c.load('firewall');
|
c.load('firewall');
|
||||||
let changed = false, want = {};
|
let changed = false, want = {};
|
||||||
|
// What changed, section by section, for syslog once it is saved (a dry run says nothing).
|
||||||
|
let notes = [];
|
||||||
|
|
||||||
let sec = (name, stype, opts) => {
|
let sec = (name, stype, opts) => {
|
||||||
want[name] = true;
|
want[name] = true;
|
||||||
changed = uci_section(c, 'firewall', name, stype) || changed;
|
let created = uci_section(c, 'firewall', name, stype), diff = {};
|
||||||
for (let k, v in opts)
|
for (let k, v in opts)
|
||||||
changed = uci_put(c, 'firewall', name, k, v) || changed;
|
if (uci_put(c, 'firewall', name, k, v))
|
||||||
|
diff[k] = v;
|
||||||
|
if (created || length(keys(diff))) {
|
||||||
|
changed = true;
|
||||||
|
push(notes, [ 'info', `${stype} ${name}: ${created ? 'created' : 'updated'} · ${opts_text(created ? opts : diff)}` ]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
push(notes, [ 'debug', `${stype} ${name}: unchanged` ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
let snap = net.snapshot(true);
|
let snap = net.snapshot(true);
|
||||||
@@ -130,17 +139,20 @@ export function sync(m, dry) {
|
|||||||
push(stale, s['.name']);
|
push(stale, s['.name']);
|
||||||
});
|
});
|
||||||
for (let s in stale) {
|
for (let s in stale) {
|
||||||
|
push(notes, [ 'info', `${c.get('firewall', s) ?? 'section'} ${s}: removed` ]);
|
||||||
c.delete('firewall', s);
|
c.delete('firewall', s);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if (dry)
|
if (dry)
|
||||||
return changed;
|
return changed;
|
||||||
|
|
||||||
|
for (let n in notes)
|
||||||
|
syslog(n[0], 'firewall', n[1]);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
c.commit('firewall');
|
c.commit('firewall');
|
||||||
ack_config([ 'firewall' ]);
|
ack_config([ 'firewall' ]);
|
||||||
|
syslog('info', 'firewall', 'fw4 -q reload');
|
||||||
system('fw4 -q reload');
|
system('fw4 -q reload');
|
||||||
system("logger -t dawnline 'firewall updated'");
|
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
};
|
};
|
||||||
@@ -268,18 +280,24 @@ export function sync_reply_routes(m) {
|
|||||||
}
|
}
|
||||||
let s = reply_script(m, proxy_diverts());
|
let s = reply_script(m, proxy_diverts());
|
||||||
if (s == '') {
|
if (s == '') {
|
||||||
if (reply_loaded())
|
if (reply_loaded()) {
|
||||||
|
syslog('info', 'nftables', `table inet ${REPLY_TABLE}: removed (no proxy to keep Dawnline's answers out of)`);
|
||||||
system(`nft delete table inet ${REPLY_TABLE} 2>/dev/null`);
|
system(`nft delete table inet ${REPLY_TABLE} 2>/dev/null`);
|
||||||
|
}
|
||||||
unlink(REPLY_SIG);
|
unlink(REPLY_SIG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (s == readfile(REPLY_SIG) && reply_loaded())
|
if (s == readfile(REPLY_SIG) && reply_loaded()) {
|
||||||
|
syslog('debug', 'nftables', `table inet ${REPLY_TABLE}: unchanged`);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
let err = nft.load(`table inet ${REPLY_TABLE}\ndelete table inet ${REPLY_TABLE}\n${s}`);
|
let err = nft.load(`table inet ${REPLY_TABLE}\ndelete table inet ${REPLY_TABLE}\n${s}`);
|
||||||
if (err) {
|
if (err) {
|
||||||
unlink(REPLY_SIG);
|
unlink(REPLY_SIG);
|
||||||
system(`logger -t dawnline -p user.err ${q('reply table: ' + err)}`);
|
syslog('error', 'nftables', `table inet ${REPLY_TABLE}: loading failed · ${err}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
syslog('info', 'nftables', `table inet ${REPLY_TABLE}: loaded · ${length(match(s, /\n/g) ?? []) + 1} lines (Dawnline's own answers kept out of proxies)`);
|
||||||
|
syslog('debug', 'nftables', `table inet ${REPLY_TABLE}: ${s}`);
|
||||||
write_file(REPLY_SIG, s, 0o644);
|
write_file(REPLY_SIG, s, 0o644);
|
||||||
};
|
};
|
||||||
@@ -79,14 +79,17 @@ function cached(key, ttl, fn) {
|
|||||||
/* ---------- releases ---------- */
|
/* ---------- releases ---------- */
|
||||||
|
|
||||||
function slim(x) {
|
function slim(x) {
|
||||||
let digests = {};
|
let digests = {}, ids = {};
|
||||||
for (let a in x.assets ?? [])
|
for (let a in x.assets ?? []) {
|
||||||
if (match(a.digest ?? '', /^sha256:[0-9a-f]{64}$/))
|
if (match(a.digest ?? '', /^sha256:[0-9a-f]{64}$/))
|
||||||
digests[a.name] = substr(a.digest, 7);
|
digests[a.name] = substr(a.digest, 7);
|
||||||
|
if (type(a.id) == 'int' && a.id > 0)
|
||||||
|
ids[a.name] = a.id;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
tag: x.tag_name, name: x.name ?? x.tag_name, published: x.published_at ?? null,
|
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),
|
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];
|
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
|
* 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
|
* 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) {
|
export function download(url, dest, o) {
|
||||||
o ??= {};
|
o ??= {};
|
||||||
let want = o.sha256 ? lc(o.sha256) : null;
|
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)\//))
|
if (want && o.mirrors && match(url, /^https:\/\/(github\.com|raw\.githubusercontent\.com)\//))
|
||||||
for (let m in MIRRORS)
|
for (let m in MIRRORS)
|
||||||
push(tries, m + url);
|
push(tries, { u: m + url, mirror: true });
|
||||||
for (let i, u in tries) {
|
for (let i, t in tries) {
|
||||||
let host = replace(u, /^https:\/\/([^\/]+)\/.*$/, '$1');
|
let host = replace(t.u, /^https:\/\/([^\/]+)\/.*$/, '$1');
|
||||||
if (i > 0)
|
if (t.mirror)
|
||||||
o.log?.(sprintf(_('Trying mirror %s'), host));
|
o.log?.(sprintf(_('Trying mirror %s'), host));
|
||||||
let r = have_curl()
|
let r = curl
|
||||||
? run(`curl -fsSL --connect-timeout 15 --max-time 300 --retry 1 -o ${q(dest)} ${q(u)}`)
|
? run(`curl -fsSL --connect-timeout 15 --max-time 300 --retry 1 -o ${q(dest)} ${q(t.u)}`)
|
||||||
: run(`uclient-fetch -q -T 30 -O ${q(dest)} ${q(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 (r.code == 0 && (stat(dest)?.size ?? 0) > 0) {
|
||||||
if (!want || sha256(dest) == want)
|
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));
|
o.log?.(sprintf(_("Warning: %s sent a file that does not match GitHub's sha256, discarded"), host));
|
||||||
}
|
}
|
||||||
system(`rm -f ${q(dest)}`);
|
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'));
|
o.log?.(_('GitHub did not answer, trying mirrors'));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { readfile, stat, unlink } from 'fs';
|
import { readfile, stat, unlink } from 'fs';
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
import {
|
import {
|
||||||
ensure_dir, read_json, write_json, lock, unlock, month_key, day_key, day_key_ago, uniq,
|
ensure_dir, read_json, write_json, lock, unlock, month_key, day_key, day_key_ago, uniq, syslog,
|
||||||
iface_status as util_iface_status, RUN_DIR, DATA_DIR
|
iface_status as util_iface_status, RUN_DIR, DATA_DIR
|
||||||
} from 'dawnline.util';
|
} from 'dawnline.util';
|
||||||
import * as awg from 'dawnline.awg';
|
import * as awg from 'dawnline.awg';
|
||||||
@@ -422,13 +422,51 @@ function with_names(e, c) {
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Events about someone's connection, not about the system: they stay out of syslog
|
||||||
|
// (the activity log has them). Connects, roams, a device's link trouble and its end.
|
||||||
|
const NOT_SYSTEM = [ 'connect', 'disconnect', 'roam', 'device_failing', 'device_recovered' ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An activity event at its syslog level, or null when it stays out (a
|
||||||
|
* connection: syslog says what the system does). People and their devices
|
||||||
|
* (what changes the tunnels and the rules) are info, problems warn and their
|
||||||
|
* end ("…_up") info.
|
||||||
|
*/
|
||||||
|
export function event_level(e) {
|
||||||
|
let cat = category_of(e.type);
|
||||||
|
if (cat == 'connections' || index(NOT_SYSTEM, e.type) >= 0)
|
||||||
|
return null;
|
||||||
|
if (cat == 'problems' && !match(e.type, /_up$/))
|
||||||
|
return 'warn';
|
||||||
|
return 'info';
|
||||||
|
};
|
||||||
|
|
||||||
|
/** An activity event as a syslog line: "Myata · Phone device changed · kind=phone, lan_bypass=on (portal)". */
|
||||||
|
export function event_line(e) {
|
||||||
|
let who = join(' · ', filter([ e.pname ?? e.person, e.dname ?? e.device ], (x) => x != null && x != ''));
|
||||||
|
return join(' ', filter([ who, replace(e.type ?? 'event', /_/g, ' '), e.detail ? `· ${e.detail}` : '', e.by ? `(${e.by})` : '' ], (x) => x != ''));
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The system's events to syslog, whatever the activity log records (its categories are the admin's choice for the page). */
|
||||||
|
function syslog_events(list, c) {
|
||||||
|
for (let e in list) {
|
||||||
|
let lvl = event_level(e);
|
||||||
|
if (lvl)
|
||||||
|
syslog(lvl, category_of(e.type), event_line(with_names(e, c)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function add_events(list, pol) {
|
export function add_events(list, pol) {
|
||||||
pol ??= policy();
|
pol ??= policy();
|
||||||
list = filter(list ?? [], (e) => index(pol.categories, category_of(e.type)) >= 0);
|
list ??= [];
|
||||||
if (!length(list))
|
if (!length(list))
|
||||||
return;
|
return;
|
||||||
let c = cursor();
|
let c = cursor();
|
||||||
c.load('dawnline');
|
c.load('dawnline');
|
||||||
|
syslog_events(list, c);
|
||||||
|
list = filter(list, (e) => index(pol.categories, category_of(e.type)) >= 0);
|
||||||
|
if (!length(list))
|
||||||
|
return;
|
||||||
let l = lock('events');
|
let l = lock('events');
|
||||||
let ev = load_events();
|
let ev = load_events();
|
||||||
let ts = time();
|
let ts = time();
|
||||||
@@ -451,6 +489,9 @@ export function add_event(e) {
|
|||||||
* and device (when it has one) within `window` s.
|
* and device (when it has one) within `window` s.
|
||||||
*/
|
*/
|
||||||
export function add_event_merged(e, window) {
|
export function add_event_merged(e, window) {
|
||||||
|
let c0 = cursor();
|
||||||
|
c0.load('dawnline');
|
||||||
|
syslog_events([ { ...e } ], c0);
|
||||||
let pol = policy();
|
let pol = policy();
|
||||||
if (index(pol.categories, category_of(e.type)) < 0)
|
if (index(pol.categories, category_of(e.type)) < 0)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -84,6 +84,18 @@ export function resolve(host) {
|
|||||||
return resolve_all([ host ])[host] ?? [];
|
return resolve_all([ host ])[host] ?? [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The address to give an app that takes no name for the server (V2RayTun's
|
||||||
|
* Android core hands the endpoint over as it is): IPv4 first, as a phone on
|
||||||
|
* mobile data may have no IPv6. The host itself when it is an IP; null when
|
||||||
|
* the name does not resolve.
|
||||||
|
*/
|
||||||
|
export function host_ip(host) {
|
||||||
|
let ips = resolve(host);
|
||||||
|
let v4 = filter(ips, (x) => ip2int(x) != null);
|
||||||
|
return v4[0] ?? ips[0] ?? null;
|
||||||
|
};
|
||||||
|
|
||||||
/** The IPv4 address of a netifd interface (a zone name for older configs). */
|
/** The IPv4 address of a netifd interface (a zone name for older configs). */
|
||||||
export function wan_ipv4(zone) {
|
export function wan_ipv4(zone) {
|
||||||
let st = live.iface_status(zone == 'wan' ? 'wan' : zone);
|
let st = live.iface_status(zone == 'wan' ? 'wan' : zone);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
import { readfile, writefile, readlink, stat, unlink } from 'fs';
|
import { readfile, writefile, readlink, stat, unlink } from 'fs';
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
import {
|
import {
|
||||||
sh, sh_out, q, ip2int, int2ip, parse_cidr, cidr_any, ensure_dir, read_json, write_json, slog, RUN_DIR
|
sh, sh_out, q, ip2int, int2ip, parse_cidr, cidr_any, ensure_dir, read_json, write_json, slog, syslog, syslog_lines, RUN_DIR
|
||||||
} from 'dawnline.util';
|
} from 'dawnline.util';
|
||||||
import * as net from 'dawnline.net';
|
import * as net from 'dawnline.net';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
@@ -60,12 +60,20 @@ function log(msg, level, detail) {
|
|||||||
slog('dawnline', level ?? 'info', msg, detail, WHO);
|
slog('dawnline', level ?? 'info', msg, detail, WHO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the commands that set the path up or take it down, each in syslog as
|
||||||
|
* it is given ("$ ip netns add dawnline"), a failure with what it said.
|
||||||
|
* Only called when something changes (ensure() returns early otherwise).
|
||||||
|
*/
|
||||||
function run(cmds) {
|
function run(cmds) {
|
||||||
let errs = [];
|
let errs = [];
|
||||||
|
syslog_lines('info', 'loop', join('\n', cmds), '$ ');
|
||||||
for (let c in cmds) {
|
for (let c in cmds) {
|
||||||
let r = sh(c);
|
let r = sh(c);
|
||||||
if (r.code != 0)
|
if (r.code != 0) {
|
||||||
push(errs, `${c}: ${trim(r.out)}`);
|
push(errs, `${c}: ${trim(r.out)}`);
|
||||||
|
syslog('error', 'loop', `failed: ${c} · ${trim(r.out)}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return errs;
|
return errs;
|
||||||
}
|
}
|
||||||
@@ -232,8 +240,8 @@ function pick_table(saved) {
|
|||||||
* { code: 'setup', detail } a command failed (detail: it and what it said)
|
* { code: 'setup', detail } a command failed (detail: it and what it said)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** A reason from plan() for the service log: English, like every log line. */
|
/** A reason from plan() for the service log and syslog: English, like every log line. */
|
||||||
function error_note(e) {
|
export function error_note(e) {
|
||||||
if (e.code == 'no_lan')
|
if (e.code == 'no_lan')
|
||||||
return L_('No LAN detected.');
|
return L_('No LAN detected.');
|
||||||
if (e.code == 'not_bridge')
|
if (e.code == 'not_bridge')
|
||||||
@@ -245,7 +253,7 @@ function error_note(e) {
|
|||||||
if (e.code == 'no_transit')
|
if (e.code == 'no_transit')
|
||||||
return L_('No free link-local range for the internal link.');
|
return L_('No free link-local range for the internal link.');
|
||||||
return L_('No free routing table.');
|
return L_('No free routing table.');
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Why "like a home device" is off (a reason above), as a sentence in the
|
* Why "like a home device" is off (a reason above), as a sentence in the
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Dawnline — the live meter (the Overview's Speed now): each server's
|
// Dawnline — the live meter (Speed now on the Overview, the People list and a
|
||||||
// throughput, one point a second over the last two minutes.
|
// person's page): each server's throughput and that of each device moving
|
||||||
|
// traffic, one point a second over the last two minutes.
|
||||||
//
|
//
|
||||||
// The meter RPC (dawnline.rpc.status) calls want() and read(); the agent's
|
// The meter RPC (dawnline.rpc.status) calls want() and read(); the agent's
|
||||||
// watcher makes a point from every read it already does (sample(), point())
|
// watcher makes a point from every read it already does (sample(), point())
|
||||||
@@ -8,8 +9,8 @@
|
|||||||
// while WANT is younger than WANT_FOR seconds: the first second of a look,
|
// while WANT is younger than WANT_FOR seconds: the first second of a look,
|
||||||
// then with each new point. When WANT goes stale it removes FILE: with nobody
|
// then with each new point. When WANT goes stale it removes FILE: with nobody
|
||||||
// looking the watcher pays a little arithmetic and one stat() a second, and
|
// looking the watcher pays a little arithmetic and one stat() a second, and
|
||||||
// writes nothing. FILE holds server ids and byte rates only, no keys, names
|
// writes nothing. FILE holds server and device ids and byte rates only, no
|
||||||
// or personal codes. Who is online and the per-minute rates are not here
|
// keys, names or personal codes. Who is online and the per-minute rates are not here
|
||||||
// (dawnline.live, the agent's tick).
|
// (dawnline.live, the agent's tick).
|
||||||
//
|
//
|
||||||
// Bytes are the peers' counters (dawnline.awg.dump): tx includes the
|
// Bytes are the peers' counters (dawnline.awg.dump): tx includes the
|
||||||
@@ -95,26 +96,31 @@ function delta(a, b) {
|
|||||||
/**
|
/**
|
||||||
* The point between samples `a` and `b`, null when they are not a second or
|
* The point between samples `a` and `b`, null when they are not a second or
|
||||||
* so apart (the first sample, a stalled watcher): { ts, servers: { server
|
* so apart (the first sample, a stalled watcher): { ts, servers: { server
|
||||||
* id: [ rx, tx ] } }, bytes per second of its devices together (rx what came
|
* id: [ rx, tx ] }, dev: { device id: [ rx, tx ] } }, bytes per second of
|
||||||
* from them, tx what went to them, as a server's per-minute `rate`), for
|
* each server's devices together (rx what came from them, tx what went to
|
||||||
* every server whose tunnel `b` read ([ 0, 0 ] when nothing moved). A device
|
* them, as a server's per-minute `rate`), for every server whose tunnel `b`
|
||||||
* is counted from its second sample on, on the server it was on in both.
|
* read ([ 0, 0 ] when nothing moved), and of each device that moved
|
||||||
|
* something (one left out moved nothing, while its server was read). A
|
||||||
|
* device is counted from its second sample on, on the server it was on in both.
|
||||||
*/
|
*/
|
||||||
export function point(a, b) {
|
export function point(a, b) {
|
||||||
let dt = b.t - a.t;
|
let dt = b.t - a.t;
|
||||||
if (!(dt > 0.2 && dt < 5))
|
if (!(dt > 0.2 && dt < 5))
|
||||||
return null;
|
return null;
|
||||||
let sum = {};
|
let sum = {}, dev = {};
|
||||||
for (let sid in b.servers)
|
for (let sid in b.servers)
|
||||||
sum[sid] = [ 0, 0 ];
|
sum[sid] = [ 0, 0 ];
|
||||||
for (let id, v in b.dev) {
|
for (let id, v in b.dev) {
|
||||||
let o = a.dev[id];
|
let o = a.dev[id];
|
||||||
if (!o || o[2] != v[2])
|
if (!o || o[2] != v[2])
|
||||||
continue;
|
continue;
|
||||||
sum[v[2]][0] += delta(o[0], v[0]);
|
let rx = delta(o[0], v[0]), tx = delta(o[1], v[1]);
|
||||||
sum[v[2]][1] += delta(o[1], v[1]);
|
sum[v[2]][0] += rx;
|
||||||
|
sum[v[2]][1] += tx;
|
||||||
|
if (rx || tx)
|
||||||
|
dev[id] = [ int(rx / dt), int(tx / dt) ];
|
||||||
}
|
}
|
||||||
let p = { ts: b.ts, servers: {} };
|
let p = { ts: b.ts, servers: {}, dev };
|
||||||
for (let sid, v in sum)
|
for (let sid, v in sum)
|
||||||
p.servers[sid] = [ int(v[0] / dt), int(v[1] / dt) ];
|
p.servers[sid] = [ int(v[0] / dt), int(v[1] / dt) ];
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
import { stat, unlink } from 'fs';
|
import { stat, unlink } from 'fs';
|
||||||
import { q, slog } from 'dawnline.util';
|
import { slog, syslog } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as store from 'dawnline.store';
|
import * as store from 'dawnline.store';
|
||||||
import { L_ } from 'dawnline.i18n';
|
import { L_ } from 'dawnline.i18n';
|
||||||
@@ -47,7 +47,7 @@ export function uhttpd() {
|
|||||||
c.delete('uhttpd', 'main', 'error_page');
|
c.delete('uhttpd', 'main', 'error_page');
|
||||||
c.commit('uhttpd');
|
c.commit('uhttpd');
|
||||||
system('/etc/init.d/uhttpd reload >/dev/null 2>&1');
|
system('/etc/init.d/uhttpd reload >/dev/null 2>&1');
|
||||||
system(`logger -t dawnline ${q('portal removed from the LuCI web server')}`);
|
syslog('info', 'portal', 'portal removed from the LuCI web server');
|
||||||
}
|
}
|
||||||
if (stat(LAN_CGI))
|
if (stat(LAN_CGI))
|
||||||
unlink(LAN_CGI);
|
unlink(LAN_CGI);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
import { stat, unlink, writefile } from 'fs';
|
import { stat, unlink, writefile } from 'fs';
|
||||||
import { q, uci_put, uci_section, ack_config, iface_intent, ensure_dir, read_json, write_json, slog, RUN_DIR } from 'dawnline.util';
|
import { q, uci_put, uci_section, ack_config, iface_intent, ensure_dir, read_json, write_json, slog, syslog, opts_text, RUN_DIR } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as awg from 'dawnline.awg';
|
import * as awg from 'dawnline.awg';
|
||||||
import { L_ } from 'dawnline.i18n';
|
import { L_ } from 'dawnline.i18n';
|
||||||
@@ -95,10 +95,17 @@ export function sync(m) {
|
|||||||
if (!tools)
|
if (!tools)
|
||||||
continue;
|
continue;
|
||||||
// Per server: with several, each changed one has to be brought up again.
|
// Per server: with several, each changed one has to be brought up again.
|
||||||
let mine = uci_section(c, 'network', ifn, 'interface');
|
let created = uci_section(c, 'network', ifn, 'interface');
|
||||||
|
let mine = created, diff = {};
|
||||||
for (let k, v in options(srv))
|
for (let k, v in options(srv))
|
||||||
if (uci_put(c, 'network', ifn, k, v))
|
if (uci_put(c, 'network', ifn, k, v)) {
|
||||||
mine = true;
|
mine = true;
|
||||||
|
diff[k] = v;
|
||||||
|
}
|
||||||
|
if (mine)
|
||||||
|
syslog('info', 'network', `interface ${ifn} (${srv.name}): ${created ? 'created' : 'updated'} · ${opts_text(diff)}`);
|
||||||
|
else
|
||||||
|
syslog('debug', 'network', `interface ${ifn} (${srv.name}): unchanged · ${opts_text(options(srv))}`);
|
||||||
// The markers are saved, but netifd does not read them: a renamed server
|
// The markers are saved, but netifd does not read them: a renamed server
|
||||||
// keeps its tunnel and every session in it.
|
// keeps its tunnel and every session in it.
|
||||||
if (uci_put(c, 'network', ifn, '_dawnline', id))
|
if (uci_put(c, 'network', ifn, '_dawnline', id))
|
||||||
@@ -127,6 +134,7 @@ export function sync(m) {
|
|||||||
});
|
});
|
||||||
for (let ifn in stale) {
|
for (let ifn in stale) {
|
||||||
iface_intent(ifn, 'removed', c.get('network', ifn, '_dawnline_name') ?? ifn);
|
iface_intent(ifn, 'removed', c.get('network', ifn, '_dawnline_name') ?? ifn);
|
||||||
|
syslog('info', 'network', `interface ${ifn} (${c.get('network', ifn, '_dawnline_name') ?? 'a removed server'}): removed, ifdown ${ifn}`);
|
||||||
system(`ifdown ${q(ifn)} 2>/dev/null`);
|
system(`ifdown ${q(ifn)} 2>/dev/null`);
|
||||||
c.delete('network', ifn);
|
c.delete('network', ifn);
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -138,12 +146,14 @@ export function sync(m) {
|
|||||||
}
|
}
|
||||||
// Only the markers changed: nothing for netifd to read (it ignores them, and so does a reload).
|
// Only the markers changed: nothing for netifd to read (it ignores them, and so does a reload).
|
||||||
if (length(touched) || length(stale)) {
|
if (length(touched) || length(stale)) {
|
||||||
|
syslog('info', 'network', 'ubus call network reload');
|
||||||
system('ubus call network reload');
|
system('ubus call network reload');
|
||||||
for (let ifn in touched)
|
for (let ifn in touched)
|
||||||
if (m.servers[c.get('network', ifn, '_dawnline')]?.enabled)
|
if (m.servers[c.get('network', ifn, '_dawnline')]?.enabled) {
|
||||||
|
syslog('info', 'network', `ifup ${ifn}`);
|
||||||
system(`ifup ${q(ifn)}`);
|
system(`ifup ${q(ifn)}`);
|
||||||
|
}
|
||||||
// Each tunnel's own line (restarting, turned off, removed) comes from hotplug.
|
// Each tunnel's own line (restarting, turned off, removed) comes from hotplug.
|
||||||
system(`logger -t dawnline ${q('network updated: ' + join(', ', [ ...touched, ...stale ]))}`);
|
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
// changes often (update, one atomic transaction).
|
// changes often (update, one atomic transaction).
|
||||||
|
|
||||||
import { unlink } from 'fs';
|
import { unlink } from 'fs';
|
||||||
import { sh, ensure_dir, write_file, rand_hex, ip2int, uniq, RUN_DIR } from 'dawnline.util';
|
import { sh, ensure_dir, write_file, rand_hex, ip2int, uniq, read_json, write_json, syslog, syslog_lines, some_of, RUN_DIR } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as net from 'dawnline.net';
|
import * as net from 'dawnline.net';
|
||||||
import * as loop from 'dawnline.loop';
|
import * as loop from 'dawnline.loop';
|
||||||
@@ -14,6 +14,55 @@ import * as loop from 'dawnline.loop';
|
|||||||
export const PRIVATE4 = [ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '100.64.0.0/10', '169.254.0.0/16', '224.0.0.0/3' ];
|
export const PRIVATE4 = [ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '100.64.0.0/10', '169.254.0.0/16', '224.0.0.0/3' ];
|
||||||
/** The sets whose members change at run time (update replaces them together). */
|
/** The sets whose members change at run time (update replaces them together). */
|
||||||
const SETS = [ 'lan_ok', 'lan_all', 'lan_part', 'mesh_pairs', 'inet_ok', 'svc_ok', 'svc_host', 'dns_real' ];
|
const SETS = [ 'lan_ok', 'lan_all', 'lan_part', 'mesh_pairs', 'inet_ok', 'svc_ok', 'svc_host', 'dns_real' ];
|
||||||
|
// The sets' members as last loaded, so a log line can say what changed.
|
||||||
|
const SETS_SEEN = `${RUN_DIR}/nft-sets.json`;
|
||||||
|
|
||||||
|
/** What a table script holds: its chains, its sets and the rules in its chains (for a log line). */
|
||||||
|
export function shape(t) {
|
||||||
|
let n = { chains: 0, sets: 0, rules: 0 }, in_chain = false;
|
||||||
|
for (let l in split(t ?? '', '\n')) {
|
||||||
|
l = trim(l);
|
||||||
|
if (substr(l, 0, 6) == 'chain ') {
|
||||||
|
n.chains++;
|
||||||
|
in_chain = true;
|
||||||
|
}
|
||||||
|
else if (substr(l, 0, 4) == 'set ')
|
||||||
|
n.sets++;
|
||||||
|
else if (in_chain && l == '}')
|
||||||
|
in_chain = false;
|
||||||
|
else if (in_chain && l != '' && substr(l, 0, 5) != 'type ' && substr(l, 0, 7) != 'policy ' && substr(l, 0, 1) != '#')
|
||||||
|
n.rules++;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sets in syslog: info with each set that changed ("inet_ok 3 → 4: +10.8.0.5"),
|
||||||
|
* debug when none did; remembered for the next time.
|
||||||
|
*/
|
||||||
|
function log_sets(sets, how) {
|
||||||
|
let first = read_json(SETS_SEEN, null) == null;
|
||||||
|
let was = read_json(SETS_SEEN, {}), now = {}, diff = [];
|
||||||
|
for (let name in SETS) {
|
||||||
|
let a = uniq(was[name] ?? []), b = uniq(sets[name] ?? []);
|
||||||
|
now[name] = b;
|
||||||
|
let add = filter(b, (x) => index(a, x) < 0), del = filter(a, (x) => index(b, x) < 0);
|
||||||
|
if (length(add) || length(del))
|
||||||
|
push(diff, `${name} ${length(a)} → ${length(b)}${length(add) ? ': +' + some_of(add) : ''}${length(del) ? (length(add) ? ' ' : ': ') + '-' + some_of(del) : ''}`);
|
||||||
|
}
|
||||||
|
write_json(SETS_SEEN, now, 0o600);
|
||||||
|
// The first load since the router started: how many in each set (the members at debug).
|
||||||
|
if (first) {
|
||||||
|
syslog('info', 'nftables', `table inet dawnline: ${how} · ${join(', ', map(SETS, (n) => `${n} ${length(now[n])}`))}`);
|
||||||
|
for (let n in SETS)
|
||||||
|
if (length(now[n]))
|
||||||
|
syslog('debug', 'nftables', `set ${n}: ${join(' ', now[n])}`);
|
||||||
|
}
|
||||||
|
else if (length(diff))
|
||||||
|
syslog('info', 'nftables', `table inet dawnline: ${how} · ${join('; ', diff)}`);
|
||||||
|
else
|
||||||
|
syslog('debug', 'nftables', `table inet dawnline: ${how} · sets unchanged (${join(', ', map(SETS, (n) => `${n} ${length(now[n])}`))})`);
|
||||||
|
}
|
||||||
|
|
||||||
function ip4(a) {
|
function ip4(a) {
|
||||||
return ip2int(a ?? '') != null;
|
return ip2int(a ?? '') != null;
|
||||||
@@ -216,6 +265,13 @@ function table(m, sets, ctx) {
|
|||||||
if (length(ifs))
|
if (length(ifs))
|
||||||
// Home names (and no LAN DNS at all): the plain resolver, whatever address was asked.
|
// Home names (and no LAN DNS at all): the plain resolver, whatever address was asked.
|
||||||
push(t, ` iifname { ${join(', ', ifs)} } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 ${to_resolver}`);
|
push(t, ` iifname { ${join(', ', ifs)} } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 ${to_resolver}`);
|
||||||
|
push(t, ' }');
|
||||||
|
// After the LAN's own DNS interceptors (transparent proxies redirect port 53
|
||||||
|
// at dstnat - 1): only the first NAT of a connection counts, so a DNAT here
|
||||||
|
// first would hand the query to the plain resolver behind their back. When
|
||||||
|
// none of them takes the tunnel, this sends it to the LAN's DNS.
|
||||||
|
push(t, ' chain dns_lan {');
|
||||||
|
push(t, ' type nat hook prerouting priority dstnat + 5; policy accept;');
|
||||||
for (let id, srv in m.servers)
|
for (let id, srv in m.servers)
|
||||||
for (let tn in core.tunnels(srv)) {
|
for (let tn in core.tunnels(srv)) {
|
||||||
// Everyone else: the LAN's DNS, through the netns (from the LAN side) when internet goes that way.
|
// Everyone else: the LAN's DNS, through the netns (from the LAN side) when internet goes that way.
|
||||||
@@ -253,7 +309,17 @@ export function render(m, sets, ctx) {
|
|||||||
|
|
||||||
/** Full table rebuild (structure changes: servers, home networks, DNS paths); null or the error. */
|
/** Full table rebuild (structure changes: servers, home networks, DNS paths); null or the error. */
|
||||||
export function rebuild(m, sets) {
|
export function rebuild(m, sets) {
|
||||||
return load('table inet dawnline\ndelete table inet dawnline\n' + table(m, sets));
|
let t = table(m, sets);
|
||||||
|
let err = load('table inet dawnline\ndelete table inet dawnline\n' + t);
|
||||||
|
if (err) {
|
||||||
|
syslog('error', 'nftables', `table inet dawnline: rebuild failed · ${err}`);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
let n = shape(t);
|
||||||
|
syslog('info', 'nftables', sprintf('table inet dawnline: rebuilt · %d chains, %d sets, %d rules', n.chains, n.sets, n.rules));
|
||||||
|
syslog_lines('debug', 'nftables', t, 'nft: ');
|
||||||
|
log_sets(sets, 'sets loaded with the table');
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,7 +335,12 @@ export function update(sets) {
|
|||||||
if (length(members))
|
if (length(members))
|
||||||
s += `add element inet dawnline ${name} { ${join(', ', members)} }\n`;
|
s += `add element inet dawnline ${name} { ${join(', ', members)} }\n`;
|
||||||
}
|
}
|
||||||
return load(s);
|
let err = load(s);
|
||||||
|
if (err)
|
||||||
|
syslog('warn', 'nftables', `table inet dawnline: set update failed, rebuilding · ${err}`);
|
||||||
|
else
|
||||||
|
log_sets(sets, 'sets updated');
|
||||||
|
return err;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Is the table loaded (watchdog). */
|
/** Is the table loaded (watchdog). */
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// Dawnline — the personal portal.
|
// Dawnline — the personal portal.
|
||||||
//
|
//
|
||||||
// GET /<code> the app shell
|
// GET /<code> the app shell
|
||||||
// GET /<code>/assets/<file> its script, styles and fonts
|
// GET /<code>/assets/<file> its script and styles (gzipped when the browser takes it)
|
||||||
// GET /<code>/api/state
|
// GET /<code>/api/state
|
||||||
// POST /<code>/api/devices { name, kind, public_key?, lan_bypass? }
|
// POST /<code>/api/devices { name, kind, public_key?, lan_bypass? }
|
||||||
// GET /<code>/api/devices/<id>/config
|
// GET /<code>/api/devices/<id>/config
|
||||||
// POST /<code>/api/devices/<id> { action: rename|rotate|delete, name? }
|
// POST /<code>/api/devices/<id> { action: rename|reconnect|bypass|delete, name?, kind?, lan_bypass?, on? }
|
||||||
//
|
//
|
||||||
// The personal link is the key: every request carries its code, there are
|
// The personal link is the key: every request carries its code, there are
|
||||||
// no sessions. Without a valid code every path answers the same bare 404 —
|
// no sessions. Without a valid code every path answers the same bare 404 —
|
||||||
@@ -33,10 +33,11 @@
|
|||||||
// that answers anything not shaped like a link (its not_found() twin).
|
// that answers anything not shaped like a link (its not_found() twin).
|
||||||
|
|
||||||
import { stat, readfile } from 'fs';
|
import { stat, readfile } from 'fs';
|
||||||
import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, VERSION, RUN_DIR } from 'dawnline.util';
|
import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, syslog, VERSION, RUN_DIR } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as awg from 'dawnline.awg';
|
import * as awg from 'dawnline.awg';
|
||||||
import * as live from 'dawnline.live';
|
import * as live from 'dawnline.live';
|
||||||
|
import * as lookup from 'dawnline.lookup';
|
||||||
import * as view from 'dawnline.view';
|
import * as view from 'dawnline.view';
|
||||||
import * as schema from 'dawnline.schema';
|
import * as schema from 'dawnline.schema';
|
||||||
import * as devices from 'dawnline.devices';
|
import * as devices from 'dawnline.devices';
|
||||||
@@ -45,7 +46,7 @@ import { _ } from 'dawnline.i18n';
|
|||||||
|
|
||||||
const RATE = `${RUN_DIR}/portal-rate.json`;
|
const RATE = `${RUN_DIR}/portal-rate.json`;
|
||||||
const ASSETS = '/usr/share/dawnline/portal/assets';
|
const ASSETS = '/usr/share/dawnline/portal/assets';
|
||||||
const TYPES = { js: 'text/javascript', css: 'text/css', svg: 'image/svg+xml', woff2: 'font/woff2', png: 'image/png' };
|
const TYPES = { js: 'text/javascript', css: 'text/css', png: 'image/png' };
|
||||||
const FAIL_LIMIT = 8;
|
const FAIL_LIMIT = 8;
|
||||||
const FAIL_WINDOW = 900;
|
const FAIL_WINDOW = 900;
|
||||||
// All Cloudflare visitors together (three-word codes can't be guessed anyway).
|
// All Cloudflare visitors together (three-word codes can't be guessed anyway).
|
||||||
@@ -263,24 +264,26 @@ function place(r) {
|
|||||||
|
|
||||||
/** The app shell; it reads the code from its own URL and sends it along. */
|
/** The app shell; it reads the code from its own URL and sends it along. */
|
||||||
function shell(r) {
|
function shell(r) {
|
||||||
// The build's time joins the version so every update busts the hour-long asset cache.
|
// The build's time joins the version: every update gives the assets new URLs, so they are cached for good.
|
||||||
let v = `?v=${VERSION}.${stat(`${ASSETS}/portal.js`)?.mtime ?? 0}`;
|
let v = `?v=${VERSION}.${stat(`${ASSETS}/portal.js`)?.mtime ?? 0}`;
|
||||||
let base = r.base, title = place(r);
|
let base = r.base, title = place(r);
|
||||||
|
// The icon goes in the page: a request of its own would start another CGI process.
|
||||||
|
let icon = readfile(`${ASSETS}/icon.svg`);
|
||||||
|
let favicon = icon ? `<link rel="icon" href="data:image/svg+xml;base64,${b64enc(icon)}" type="image/svg+xml">\n` : '';
|
||||||
headers(r, '200 OK', {
|
headers(r, '200 OK', {
|
||||||
'Content-Type': 'text/html; charset=utf-8',
|
'Content-Type': 'text/html; charset=utf-8',
|
||||||
'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; font-src 'self'; " +
|
'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; " +
|
||||||
"connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'",
|
"connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'",
|
||||||
});
|
});
|
||||||
r.io.write(`<!doctype html>
|
r.io.write(`<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
|
||||||
<meta name="color-scheme" content="light dark">
|
<meta name="color-scheme" content="light dark">
|
||||||
<meta name="robots" content="noindex, nofollow">
|
<meta name="robots" content="noindex, nofollow">
|
||||||
<title>${html_escape(title)}</title>
|
<title>${html_escape(title)}</title>
|
||||||
<link rel="icon" href="${base}/assets/icon.svg${v}" type="image/svg+xml">
|
${favicon}<link rel="stylesheet" href="${base}/assets/portal.css${v}">
|
||||||
<link rel="stylesheet" href="${base}/assets/portal.css${v}">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app" data-base="${html_escape(base)}" data-title="${html_escape(title)}"></div>
|
<div id="app" data-base="${html_escape(base)}" data-title="${html_escape(title)}"></div>
|
||||||
@@ -291,13 +294,18 @@ function shell(r) {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Script, styles, icon and fonts (kept outside the web root). */
|
/** Script and styles (kept outside the web root); the shell's ?v= changes with every build, so they never go stale. */
|
||||||
function asset(r, name) {
|
function asset(r, name) {
|
||||||
let ext = match(name, /^[a-z0-9-]+\.(js|css|svg|woff2|png)$/)?.[1];
|
let ext = match(name, /^[a-z0-9-]+\.(js|css|png)$/)?.[1];
|
||||||
let data = ext ? readfile(`${ASSETS}/${name}`) : null;
|
// The build keeps a gzipped copy beside each: a third of the bytes for a browser that takes it.
|
||||||
|
let gz = ext && r.gzip ? readfile(`${ASSETS}/${name}.gz`) : null;
|
||||||
|
let data = gz ?? (ext ? readfile(`${ASSETS}/${name}`) : null);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
not_found(r);
|
not_found(r);
|
||||||
headers(r, '200 OK', { 'Content-Type': TYPES[ext], 'Cache-Control': 'private, max-age=3600' });
|
let h = { 'Content-Type': TYPES[ext], 'Cache-Control': 'private, max-age=31536000, immutable', 'Vary': 'Accept-Encoding' };
|
||||||
|
if (gz != null)
|
||||||
|
h['Content-Encoding'] = 'gzip';
|
||||||
|
headers(r, '200 OK', h);
|
||||||
r.io.write(data);
|
r.io.write(data);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -416,6 +424,17 @@ function api_state(r) {
|
|||||||
send_json(r, '200 OK', state(r));
|
send_json(r, '200 OK', state(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A configuration as the portal sends it: with the server's address as an IP
|
||||||
|
* too (amnezia.host_ip, lookup.host_ip()), for V2RayTun on Android, which
|
||||||
|
* takes no name for AmneziaWG. Lookups are cached for minutes (lookup.uc).
|
||||||
|
*/
|
||||||
|
function with_ip(cfg) {
|
||||||
|
if (cfg?.amnezia)
|
||||||
|
cfg.amnezia.host_ip = lookup.host_ip(cfg.amnezia.host);
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
function api_add(r) {
|
function api_add(r) {
|
||||||
need_open(r);
|
need_open(r);
|
||||||
need_https(r);
|
need_https(r);
|
||||||
@@ -426,7 +445,7 @@ function api_add(r) {
|
|||||||
// lan_bypass: JSON true keeps the device's own local network out of the tunnel; anything else is off.
|
// lan_bypass: JSON true keeps the device's own local network out of the tunnel; anything else is off.
|
||||||
let res = guard(r, () => devices.add(r.person.id, b.name, b.kind, { by: 'portal', public_key: b.public_key, lan_bypass: b.lan_bypass === true }));
|
let res = guard(r, () => devices.add(r.person.id, b.name, b.kind, { by: 'portal', public_key: b.public_key, lan_bypass: b.lan_bypass === true }));
|
||||||
reload(r);
|
reload(r);
|
||||||
send_json(r, '200 OK', { id: res.id, config: res.config, state: state(r) });
|
send_json(r, '200 OK', { id: res.id, config: with_ip(res.config), state: state(r) });
|
||||||
}
|
}
|
||||||
|
|
||||||
function api_config(r, id) {
|
function api_config(r, id) {
|
||||||
@@ -434,7 +453,7 @@ function api_config(r, id) {
|
|||||||
need_open(r);
|
need_open(r);
|
||||||
need_https(r);
|
need_https(r);
|
||||||
awg.mark_issued(r.m, d.id);
|
awg.mark_issued(r.m, d.id);
|
||||||
send_json(r, '200 OK', awg.client_config(r.m, d));
|
send_json(r, '200 OK', with_ip(awg.client_config(r.m, d)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** POST /devices/<id> { action }: what each action does; the answer carries the new state. */
|
/** POST /devices/<id> { action }: what each action does; the answer carries the new state. */
|
||||||
@@ -448,8 +467,20 @@ const ACTIONS = {
|
|||||||
need_https(r);
|
need_https(r);
|
||||||
if (!devices.ready())
|
if (!devices.ready())
|
||||||
fail(r, '503 Service Unavailable', not_ready());
|
fail(r, '503 Service Unavailable', not_ready());
|
||||||
let config = guard(r, () => devices.reconnect(d.id, { by: 'portal', person: r.person.id, defer: d.address == r.peer }));
|
// What it is and LAN Bypass may change with the keys (the sheet asks again); left out, they stay.
|
||||||
return { config };
|
let kind = type(b.kind) == 'string' ? b.kind : null;
|
||||||
|
let bypass = type(b.lan_bypass) == 'bool' ? b.lan_bypass : null;
|
||||||
|
let config = guard(r, () => devices.reconnect(d.id, { by: 'portal', person: r.person.id, defer: d.address == r.peer,
|
||||||
|
kind, lan_bypass: bypass }));
|
||||||
|
return { config: with_ip(config) };
|
||||||
|
},
|
||||||
|
// LAN Bypass on or off, keys unchanged: the device takes its updated configuration (the set-up sheet opens on it).
|
||||||
|
bypass: (r, d, b) => {
|
||||||
|
need_https(r);
|
||||||
|
if (type(b.on) != 'bool')
|
||||||
|
fail(r, '400 Bad Request', _('Unknown action.'));
|
||||||
|
guard(r, () => devices.update(d.id, { lan_bypass: b.on }, { by: 'portal', person: r.person.id }));
|
||||||
|
return {};
|
||||||
},
|
},
|
||||||
'delete': (r, d, b) => {
|
'delete': (r, d, b) => {
|
||||||
guard(r, () => devices.remove(d.id, { by: 'portal', person: r.person.id }));
|
guard(r, () => devices.remove(d.id, { by: 'portal', person: r.person.id }));
|
||||||
@@ -519,6 +550,7 @@ export function handle(io) {
|
|||||||
hsts: https && (match(host, /:([0-9]+)$/)?.[1] ?? '443') == '443',
|
hsts: https && (match(host, /:([0-9]+)$/)?.[1] ?? '443') == '443',
|
||||||
person: null,
|
person: null,
|
||||||
base: '',
|
base: '',
|
||||||
|
gzip: match(lc(header('accept-encoding') ?? ''), /(^|[ ,])gzip([ ;,]|$)/) != null,
|
||||||
};
|
};
|
||||||
let segs = filter(split(path, '/'), (s) => s != '');
|
let segs = filter(split(path, '/'), (s) => s != '');
|
||||||
|
|
||||||
@@ -582,7 +614,11 @@ export function serve(io) {
|
|||||||
handle(io);
|
handle(io);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (e.message != DONE)
|
if (e.message != DONE) {
|
||||||
|
// What broke and where; the path without its first part (the person's link code is a secret).
|
||||||
|
let path = replace(split(io.env.REQUEST_URI ?? '', '?')[0], /^\/[^\/]*/, '/<link>');
|
||||||
|
syslog('error', 'portal', `${io.env.REQUEST_METHOD ?? '?'} ${path}: 500 · ${e.message}${e.stacktrace?.[0]?.context ? ' · ' + replace(e.stacktrace[0].context, /[\r\n\t]+/g, ' ') : ''}`);
|
||||||
io.write(`Status: 500 Internal Server Error\r\nContent-Type: text/plain\r\n\r\nError\n`);
|
io.write(`Status: 500 Internal Server Error\r\nContent-Type: text/plain\r\n\r\nError\n`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { readfile, writefile, stat } from 'fs';
|
import { readfile, writefile, stat } from 'fs';
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
import { ensure_dir, iface_status, uniq } from 'dawnline.util';
|
import { ensure_dir, iface_status, uniq, syslog, syslog_lines } from 'dawnline.util';
|
||||||
import * as net from 'dawnline.net';
|
import * as net from 'dawnline.net';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
|
|
||||||
@@ -90,10 +90,15 @@ export function sync(m, target, lan) {
|
|||||||
for (let d in lan_domain(m))
|
for (let d in lan_domain(m))
|
||||||
push(lines, `server=/${d}/${lan}`);
|
push(lines, `server=/${d}/${lan}`);
|
||||||
let conf = join('\n', lines) + '\n';
|
let conf = join('\n', lines) + '\n';
|
||||||
if ((readfile(CONF) ?? '') == conf)
|
let where = target.mode == 'ns' ? `${target.address}:${target.port} in the netns` : length(ifs) ? `port ${target.port} on ${join(', ', ifs)}` : 'loopback only (no tunnel on)';
|
||||||
|
if ((readfile(CONF) ?? '') == conf) {
|
||||||
|
syslog('debug', 'dns', `resolver for Home-only devices: unchanged · ${where}`);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
writefile(CONF, conf);
|
writefile(CONF, conf);
|
||||||
system(`chmod 644 ${CONF}`);
|
system(`chmod 644 ${CONF}`);
|
||||||
|
syslog('info', 'dns', `resolver for Home-only devices: ${CONF} written · ${where} · upstream ${join(' ', wan_dns()) || 'none'}${lan ? ` · home names via ${lan}` : ''}; restarting it`);
|
||||||
|
syslog_lines('debug', 'dns', conf, 'dnsmasq: ');
|
||||||
let pid = trim(readfile(PID) ?? '');
|
let pid = trim(readfile(PID) ?? '');
|
||||||
if (match(pid, /^[0-9]+$/))
|
if (match(pid, /^[0-9]+$/))
|
||||||
system(`kill ${pid} 2>/dev/null`);
|
system(`kill ${pid} 2>/dev/null`);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import * as view from 'dawnline.view';
|
|||||||
import * as awg from 'dawnline.awg';
|
import * as awg from 'dawnline.awg';
|
||||||
import * as store from 'dawnline.store';
|
import * as store from 'dawnline.store';
|
||||||
import * as devices from 'dawnline.devices';
|
import * as devices from 'dawnline.devices';
|
||||||
|
import * as lookup from 'dawnline.lookup';
|
||||||
import { wrap, str, clamp_days } from 'dawnline.rpc.common';
|
import { wrap, str, clamp_days } from 'dawnline.rpc.common';
|
||||||
import { _ } from 'dawnline.i18n';
|
import { _ } from 'dawnline.i18n';
|
||||||
|
|
||||||
@@ -155,7 +156,13 @@ function device_config(a) {
|
|||||||
die(_('Unknown device.'));
|
die(_('Unknown device.'));
|
||||||
if (a.issue === true)
|
if (a.issue === true)
|
||||||
awg.mark_issued(m, d.id);
|
awg.mark_issued(m, d.id);
|
||||||
return awg.client_config(m, d);
|
let cfg = awg.client_config(m, d);
|
||||||
|
// V2RayTun on Android takes the server by its IP (the admin's set-up shows its link for phones, tablets and
|
||||||
|
// other devices): only where it can connect at all, and AmneziaWG 3.1 (Maximum) is beyond it.
|
||||||
|
let srv = m.servers[m.people[d.person]?.server];
|
||||||
|
if (cfg && d.kind != 'router' && d.kind != 'computer' && srv?.preset != 'max')
|
||||||
|
cfg.amnezia.host_ip = lookup.host_ip(cfg.amnezia.host);
|
||||||
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Name, on/off and the link values (mtu, keepalive: strings, '' = the server's; lan_bypass: true or false). */
|
/** Name, on/off and the link values (mtu, keepalive: strings, '' = the server's; lan_bypass: true or false). */
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// history, updates). What may be saved is dawnline.schema's.
|
// history, updates). What may be saved is dawnline.schema's.
|
||||||
|
|
||||||
import { stat } from 'fs';
|
import { stat } from 'fs';
|
||||||
import { q, sh_out, admin_log, RUN_DIR, DATA_DIR } from 'dawnline.util';
|
import { q, sh_out, admin_log, syslog, RUN_DIR, DATA_DIR } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as live from 'dawnline.live';
|
import * as live from 'dawnline.live';
|
||||||
import * as apply from 'dawnline.apply';
|
import * as apply from 'dawnline.apply';
|
||||||
@@ -96,16 +96,25 @@ function settings_update(a) {
|
|||||||
die(_('Nothing to save.'));
|
die(_('Nothing to save.'));
|
||||||
let res = store.transact((c, m) => {
|
let res = store.transact((c, m) => {
|
||||||
let restart = false;
|
let restart = false;
|
||||||
|
// What each key was and became, as uci holds them (for syslog: every change, not only those worth a line).
|
||||||
|
let diff = [];
|
||||||
|
let note = (k, to) => {
|
||||||
|
let from = c.get(core.CONFIG, 'settings', k);
|
||||||
|
if (!same(to, from))
|
||||||
|
push(diff, { k, from, to });
|
||||||
|
};
|
||||||
c.set(core.CONFIG, 'settings', 'settings');
|
c.set(core.CONFIG, 'settings', 'settings');
|
||||||
for (let k, val in v) {
|
for (let k, val in v) {
|
||||||
if (k == 'log_category') {
|
if (k == 'log_category') {
|
||||||
let lst = filter(type(val) == 'array' ? val : [], (x) => index(live.CATEGORIES, x) >= 0);
|
let lst = filter(type(val) == 'array' ? val : [], (x) => index(live.CATEGORIES, x) >= 0);
|
||||||
|
note(k, length(lst) ? lst : [ '' ]);
|
||||||
c.set(core.CONFIG, 'settings', 'log_category', length(lst) ? lst : [ '' ]);
|
c.set(core.CONFIG, 'settings', 'log_category', length(lst) ? lst : [ '' ]);
|
||||||
// Superseded by the category list.
|
// Superseded by the category list.
|
||||||
c.delete(core.CONFIG, 'settings', 'log_connections');
|
c.delete(core.CONFIG, 'settings', 'log_connections');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let nv = schema.validate(k, val);
|
let nv = schema.validate(k, val);
|
||||||
|
note(k, nv);
|
||||||
if (schema.SETTINGS[k].restart && !same(nv, c.get(core.CONFIG, 'settings', k)))
|
if (schema.SETTINGS[k].restart && !same(nv, c.get(core.CONFIG, 'settings', k)))
|
||||||
restart = true;
|
restart = true;
|
||||||
if (nv == null)
|
if (nv == null)
|
||||||
@@ -114,8 +123,13 @@ function settings_update(a) {
|
|||||||
c.set(core.CONFIG, 'settings', k, nv);
|
c.set(core.CONFIG, 'settings', k, nv);
|
||||||
}
|
}
|
||||||
check_portal(core.load(c), m);
|
check_portal(core.load(c), m);
|
||||||
return { restart, was: m.settings };
|
return { restart, was: m.settings, diff };
|
||||||
});
|
});
|
||||||
|
// Every setting that changed, in syslog: "admin changed settings · log_keep_days: 30 → 90, domain: lan → home".
|
||||||
|
if (length(res.diff)) {
|
||||||
|
let val = (x) => x == null || x == '' ? 'default' : type(x) == 'array' ? join(' ', filter(x, (y) => y != '')) || 'none' : `${x}`;
|
||||||
|
syslog('info', 'settings', `admin changed settings · ${join(', ', map(res.diff, (d) => `${d.k}: ${val(d.from)} → ${val(d.to)}`))}`);
|
||||||
|
}
|
||||||
let s = null;
|
let s = null;
|
||||||
if (res.restart)
|
if (res.restart)
|
||||||
system('/etc/init.d/dawnline reload >/dev/null 2>&1');
|
system('/etc/init.d/dawnline reload >/dev/null 2>&1');
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function releases(a) {
|
|||||||
let page = +(a.page ?? 1);
|
let page = +(a.page ?? 1);
|
||||||
if (page != int(page) || page < 1 || page > 50)
|
if (page != int(page) || page < 1 || page > 50)
|
||||||
die(_('Unknown page.'));
|
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. */
|
/** 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}`);
|
r = gh.release(rp, `v${tag}`);
|
||||||
if (!r)
|
if (!r)
|
||||||
die(sprintf(_('No release %s in %s.'), tag, rp));
|
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). */
|
/** 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,
|
* 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.
|
* (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) {
|
function run(a) {
|
||||||
let what = a.what ?? 'check';
|
let what = a.what ?? 'check';
|
||||||
@@ -126,16 +128,17 @@ function run(a) {
|
|||||||
if (upd.busy())
|
if (upd.busy())
|
||||||
die(_('Another component action is already running'));
|
die(_('Another component action is already running'));
|
||||||
ensure_dir(RUN_DIR);
|
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}`;
|
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).
|
// The job speaks the admin's language (use() let only a plain language code through).
|
||||||
let lang = i18n.current();
|
let lang = i18n.current();
|
||||||
system(`${lang ? `DAWNLINE_LANG=${lang} ` : ''}start-stop-daemon -S -b -x /usr/libexec/dawnline/updater -- ${args}`);
|
system(`${lang ? `DAWNLINE_LANG=${lang} ` : ''}start-stop-daemon -S -b -x /usr/libexec/dawnline/updater -- ${args}`);
|
||||||
for (let i = 0; i < 20; i++) {
|
for (let i = 0; i < 20; i++) {
|
||||||
let j = read_json(upd.JOB_FILE, null);
|
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 };
|
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 };
|
return { started: true, job: null };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ export const SETTINGS = {
|
|||||||
geo_enabled: { type: 'bool', dflt: false },
|
geo_enabled: { type: 'bool', dflt: false },
|
||||||
geo_provider: { type: 'enum', dflt: 'ipwho.is', values: [ 'ipwho.is', 'ipapi.co' ] },
|
geo_provider: { type: 'enum', dflt: 'ipwho.is', values: [ 'ipwho.is', 'ipapi.co' ] },
|
||||||
log_connections: { type: 'bool', dflt: true },
|
log_connections: { type: 'bool', dflt: true },
|
||||||
|
// What goes to syslog (dawnline.util syslog): error | warn | info | debug (each step of a start or an apply).
|
||||||
|
log_level: { type: 'enum', dflt: 'info', values: [ 'error', 'warn', 'info', 'debug' ] },
|
||||||
watchdog: { type: 'bool', dflt: true },
|
watchdog: { type: 'bool', dflt: true },
|
||||||
log_keep_days: { type: 'int', dflt: 30, min: 0, max: 9999 },
|
log_keep_days: { type: 'int', dflt: 30, min: 0, max: 9999 },
|
||||||
log_max: { type: 'int', dflt: 2000, min: 100, max: 20000 },
|
log_max: { type: 'int', dflt: 2000, min: 100, max: 20000 },
|
||||||
@@ -158,6 +160,7 @@ function messages() {
|
|||||||
default_device_limit: _('Default device limit must be 1-32.'),
|
default_device_limit: _('Default device limit must be 1-32.'),
|
||||||
domain: _('Domain may use lowercase letters, digits, dashes and dots.'),
|
domain: _('Domain may use lowercase letters, digits, dashes and dots.'),
|
||||||
geo_provider: _('Unknown location service.'),
|
geo_provider: _('Unknown location service.'),
|
||||||
|
log_level: _('Choose a system log level: errors, warnings, normal or verbose.'),
|
||||||
log_keep_days: _('Keep activity for 0 (no age limit) to 9999 days.'),
|
log_keep_days: _('Keep activity for 0 (no age limit) to 9999 days.'),
|
||||||
log_max: _('Log size must be 100-20000 events.'),
|
log_max: _('Log size must be 100-20000 events.'),
|
||||||
log_persist: _('Save the log every 10min, hourly or off.'),
|
log_persist: _('Save the log every 10min, hourly or off.'),
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function check(ctx) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The sha256 a release publishes for a file: GitHub's own (API), else the
|
* 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) {
|
function want_sha(ctx, tag, asset, dir) {
|
||||||
let want = gh.asset_sha256(REPO, tag, asset);
|
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 { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||||
import { _ } from 'dawnline.i18n';
|
import { _ } from 'dawnline.i18n';
|
||||||
|
|
||||||
export const VERSION = '0.14.1';
|
export const VERSION = '0.18.0';
|
||||||
/** GitHub repository with Dawnline releases (updates and the installer). */
|
/** GitHub repository with Dawnline releases (updates and the installer). */
|
||||||
export const REPO = 'tickcount/luci-app-dawnline';
|
export const REPO = 'tickcount/luci-app-dawnline';
|
||||||
export const RUN_DIR = '/var/run/dawnline';
|
export const RUN_DIR = '/var/run/dawnline';
|
||||||
@@ -226,6 +226,96 @@ export function ack_config(confs) {
|
|||||||
writefile(md5f, join('\n', lines) + '\n');
|
writefile(md5f, join('\n', lines) + '\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ---------- syslog ---------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Every line Dawnline puts in syslog, as podkop and sing-box do it:
|
||||||
|
* dawnline: [info] [awg] Home started · accepting connections on port 51820
|
||||||
|
* with the matching priority (daemon.err, .warning, .info, .debug), so
|
||||||
|
* `logread -e dawnline` or a remote syslog filters by level. The admin's
|
||||||
|
* level (settings.log_level) decides what goes out: error | warn | info
|
||||||
|
* (the default) | debug (each step of a start or an apply).
|
||||||
|
*/
|
||||||
|
const LOG_RANK = { error: 0, warn: 1, info: 2, debug: 3 };
|
||||||
|
const LOG_PRIO = { error: 'err', warn: 'warning', info: 'info', debug: 'debug' };
|
||||||
|
const LOG_LEVEL_RE = regexp("option log_level '?(error|warn|info|debug)'?");
|
||||||
|
// The level as last read, and the config file's mtime it was read at (a long-running agent sees a change).
|
||||||
|
let log_cfg = { mtime: -1, level: 'info' };
|
||||||
|
|
||||||
|
/** The admin's syslog level (settings.log_level): error | warn | info | debug; info when not set. */
|
||||||
|
export function log_level() {
|
||||||
|
let mt = stat('/etc/config/dawnline')?.mtime ?? 0;
|
||||||
|
if (mt != log_cfg.mtime) {
|
||||||
|
let m = match(readfile('/etc/config/dawnline') ?? '', LOG_LEVEL_RE);
|
||||||
|
log_cfg = { mtime: mt, level: m?.[1] ?? 'info' };
|
||||||
|
}
|
||||||
|
return log_cfg.level;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Does a line at `level` go out at the admin's level? */
|
||||||
|
export function log_on(level) {
|
||||||
|
return (LOG_RANK[level] ?? 2) <= LOG_RANK[log_level()];
|
||||||
|
};
|
||||||
|
|
||||||
|
// A line break or a tab with the blanks around it: one space in a syslog line (compiled once, syslog runs often).
|
||||||
|
const LOG_BREAK = /[ \t\r\n]*[\t\r\n][ \t\r\n]*/g;
|
||||||
|
|
||||||
|
/** One syslog line's words: "[level] [src] line", on one line, at most 1000 characters. */
|
||||||
|
export function syslog_line(level, src, line) {
|
||||||
|
let one = replace(trim(`${line ?? ''}`), LOG_BREAK, ' ');
|
||||||
|
return substr(`[${LOG_RANK[level] != null ? level : 'info'}] [${src ?? 'dawnline'}] ${one}`, 0, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A line in syslog at `level` (error | warn | info | debug) from `src`
|
||||||
|
* (dawnline, awg, portal, apply, agent, service, settings, people, …), when
|
||||||
|
* the admin's level takes it. Nothing is kept anywhere else: what the admin UI
|
||||||
|
* shows goes through slog() below, which calls this too.
|
||||||
|
*/
|
||||||
|
export function syslog(level, src, line) {
|
||||||
|
if (!log_on(level))
|
||||||
|
return;
|
||||||
|
system(`logger -t dawnline -p daemon.${LOG_PRIO[level] ?? 'info'} ${q(syslog_line(level, src, line))}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Option names whose values never go in a log line: private, preshared and header-protection keys.
|
||||||
|
const SECRET_OPT = /(private|preshared|protection)_?key/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options as a log line's words: "listen_port=51820, addresses=10.8.0.1/24,
|
||||||
|
* private_key=***" (arrays joined with spaces, null as "-", secrets masked).
|
||||||
|
*/
|
||||||
|
export function opts_text(o) {
|
||||||
|
let out = [];
|
||||||
|
for (let k, v in o ?? {}) {
|
||||||
|
let s = v == null ? '-' : type(v) == 'array' ? join(' ', v) : `${v}`;
|
||||||
|
push(out, `${k}=${match(k, SECRET_OPT) ? '***' : s}`);
|
||||||
|
}
|
||||||
|
return join(', ', out);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A block of text in syslog, a line per line (an nft script, a peer list),
|
||||||
|
* each "[level] [src] <prefix><line>": one logger for all of them.
|
||||||
|
*/
|
||||||
|
export function syslog_lines(level, src, text, prefix) {
|
||||||
|
if (!log_on(level) || trim(`${text ?? ''}`) == '')
|
||||||
|
return;
|
||||||
|
let p = popen(`logger -t dawnline -p daemon.${LOG_PRIO[level] ?? 'info'}`, 'w');
|
||||||
|
if (!p)
|
||||||
|
return;
|
||||||
|
for (let l in split(`${text ?? ''}`, '\n'))
|
||||||
|
if (trim(l) != '')
|
||||||
|
p.write(syslog_line(level, src, `${prefix ?? ''}${trim(l)}`) + '\n');
|
||||||
|
p.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
/** A list in a log line: the first `n` (10) and how many more ("a, b, c and 12 more"). */
|
||||||
|
export function some_of(list, n) {
|
||||||
|
n ??= 10;
|
||||||
|
return length(list) <= n ? join(', ', list) : `${join(', ', slice(list, 0, n))} and ${length(list) - n} more`;
|
||||||
|
};
|
||||||
|
|
||||||
/* ---------- service log ---------- */
|
/* ---------- service log ---------- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -257,7 +347,11 @@ export function slog(src, level, msg, detail, who, extra) {
|
|||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
let line = e.by == 'admin' ? join(' ', filter([ 'admin', msg, e.kind, who, e.note ? '· ' + e.note : null ], (x) => x)) : who ? `${who} ${msg}` : msg;
|
let line = e.by == 'admin' ? join(' ', filter([ 'admin', msg, e.kind, who, e.note ? '· ' + e.note : null ], (x) => x)) : who ? `${who} ${msg}` : msg;
|
||||||
system(`logger -t dawnline${level == 'error' ? ' -p user.err' : ''} ${q(line)}`);
|
// Problems carry what went wrong (the service log's detail: an error's text, the syslog lines around a crash).
|
||||||
|
let lvl = { error: 'error', repair: 'warn', down: 'warn' }[level] ?? 'info';
|
||||||
|
if (e.detail && lvl != 'info')
|
||||||
|
line += ` · ${substr(replace(e.detail, /[\r\n\t]+/g, ' | '), 0, 400)}`;
|
||||||
|
syslog(lvl, src, line);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A change the admin made in LuCI, for the service log. */
|
/** A change the admin made in LuCI, for the service log. */
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ Read with `code-standards.md` and, for anything visible, `ui-design.md` and `i18
|
|||||||
|
|
||||||
## Checks
|
## Checks
|
||||||
|
|
||||||
- In `web/`: `npm run format:check`, `npm run typecheck`, `npm run i18n:check`, `npm test`, `npm run build`; the rebuilt bundles under `package/` and the catalogs are committed (CI fails otherwise).
|
- In `web/`: `npm run format:check`, `npm run typecheck`, `npm run lint`, `npm run knip`, `npm run i18n:check`, `npm test`, `npm run build`; the catalogs are committed, the bundles under `package/` are git-ignored (CI builds them before packaging).
|
||||||
@@ -17,6 +17,11 @@ APK_SDK="${APK_SDK:-itdoginfo/openwrt-sdk-apk:25.12.3}"
|
|||||||
grep -q "^export const VERSION = '$VERSION';" "$APP/root/usr/share/ucode/dawnline/util.uc" || { echo "util.uc VERSION != $VERSION" >&2; exit 1; }
|
grep -q "^export const VERSION = '$VERSION';" "$APP/root/usr/share/ucode/dawnline/util.uc" || { echo "util.uc VERSION != $VERSION" >&2; exit 1; }
|
||||||
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
||||||
|
|
||||||
|
# The web bundles are not committed: web/ builds them (npm run build).
|
||||||
|
for f in htdocs/luci-static/resources/dawnline/app.js root/usr/share/dawnline/portal/assets/portal.js root/usr/share/dawnline/portal/assets/portal.css; do
|
||||||
|
[ -f "$APP/$f" ] || { echo "$APP/$f is missing: run 'npm run build' in web/" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
mkdir -p "$OUT"
|
mkdir -p "$OUT"
|
||||||
build() {
|
build() {
|
||||||
local type="$1" sdk="$2" tag="dawnline-build:$1"
|
local type="$1" sdk="$2" tag="dawnline-build:$1"
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ grep -q "PKG_VERSION:=$VERSION\$" "$APP/Makefile" || { echo "Makefile PKG_VERSIO
|
|||||||
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
||||||
|
|
||||||
[ "${SKIP_WEB:-0}" = 1 ] || (cd "$ROOT/web" && npm run --silent ci)
|
[ "${SKIP_WEB:-0}" = 1 ] || (cd "$ROOT/web" && npm run --silent ci)
|
||||||
|
# With SKIP_WEB=1 the bundles come from an earlier build (they are not committed).
|
||||||
|
for f in htdocs/luci-static/resources/dawnline/app.js root/usr/share/dawnline/portal/assets/portal.js root/usr/share/dawnline/portal/assets/portal.css; do
|
||||||
|
[ -f "$APP/$f" ] || { echo "$APP/$f is missing: run 'npm run build' in web/" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
mkdir -p "$STAGE/www" "$OUT"
|
mkdir -p "$STAGE/www" "$OUT"
|
||||||
cp -R "$APP/root/." "$STAGE/"
|
cp -R "$APP/root/." "$STAGE/"
|
||||||
|
|||||||
@@ -133,13 +133,14 @@ const prelude = (lang, db) => `(() => {
|
|||||||
});
|
});
|
||||||
addEventListener('DOMContentLoaded', () => {
|
addEventListener('DOMContentLoaded', () => {
|
||||||
const s = document.createElement('style');
|
const s = document.createElement('style');
|
||||||
// The demo's chip and GitHub pill go, and the path takes the row again, as on a router's page.
|
// The demo's chip, GitHub knob and set-up state switch go, and the path takes the row again, as on a router's
|
||||||
s.textContent = '.dm-chip, .dm-gh { display: none !important; } .cr-path { flex: 1 !important; }';
|
// page.
|
||||||
|
s.textContent = '.dm-chip, .dm-gh, .dm-way { display: none !important; } .cr-path { flex: 1 !important; }';
|
||||||
document.head.append(s);
|
document.head.append(s);
|
||||||
});
|
});
|
||||||
})()`;
|
})()`;
|
||||||
|
|
||||||
const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.svg': 'image/svg+xml', '.woff2': 'font/woff2' };
|
const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.svg': 'image/svg+xml' };
|
||||||
|
|
||||||
/** Answer the page's requests from the demo build: its page for the personal link, its files by name. */
|
/** Answer the page's requests from the demo build: its page for the personal link, its files by name. */
|
||||||
async function serve(page) {
|
async function serve(page) {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ for (const [real, shown] of args.names)
|
|||||||
args.mask.push([real, shown], [real.toLowerCase(), shown.toLowerCase()], [real.toUpperCase(), shown.toUpperCase()]);
|
args.mask.push([real, shown], [real.toLowerCase(), shown.toLowerCase()], [real.toUpperCase(), shown.toUpperCase()]);
|
||||||
const INITIALS = args.names.map(([real, shown]) => [initials(real), initials(shown)]);
|
const INITIALS = args.names.map(([real, shown]) => [initials(real), initials(shown)]);
|
||||||
|
|
||||||
const LUCI = `${args.router}/cgi-bin/luci/admin/network/dawnline`;
|
const LUCI = `${args.router}/cgi-bin/luci/admin/services/dawnline`;
|
||||||
const USER = process.env.LUCI_USER || 'root';
|
const USER = process.env.LUCI_USER || 'root';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import tempfile
|
|||||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
RAW = os.path.join(ROOT, 'docs', 'screenshots', 'raw')
|
RAW = os.path.join(ROOT, 'docs', 'screenshots', 'raw')
|
||||||
OUT = os.path.join(ROOT, 'docs', 'screenshots')
|
OUT = os.path.join(ROOT, 'docs', 'screenshots')
|
||||||
FONT = os.path.join(ROOT, 'package', 'luci-app-dawnline', 'root', 'usr', 'share', 'dawnline', 'portal', 'assets',
|
|
||||||
'geist-latin-wght-normal.woff2')
|
|
||||||
|
|
||||||
SHOTS = ['overview', 'people', 'person', 'portal', 'overview-ru', 'people-ru', 'person-ru', 'portal-ru']
|
SHOTS = ['overview', 'people', 'person', 'portal', 'overview-ru', 'people-ru', 'person-ru', 'portal-ru']
|
||||||
# name -> the steps in front of its page, in order (raw captures). The portal's come from its demo
|
# name -> the steps in front of its page, in order (raw captures). The portal's come from its demo
|
||||||
@@ -47,7 +45,6 @@ CANDIDATES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
TEMPLATE = """<!doctype html><html><head><meta charset="utf-8"><style>
|
TEMPLATE = """<!doctype html><html><head><meta charset="utf-8"><style>
|
||||||
@font-face{{font-family:Geist;src:url('file://{font}') format('woff2');font-weight:100 900}}
|
|
||||||
html,body{{margin:0;width:{w}px;height:{h}px;overflow:hidden}}
|
html,body{{margin:0;width:{w}px;height:{h}px;overflow:hidden}}
|
||||||
body{{position:relative;background:#080808}}
|
body{{position:relative;background:#080808}}
|
||||||
.panel{{position:absolute;left:{px}px;top:{py}px;width:{pw}px;height:{ph}px;
|
.panel{{position:absolute;left:{px}px;top:{py}px;width:{pw}px;height:{ph}px;
|
||||||
@@ -56,7 +53,7 @@ body{{position:relative;background:#080808}}
|
|||||||
box-shadow:0 0 0 1px rgba(255,255,255,.04)}}
|
box-shadow:0 0 0 1px rgba(255,255,255,.04)}}
|
||||||
.sheet{{position:absolute;display:block;filter:drop-shadow(0 24px 48px rgba(0,0,0,.6))}}
|
.sheet{{position:absolute;display:block;filter:drop-shadow(0 24px 48px rgba(0,0,0,.6))}}
|
||||||
.n{{position:absolute;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
|
.n{{position:absolute;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
|
||||||
font:600 16px Geist,sans-serif;color:#ededed;background:#232323;
|
font:600 16px system-ui,-apple-system,sans-serif;color:#ededed;background:#232323;
|
||||||
box-shadow:0 0 0 1px rgba(255,255,255,.12),0 6px 16px rgba(0,0,0,.5)}}
|
box-shadow:0 0 0 1px rgba(255,255,255,.12),0 6px 16px rgba(0,0,0,.5)}}
|
||||||
</style></head><body><div class="panel"></div><img class="page" src="file://{src}">{steps}</body></html>"""
|
</style></head><body><div class="panel"></div><img class="page" src="file://{src}">{steps}</body></html>"""
|
||||||
|
|
||||||
@@ -113,7 +110,7 @@ def main():
|
|||||||
html = os.path.join(tmp, f'{name}.html')
|
html = os.path.join(tmp, f'{name}.html')
|
||||||
with open(html, 'w', encoding='utf-8') as f:
|
with open(html, 'w', encoding='utf-8') as f:
|
||||||
f.write(TEMPLATE.format(w=w, h=h, x=x, y=y, iw=iw, ih=ih, px=x - INSET, py=y - INSET, pw=iw + 2 * INSET,
|
f.write(TEMPLATE.format(w=w, h=h, x=x, y=y, iw=iw, ih=ih, px=x - INSET, py=y - INSET, pw=iw + 2 * INSET,
|
||||||
ph=ih + 2 * INSET, src=src, font=FONT, steps=steps))
|
ph=ih + 2 * INSET, src=src, steps=steps))
|
||||||
out = os.path.join(OUT, f'{name}.png')
|
out = os.path.join(OUT, f'{name}.png')
|
||||||
subprocess.run([browser, '--headless=new', '--disable-gpu', '--hide-scrollbars', '--allow-file-access-from-files',
|
subprocess.run([browser, '--headless=new', '--disable-gpu', '--hide-scrollbars', '--allow-file-access-from-files',
|
||||||
f'--force-device-scale-factor={SCALE}', f'--window-size={w},{h}', f'--screenshot={out}', f'file://{html}'],
|
f'--force-device-scale-factor={SCALE}', f'--window-size={w},{h}', f'--screenshot={out}', f'file://{html}'],
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ Install or upgrade on the router (OpenWrt 24.10 with opkg, or 25.12 with apk):
|
|||||||
sh -c "\$(wget -qO- https://raw.githubusercontent.com/$REPO/main/install.sh)"
|
sh -c "\$(wget -qO- https://raw.githubusercontent.com/$REPO/main/install.sh)"
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
Or update from LuCI → Network → Dawnline → Components.
|
Or update from LuCI → Services → Dawnline → Components.
|
||||||
EOF
|
EOF
|
||||||
if [ -n "$PREV" ]; then
|
if [ -n "$PREV" ]; then
|
||||||
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$REPO" "$PREV" "$TAG"
|
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$REPO" "$PREV" "$TAG"
|
||||||
|
|||||||
@@ -154,6 +154,18 @@ function recorder() {
|
|||||||
return { w, c: { set: (cfg, s, k, v) => { w[`${s}.${k}`] = v; }, delete: (cfg, s, k) => { w[`${s}.${k}`] = null; } } };
|
return { w, c: { set: (cfg, s, k, v) => { w[`${s}.${k}`] = v; }, delete: (cfg, s, k) => { w[`${s}.${k}`] = null; } } };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test('set_device_kind', () => {
|
||||||
|
let mm = { devices: { d: { id: 'd', kind: 'phone' } } };
|
||||||
|
let r = recorder();
|
||||||
|
eq(core.set_device_kind(r.c, mm, 'd', 'tablet'), true, 'changed');
|
||||||
|
eq([ r.w, mm.devices.d.kind ], [ { 'd.kind': 'tablet' }, 'tablet' ], 'written, and the model follows');
|
||||||
|
r = recorder();
|
||||||
|
eq(core.set_device_kind(r.c, mm, 'd', 'tablet'), false, 'the same kind changes nothing');
|
||||||
|
eq(r.w, {}, 'nothing written');
|
||||||
|
throws(() => core.set_device_kind(r.c, mm, 'd', 'toaster'), /^Unknown device type\.$/, 'not a kind');
|
||||||
|
throws(() => core.set_device_kind(r.c, mm, 'x', 'phone'), /^Unknown device\.$/, 'unknown device');
|
||||||
|
});
|
||||||
|
|
||||||
test('set_device_link', () => {
|
test('set_device_link', () => {
|
||||||
let mm = { devices: { d: { id: 'd', mtu: 0, keepalive: null, lan_bypass: false } } };
|
let mm = { devices: { d: { id: 'd', mtu: 0, keepalive: null, lan_bypass: false } } };
|
||||||
let r = recorder();
|
let r = recorder();
|
||||||
|
|||||||
@@ -4,14 +4,16 @@
|
|||||||
// sync's nft and awg steps fail harmlessly in the container. /etc/config/dawnline
|
// sync's nft and awg steps fail harmlessly in the container. /etc/config/dawnline
|
||||||
// and the issued and reconnect marks are put back after.
|
// and the issued and reconnect marks are put back after.
|
||||||
import { readfile, writefile, unlink } from 'fs';
|
import { readfile, writefile, unlink } from 'fs';
|
||||||
import { DATA_DIR, ensure_dir } from 'dawnline.util';
|
import { DATA_DIR, RUN_DIR, ensure_dir } from 'dawnline.util';
|
||||||
import * as core from 'dawnline.core';
|
import * as core from 'dawnline.core';
|
||||||
import * as awg from 'dawnline.awg';
|
import * as awg from 'dawnline.awg';
|
||||||
import * as people from 'dawnline.rpc.people';
|
import * as people from 'dawnline.rpc.people';
|
||||||
|
import * as devices from 'dawnline.devices';
|
||||||
|
|
||||||
const CONFIG = '/etc/config/dawnline';
|
const CONFIG = '/etc/config/dawnline';
|
||||||
const ISSUED = `${DATA_DIR}/issued.json`;
|
const ISSUED = `${DATA_DIR}/issued.json`;
|
||||||
const RECONNECT = `${DATA_DIR}/reconnect.json`;
|
const RECONNECT = `${DATA_DIR}/reconnect.json`;
|
||||||
|
const EVENTS = `${RUN_DIR}/events.json`;
|
||||||
|
|
||||||
// fn(), then the files as they were, whatever fn did.
|
// fn(), then the files as they were, whatever fn did.
|
||||||
function kept(paths, fn) {
|
function kept(paths, fn) {
|
||||||
@@ -65,3 +67,20 @@ test('device_rotate: New keys set the device up again', () => {
|
|||||||
});
|
});
|
||||||
eq(core.load().devices.alice_phone.private_key, '', 'the fixture is back');
|
eq(core.load().devices.alice_phone.private_key, '', 'the fixture is back');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('portal: Reconnect changes what it is and LAN Bypass with the keys; LAN Bypass alone keeps them', () => {
|
||||||
|
ensure_dir(RUN_DIR);
|
||||||
|
kept([ CONFIG, ISSUED, RECONNECT, EVENTS ], () => {
|
||||||
|
let mine = { by: 'portal', person: 'alice' };
|
||||||
|
devices.reconnect('alice_phone', { ...mine, kind: 'tablet', lan_bypass: true });
|
||||||
|
let d = core.load().devices.alice_phone;
|
||||||
|
eq([ d.kind, d.lan_bypass ], [ 'tablet', true ], 'changed in the same write as the keys');
|
||||||
|
let keys = d.public_key;
|
||||||
|
devices.update('alice_phone', { lan_bypass: false }, mine);
|
||||||
|
d = core.load().devices.alice_phone;
|
||||||
|
eq([ d.lan_bypass, d.public_key ], [ false, keys ], 'LAN Bypass off, the keys as they were');
|
||||||
|
throws(() => devices.update('alice_phone', { mtu: '1400' }, mine), /^Only the admin can change how a device connects\.$/, "the MTU stays the admin's");
|
||||||
|
throws(() => devices.reconnect('alice_phone', { ...mine, kind: 'toaster' }), /^Unknown device type\.$/, 'not a kind');
|
||||||
|
throws(() => devices.update('alice_phone', { lan_bypass: true }, { by: 'portal', person: 'bob' }), /^Device not found\.$/, "another person's device");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -51,6 +51,9 @@ table inet dawnline {
|
|||||||
chain dns {
|
chain dns {
|
||||||
type nat hook prerouting priority dstnat - 5; policy accept;
|
type nat hook prerouting priority dstnat - 5; policy accept;
|
||||||
iifname { "awghome", "awgwork" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 dnat ip to 169.254.77.2:53
|
iifname { "awghome", "awgwork" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 dnat ip to 169.254.77.2:53
|
||||||
|
}
|
||||||
|
chain dns_lan {
|
||||||
|
type nat hook prerouting priority dstnat + 5; policy accept;
|
||||||
iifname "awghome" ip daddr 10.9.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.250:53
|
iifname "awghome" ip daddr 10.9.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.250:53
|
||||||
iifname "awgwork" ip daddr 10.9.1.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.1:53
|
iifname "awgwork" ip daddr 10.9.1.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.1.1:53
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// dawnline.github: which URLs are a release's files (those can come through
|
||||||
|
// the API instead of github.com's redirect) and the points of a commit message.
|
||||||
|
import * as gh from 'dawnline.github';
|
||||||
|
|
||||||
|
test('release_file', () => {
|
||||||
|
eq(gh.release_file('https://github.com/tickcount/luci-app-dawnline/releases/download/v0.16.0/sha256sums.txt'),
|
||||||
|
{ repo: 'tickcount/luci-app-dawnline', tag: 'v0.16.0', name: 'sha256sums.txt' }, 'a Dawnline release file');
|
||||||
|
eq(gh.release_file('https://github.com/Slava-Shchipunov/awg-openwrt/releases/download/v24.10.4/kmod-amneziawg_v24.10.4_aarch64_cortex-a53_mediatek_filogic.ipk'),
|
||||||
|
{ repo: 'Slava-Shchipunov/awg-openwrt', tag: 'v24.10.4', name: 'kmod-amneziawg_v24.10.4_aarch64_cortex-a53_mediatek_filogic.ipk' },
|
||||||
|
'an AmneziaWG build');
|
||||||
|
eq(gh.release_file('https://ghfast.top/https://github.com/tickcount/luci-app-dawnline/releases/download/v0.16.0/a.ipk'), null, 'a mirror');
|
||||||
|
eq(gh.release_file('https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh'), null, 'not a release file');
|
||||||
|
eq(gh.release_file('https://github.com/tickcount/luci-app-dawnline/releases/latest'), null, 'the latest redirect');
|
||||||
|
eq(gh.release_file('https://github.com/a/b/releases/download/v1/x.ipk?raw=1'), null, 'a query');
|
||||||
|
eq(gh.release_file('https://github.com/a/b/releases/download/v1/sub/x.ipk'), null, 'a deeper path');
|
||||||
|
eq(gh.release_file(null), null, 'nothing');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('points', () => {
|
||||||
|
eq(gh.points('Dawnline 0.16.0\n\n- Check no longer times out\n- Downloads without curl\n go through the API'),
|
||||||
|
[ 'Check no longer times out', 'Downloads without curl go through the API' ], 'a release commit, a wrapped point');
|
||||||
|
eq(gh.points('Fix the portal'), [ 'Fix the portal' ], 'another commit: its title');
|
||||||
|
eq(gh.points('Dawnline 0.16.0'), [], 'a bare release title');
|
||||||
|
eq(gh.points('Merge branch x\n\n- y'), [], 'a merge');
|
||||||
|
});
|
||||||
@@ -180,3 +180,15 @@ test('add_event_merged: per device', () => {
|
|||||||
eq(live.category_of('device_recovered'), 'problems', 'and so is its end');
|
eq(live.category_of('device_recovered'), 'problems', 'and so is its end');
|
||||||
had == null ? unlink(path) : writefile(path, had);
|
had == null ? unlink(path) : writefile(path, had);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('event_level and event_line: the system\'s events in syslog', () => {
|
||||||
|
eq(live.event_level({ type: 'connect' }), null, 'a connection stays out of syslog');
|
||||||
|
eq(live.event_level({ type: 'roam' }), null, 'so does a device moving networks');
|
||||||
|
eq(live.event_level({ type: 'device_failing' }), null, "and a device's link trouble");
|
||||||
|
eq(live.event_level({ type: 'device_changed' }), 'info', 'people and devices are info');
|
||||||
|
eq(live.event_level({ type: 'server_down' }), 'warn', 'a problem is warn');
|
||||||
|
eq(live.event_level({ type: 'server_up' }), 'info', 'its end is info');
|
||||||
|
eq(live.event_line({ type: 'device_changed', pname: 'Myata', dname: 'Phone', detail: 'kind=phone, lan_bypass=on', by: 'portal' }),
|
||||||
|
'Myata · Phone device changed · kind=phone, lan_bypass=on (portal)', 'names, what, detail, by whom');
|
||||||
|
eq(live.event_line({ type: 'paused', person: 'p1' }), 'p1 paused', 'the id where there is no name');
|
||||||
|
});
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// dawnline.meter: the point between two samples (each server's bytes per
|
// dawnline.meter: the point between two samples (each server's and each
|
||||||
// second), the sample taken from a dump, the two minutes kept, and the file
|
// moving device's bytes per second), the sample taken from a dump, the two minutes kept, and the file
|
||||||
// the watcher writes and the RPC reads (in RUN_DIR, removed after).
|
// the watcher writes and the RPC reads (in RUN_DIR, removed after).
|
||||||
import * as meter from 'dawnline.meter';
|
import * as meter from 'dawnline.meter';
|
||||||
import { stat, unlink } from 'fs';
|
import { stat, unlink } from 'fs';
|
||||||
@@ -14,13 +14,15 @@ test('point', () => {
|
|||||||
// d_2 sent nothing; d_3's peer was added again (counters from zero); d_4 is new; d_5 moved to s_1.
|
// d_2 sent nothing; d_3's peer was added again (counters from zero); d_4 is new; d_5 moved to s_1.
|
||||||
dev: { d_1: [ 3000, 12000, 's_1' ], d_2: [ 500, 500, 's_1' ], d_3: [ 100, 300, 's_1' ], d_4: [ 10, 10, 's_1' ], d_5: [ 50, 50, 's_1' ] },
|
dev: { d_1: [ 3000, 12000, 's_1' ], d_2: [ 500, 500, 's_1' ], d_3: [ 100, 300, 's_1' ], d_4: [ 10, 10, 's_1' ], d_5: [ 50, 50, 's_1' ] },
|
||||||
};
|
};
|
||||||
eq(meter.point(a, b), { ts: 5001, servers: { s_1: [ 2000, 10000 ], s_2: [ 0, 0 ] } },
|
eq(meter.point(a, b), { ts: 5001, servers: { s_1: [ 2000, 10000 ], s_2: [ 0, 0 ] }, dev: { d_1: [ 2000, 10000 ] } },
|
||||||
'bytes per second of each server\'s devices together; a server read with nothing moving is 0');
|
'bytes per second of each server\'s devices together; a server read with nothing moving is 0; only devices that moved');
|
||||||
|
eq(meter.point(a, { ...b, t: 102.0 }).dev, { d_1: [ 1000, 5000 ] }, 'a device over two seconds');
|
||||||
eq(meter.point(a, { ...b, t: 102.0 }).servers.s_1, [ 1000, 5000 ], 'over two seconds');
|
eq(meter.point(a, { ...b, t: 102.0 }).servers.s_1, [ 1000, 5000 ], 'over two seconds');
|
||||||
eq(meter.point(a, { ...b, t: 100.0 }), null, 'no time passed');
|
eq(meter.point(a, { ...b, t: 100.0 }), null, 'no time passed');
|
||||||
eq(meter.point(a, { ...b, t: 110.0 }), null, 'the watcher stalled');
|
eq(meter.point(a, { ...b, t: 110.0 }), null, 'the watcher stalled');
|
||||||
eq(meter.point(a, { ...b, servers: [ 's_2' ], dev: { d_5: [ 50, 50, 's_2' ] } }).servers, { s_2: [ 50, 50 ] }, 'only servers read in the newer sample');
|
eq(meter.point(a, { ...b, servers: [ 's_2' ], dev: { d_5: [ 50, 50, 's_2' ] } }).servers, { s_2: [ 50, 50 ] }, 'only servers read in the newer sample');
|
||||||
eq(meter.point({ ...a, dev: {} }, b).servers, { s_1: [ 0, 0 ], s_2: [ 0, 0 ] }, 'a first look at every device: nothing yet');
|
eq(meter.point({ ...a, dev: {} }, b).servers, { s_1: [ 0, 0 ], s_2: [ 0, 0 ] }, 'a first look at every device: nothing yet');
|
||||||
|
eq(meter.point({ ...a, dev: {} }, b).dev, {}, 'and no device either');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sample', () => {
|
test('sample', () => {
|
||||||
@@ -37,7 +39,7 @@ test('sample', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('keep', () => {
|
test('keep', () => {
|
||||||
let pt = (ts) => ({ ts: ts, servers: { s_1: [ ts, 0 ] } });
|
let pt = (ts) => ({ ts: ts, servers: { s_1: [ ts, 0 ] }, dev: { d_1: [ ts, 0 ] } });
|
||||||
let ring = [];
|
let ring = [];
|
||||||
for (let ts = 1000; ts < 1000 + meter.POINTS + 5; ts++)
|
for (let ts = 1000; ts < 1000 + meter.POINTS + 5; ts++)
|
||||||
meter.keep(ring, pt(ts));
|
meter.keep(ring, pt(ts));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// dawnline.nft: the access table rendered for a model with two servers (one
|
// dawnline.nft: the access table rendered for a model with two servers (one
|
||||||
// sending everyone like a home device, one direct) and the router read as a
|
// sending everyone like a home device, one direct) and the router read as a
|
||||||
// fixed context: exactly what 0.13.0 renders (fixtures/nft-table.txt, made by
|
// fixed context: what 0.13.0 rendered (fixtures/nft-table.txt, made by
|
||||||
// that version from this model).
|
// that version from this model).
|
||||||
import { readfile } from 'fs';
|
import { readfile } from 'fs';
|
||||||
import * as nft from 'dawnline.nft';
|
import * as nft from 'dawnline.nft';
|
||||||
@@ -47,3 +47,9 @@ test('render: the table as it was', () => {
|
|||||||
m.devices.b1.lan_bypass = true;
|
m.devices.b1.lan_bypass = true;
|
||||||
eq(render(m), golden, 'a device that keeps its own local network out of the tunnel changes nothing here');
|
eq(render(m), golden, 'a device that keeps its own local network out of the tunnel changes nothing here');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('shape: chains, sets and rules of a table script', () => {
|
||||||
|
let t = 'table inet dawnline {\n\tset inet_ok {\n\t\ttype ipv4_addr\n\t}\n\tchain forward {\n\t\ttype filter hook forward priority 0; policy accept;\n\t\tiifname "dawn0" ip saddr @inet_ok accept\n\t\t# a note\n\t\tiifname "dawn0" drop\n\t}\n}\n';
|
||||||
|
eq(nft.shape(t), { chains: 1, sets: 1, rules: 2 }, 'the hook line, the policy and a comment are no rules');
|
||||||
|
eq(nft.shape(''), { chains: 0, sets: 0, rules: 0 }, 'nothing');
|
||||||
|
});
|
||||||
@@ -26,6 +26,8 @@ test('validate: int', () => {
|
|||||||
test('validate: enum', () => {
|
test('validate: enum', () => {
|
||||||
eq(schema.validate('geo_provider', 'ipapi.co'), 'ipapi.co', 'known');
|
eq(schema.validate('geo_provider', 'ipapi.co'), 'ipapi.co', 'known');
|
||||||
throws(() => schema.validate('geo_provider', 'maxmind'), /Unknown location service/, 'unknown');
|
throws(() => schema.validate('geo_provider', 'maxmind'), /Unknown location service/, 'unknown');
|
||||||
|
eq(schema.validate('log_level', 'debug'), 'debug', 'a syslog level');
|
||||||
|
throws(() => schema.validate('log_level', 'trace'), /system log level/, 'not a syslog level');
|
||||||
eq(schema.validate('update_interval', '7d'), '7d', 'interval from dawnline.updates');
|
eq(schema.validate('update_interval', '7d'), '7d', 'interval from dawnline.updates');
|
||||||
throws(() => schema.validate('update_interval', '2d'), /6h, 12h, 1d or 7d/, 'unknown interval');
|
throws(() => schema.validate('update_interval', '2d'), /6h, 12h, 1d or 7d/, 'unknown interval');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -318,3 +318,18 @@ test('host_label, tunnel_name, slugify: dashes trimmed without a regex', () => {
|
|||||||
}
|
}
|
||||||
same(null);
|
same(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('syslog_line', () => {
|
||||||
|
eq(util.syslog_line('warn', 'awg', 'Home stopped unexpectedly'), '[warn] [awg] Home stopped unexpectedly', 'level, source, words');
|
||||||
|
eq(util.syslog_line('error', 'apply', 'failed:\n no table\tthere'), '[error] [apply] failed: no table there', 'one line');
|
||||||
|
eq(util.syslog_line('loud', null, 'x'), '[info] [dawnline] x', 'an unknown level is info, no source is dawnline');
|
||||||
|
eq(length(util.syslog_line('info', 'x', replace(sprintf('%1500s', ''), ' ', 'y'))), 1000, 'at most 1000 characters');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('opts_text: options in a log line, keys masked', () => {
|
||||||
|
eq(util.opts_text({ listen_port: 51820, addresses: [ '10.8.0.1/24' ], private_key: 'abc=', mtu: null }),
|
||||||
|
'listen_port=51820, addresses=10.8.0.1/24, private_key=***, mtu=-', 'values, lists, a secret, nothing');
|
||||||
|
eq(util.opts_text({ preshared_key: 'x', awg_header_protection_key: 'y', public_key: 'z' }),
|
||||||
|
'preshared_key=***, awg_header_protection_key=***, public_key=z', 'a public key is no secret');
|
||||||
|
eq(util.opts_text(null), '', 'none');
|
||||||
|
});
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
coverage/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
src/portal/fonts/
|
|
||||||
src/admin/styles/*.css
|
src/admin/styles/*.css
|
||||||
dist/
|
dist/
|
||||||
@@ -31,7 +31,9 @@ import fs from 'node:fs';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import * as prettier from 'prettier';
|
import * as prettier from 'prettier';
|
||||||
import ts from 'typescript';
|
import * as ts from 'typescript/unstable/ast';
|
||||||
|
import { createVirtualFileSystem } from 'typescript/unstable/fs';
|
||||||
|
import { API } from 'typescript/unstable/sync';
|
||||||
import { keyOf, parsePo, pluralForms, translated, writePo, type Entry, type Po } from './po.ts';
|
import { keyOf, parsePo, pluralForms, translated, writePo, type Entry, type Po } from './po.ts';
|
||||||
|
|
||||||
const WEB = path.resolve(import.meta.dirname, '..');
|
const WEB = path.resolve(import.meta.dirname, '..');
|
||||||
@@ -149,14 +151,39 @@ class Errors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isFunctionLike(n: ts.Node): boolean {
|
function isFunctionLike(n: ts.Node): boolean {
|
||||||
return ts.isFunctionLike(n) || ts.isPropertyDeclaration(n) || ts.isClassStaticBlockDeclaration(n);
|
return ts.isFunctionLikeDeclaration(n) || ts.isPropertyDeclaration(n) || ts.isClassStaticBlockDeclaration(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The syntax trees of the files, parsed in one run by TypeScript 7 (its JS API
|
||||||
|
* drives the native compiler, tsgo). They go to it as a virtual project, ucode
|
||||||
|
* as JavaScript: nothing else is read, no import followed, no type checked.
|
||||||
|
*/
|
||||||
|
function parseAll(files: string[]): Map<string, ts.SourceFile> {
|
||||||
|
const name = (f: string) => (f.endsWith('.ts') ? f : `${f}.js`);
|
||||||
|
const config = '/dawnline-i18n/tsconfig.json';
|
||||||
|
const vfs: Record<string, string> = {
|
||||||
|
[config]: JSON.stringify({ compilerOptions: { allowJs: true, noLib: true, noResolve: true, types: [] }, files: files.map(name) }),
|
||||||
|
};
|
||||||
|
for (const f of files) vfs[name(f)] = fs.readFileSync(f, 'utf8');
|
||||||
|
const api = new API({ cwd: WEB, fs: createVirtualFileSystem(vfs) });
|
||||||
|
try {
|
||||||
|
const program = api.updateSnapshot({ openProjects: [config] }).getProject(config)?.program;
|
||||||
|
if (!program) throw new Error('TypeScript did not open the virtual project');
|
||||||
|
return new Map(
|
||||||
|
files.map((f) => {
|
||||||
|
const sf = program.getSourceFile(name(f));
|
||||||
|
if (!sf) throw new Error(`TypeScript did not parse ${rel(f)}`);
|
||||||
|
return [f, sf];
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
api.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every translation call in one file. */
|
/** Every translation call in one file. */
|
||||||
function scan(file: string, lazy: boolean, logs: boolean, errors: Errors, out: Found[]) {
|
function scan(file: string, sf: ts.SourceFile, lazy: boolean, logs: boolean, errors: Errors, out: Found[]) {
|
||||||
const text = fs.readFileSync(file, 'utf8');
|
|
||||||
const kind = file.endsWith('.ts') ? ts.ScriptKind.TS : ts.ScriptKind.JS;
|
|
||||||
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, kind);
|
|
||||||
const wrapper = WRAPPERS.has(file);
|
const wrapper = WRAPPERS.has(file);
|
||||||
const visit = (node: ts.Node) => {
|
const visit = (node: ts.Node) => {
|
||||||
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && CALLS[node.expression.text] && !wrapper) {
|
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && CALLS[node.expression.text] && !wrapper) {
|
||||||
@@ -201,7 +228,7 @@ function scan(file: string, lazy: boolean, logs: boolean, errors: Errors, out: F
|
|||||||
out.push(e);
|
out.push(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts.forEachChild(node, visit);
|
node.forEachChild(visit);
|
||||||
};
|
};
|
||||||
visit(sf);
|
visit(sf);
|
||||||
}
|
}
|
||||||
@@ -213,9 +240,9 @@ function scanMenu(file: string, out: Found[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** One catalog's strings, deduplicated and sorted (by code unit: the same order on every machine). */
|
/** One catalog's strings, deduplicated and sorted (by code unit: the same order on every machine). */
|
||||||
function collect(spec: CatalogSpec, errors: Errors): Entry[] {
|
function collect(spec: CatalogSpec, trees: Map<string, ts.SourceFile>, errors: Errors): Entry[] {
|
||||||
const found: Found[] = [];
|
const found: Found[] = [];
|
||||||
for (const f of spec.sources()) scan(f, spec.lazy(f), !!spec.logs, errors, found);
|
for (const f of spec.sources()) scan(f, trees.get(f)!, spec.lazy(f), !!spec.logs, errors, found);
|
||||||
for (const f of spec.menus?.() ?? []) scanMenu(f, found);
|
for (const f of spec.menus?.() ?? []) scanMenu(f, found);
|
||||||
const byKey = new Map<string, Found>();
|
const byKey = new Map<string, Found>();
|
||||||
for (const e of found) {
|
for (const e of found) {
|
||||||
@@ -316,7 +343,8 @@ async function main() {
|
|||||||
}
|
}
|
||||||
const usedDrafts = new Set<string>();
|
const usedDrafts = new Set<string>();
|
||||||
|
|
||||||
const collected = CATALOGS.map((spec) => ({ spec, entries: collect(spec, errors) }));
|
const trees = parseAll([...new Set(CATALOGS.flatMap((spec) => spec.sources()))]);
|
||||||
|
const collected = CATALOGS.map((spec) => ({ spec, entries: collect(spec, trees, errors) }));
|
||||||
const only = opt.only.map((f) => rel(path.resolve(f)));
|
const only = opt.only.map((f) => rel(path.resolve(f)));
|
||||||
const under = (r: string) => only.some((o) => r === o || r.startsWith(`${o}/`));
|
const under = (r: string) => only.some((o) => r === o || r.startsWith(`${o}/`));
|
||||||
// Linting some files: the problems of those (other files may be half-way through a change).
|
// Linting some files: the problems of those (other files may be half-way through a change).
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.14.1",
|
"version": "0.18.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -12,18 +12,27 @@
|
|||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"format:check": "prettier --check .",
|
"format:check": "prettier --check .",
|
||||||
"ci": "npm run format:check && npm run typecheck && npm run i18n:check && npm run test && npm run build",
|
"lint": "oxlint --deny-warnings",
|
||||||
|
"knip": "knip",
|
||||||
|
"ci": "npm run format:check && npm run typecheck && npm run lint && npm run knip && npm run i18n:check && npm run test && npm run build",
|
||||||
"i18n": "node i18n/extract.ts",
|
"i18n": "node i18n/extract.ts",
|
||||||
"i18n:check": "node i18n/extract.ts --check"
|
"i18n:check": "node i18n/extract.ts --check"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"qrcode-generator": "1.4.4"
|
"qrcode-generator": "2.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "22.20.5",
|
"@types/node": "26.6.5",
|
||||||
"prettier": "3.6.2",
|
"esbuild": "0.28.2",
|
||||||
"tsup": "8.5.0",
|
"knip": "6.43.0",
|
||||||
"typescript": "5.9.3",
|
"oxlint": "1.89.0",
|
||||||
"vitest": "3.2.4"
|
"prettier": "3.9.10",
|
||||||
|
"tsup": "9.0.0",
|
||||||
|
"typescript": "7.0.2",
|
||||||
|
"vitest": "5.0.5"
|
||||||
|
},
|
||||||
|
"allowScripts": {
|
||||||
|
"esbuild@0.28.2": true,
|
||||||
|
"fsevents@2.3.3": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ import { fmt, plural } from '../shared/i18n';
|
|||||||
type Service = Status['services'][number];
|
type Service = Status['services'][number];
|
||||||
|
|
||||||
/** Circle colours; the circle stores an index. */
|
/** Circle colours; the circle stores an index. */
|
||||||
export const CIRCLE_COLORS = ['#3a83f7', '#a78bfa', '#f472b6', '#f59e0b', '#10b981', '#22d3ee', '#ef4444', '#84cc16'];
|
const CIRCLE_COLORS = ['#3a83f7', '#a78bfa', '#f472b6', '#f59e0b', '#10b981', '#22d3ee', '#ef4444', '#84cc16'];
|
||||||
|
|
||||||
export const circleDot = (c: Circle | undefined) =>
|
export const circleDot = (c: Circle | undefined) =>
|
||||||
E('i', { class: 'dl-circle-dot', style: `background:${CIRCLE_COLORS[c?.color ?? 0] ?? CIRCLE_COLORS[0]}` });
|
E('i', { class: 'dl-circle-dot', style: `background:${CIRCLE_COLORS[c?.color ?? 0] ?? CIRCLE_COLORS[0]}` });
|
||||||
@@ -26,7 +26,7 @@ export const homeAccess = (p: Person) => p.access === 'both' || (p.access === 'l
|
|||||||
|
|
||||||
/* ---------- Home services ---------- */
|
/* ---------- Home services ---------- */
|
||||||
|
|
||||||
export function serviceDialog(sv: Service | null, prefill: Partial<Service>, onSaved: () => unknown) {
|
function serviceDialog(sv: Service | null, prefill: Partial<Service>, onSaved: () => unknown) {
|
||||||
const name = input(sv?.name ?? prefill.name ?? '', { placeholder: _('NAS') });
|
const name = input(sv?.name ?? prefill.name ?? '', { placeholder: _('NAS') });
|
||||||
const addr = input(sv?.address ?? prefill.address ?? '', { placeholder: '192.168.1.10', class: 'cbi-input-text dl-mono' });
|
const addr = input(sv?.address ?? prefill.address ?? '', { placeholder: '192.168.1.10', class: 'cbi-input-text dl-mono' });
|
||||||
const ports = input((sv?.ports ?? prefill.ports ?? []).join(', '), {
|
const ports = input((sv?.ports ?? prefill.ports ?? []).join(', '), {
|
||||||
|
|||||||
@@ -82,10 +82,14 @@ export interface EndpointProbe {
|
|||||||
here6?: boolean;
|
here6?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** One second of the live meter: each server whose tunnel was read, [rx, tx] in bytes/s (rx = from devices, as Server.rate). */
|
/**
|
||||||
|
* One second of the live meter: each server whose tunnel was read, [rx, tx] in bytes/s (rx = from devices, as
|
||||||
|
* Server.rate), and each device that moved something (one left out moved nothing; an older agent sends none).
|
||||||
|
*/
|
||||||
export interface MeterPoint {
|
export interface MeterPoint {
|
||||||
ts: number;
|
ts: number;
|
||||||
servers: Record<string, Pair>;
|
servers: Record<string, Pair>;
|
||||||
|
dev?: Record<string, Pair>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -295,7 +299,7 @@ export interface LogsInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The path that makes tunnel clients' internet traffic enter from the LAN. */
|
/** The path that makes tunnel clients' internet traffic enter from the LAN. */
|
||||||
export interface LikeHome {
|
interface LikeHome {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
dev?: string;
|
dev?: string;
|
||||||
address?: string;
|
address?: string;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// The AmneziaWG core in the admin: how a device connects (.conf, AmneziaVPN
|
// The AmneziaWG core in the admin: how a device connects (.conf, AmneziaVPN
|
||||||
// key, QR), the disguise and its parameters, and the core's own settings on
|
// key, QR, V2RayTun's link), the disguise and its parameters, and the core's own settings on
|
||||||
// Server → AmneziaWG. Plain WireGuard is AmneziaWG with the disguise off.
|
// Server → AmneziaWG. Plain WireGuard is AmneziaWG with the disguise off.
|
||||||
|
|
||||||
import type { AwgConfig, Server, Status } from '../../shared/types';
|
import type { AwgConfig, Kind, Server, Status } from '../../shared/types';
|
||||||
import { E } from '../e';
|
import { E } from '../e';
|
||||||
import { api } from '../api';
|
import { api } from '../api';
|
||||||
import { button } from '../ui/button';
|
import { button } from '../ui/button';
|
||||||
@@ -14,10 +14,12 @@ import { callout, card, firstBad, group, liveRow, row } from '../ui/layout';
|
|||||||
import { qrCode } from '../ui/qr';
|
import { qrCode } from '../ui/qr';
|
||||||
import { keepaliveHelp, mtuHelp, portHelp, type PortHold } from '../netcheck';
|
import { keepaliveHelp, mtuHelp, portHelp, type PortHold } from '../netcheck';
|
||||||
import { vpnKey } from '../../shared/vpnkey';
|
import { vpnKey } from '../../shared/vpnkey';
|
||||||
|
import { awgLink, v2rFits } from '../../shared/awglink';
|
||||||
|
import { V2R_WINDOWS } from '../../shared/flags';
|
||||||
import { icon } from '../../shared/icons';
|
import { icon } from '../../shared/icons';
|
||||||
import { methodInfo, methodPicker, type Method, defaultMethod, legacyTitle } from '../disguise';
|
import { methodInfo, methodPicker, type Method, defaultMethod, legacyTitle } from '../disguise';
|
||||||
import { fmt, fill, num, plural } from '../../shared/i18n';
|
import { fmt, fill, num, plural } from '../../shared/i18n';
|
||||||
import { coreHead, type Core, type CoreCtx } from './common';
|
import { coreHead, type ConnectView, type Core, type CoreCtx } from './common';
|
||||||
|
|
||||||
/** `.conf` names of the disguise parameters, in file order. */
|
/** `.conf` names of the disguise parameters, in file order. */
|
||||||
const CONF: [string, string][] = [
|
const CONF: [string, string][] = [
|
||||||
@@ -219,8 +221,71 @@ export function plainWg(cfg: AwgConfig): boolean {
|
|||||||
return Object.entries(o).every(([k, v]) => v == null || v === '' || v === (neutral[k] ?? '0'));
|
return Object.entries(o).every(([k, v]) => v == null || v === '' || v === (neutral[k] ?? '0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** File / key / QR switcher for a client configuration; opens on the file unless asked otherwise. */
|
/**
|
||||||
export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr' = 'file'): Promise<HTMLElement> {
|
* V2RayTun's way in: the connection as its awg:// link (shared/awglink.ts;
|
||||||
|
* the app's own words are in portal/setup.ts, with where they come from). A
|
||||||
|
* computer runs it on Windows, whose core looks the server's name up itself:
|
||||||
|
* the link keeps the name. That one is off for now (shared/flags.ts
|
||||||
|
* V2R_WINDOWS: its core leaves the server's DNS unused). Anything else is
|
||||||
|
* taken for Android, whose core takes no name: the link has the server's IP
|
||||||
|
* (amnezia.host_ip, from device_config).
|
||||||
|
*/
|
||||||
|
function v2rPane(cfg: AwgConfig, kind: Kind): HTMLElement {
|
||||||
|
const win = kind === 'computer';
|
||||||
|
const host = cfg.amnezia.host.replace(/^\[(.*)\]$/, '$1');
|
||||||
|
const ip = win ? null : (cfg.amnezia.host_ip ?? null);
|
||||||
|
const link = awgLink(cfg.conf, cfg.server, ip);
|
||||||
|
const box = E('div', { class: 'dl-linkbox' }, [
|
||||||
|
E('span', { class: 'dl-mono', title: link }, link),
|
||||||
|
button(_('Copy'), () => copyText(link, _('Link copied'))),
|
||||||
|
]);
|
||||||
|
if (win)
|
||||||
|
return E('div', { class: 'dl-stack gap8' }, [
|
||||||
|
box,
|
||||||
|
E(
|
||||||
|
'span',
|
||||||
|
{ class: 'dl-sub' },
|
||||||
|
fmt(
|
||||||
|
_(
|
||||||
|
'V2RayTun on Windows: %s, then set its mode to %s and connect. That mode needs administrator rights: the app offers to restart with them.',
|
||||||
|
),
|
||||||
|
['+', _('Import from clipboard', 'V2RayTun app')].join(' → '),
|
||||||
|
_('Tunnel', 'V2RayTun app'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
return E('div', { class: 'dl-qr-pane' }, [
|
||||||
|
qrCode(link),
|
||||||
|
E(
|
||||||
|
'span',
|
||||||
|
{ class: 'dl-sub' },
|
||||||
|
fmt(
|
||||||
|
_('V2RayTun on Android: %s, or copy the link and %s.'),
|
||||||
|
['+', _('Import config from QRcode', 'V2RayTun app')].join(' → '),
|
||||||
|
['+', _('Import config from Clipboard', 'V2RayTun app')].join(' → '),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
box,
|
||||||
|
// Honest about what the IP costs, and about a name that gives none.
|
||||||
|
ip && ip !== host
|
||||||
|
? E(
|
||||||
|
'div',
|
||||||
|
{ class: 'dl-hint' },
|
||||||
|
_('The link has the server’s IP address, not its name: if the address changes, set the device up again.'),
|
||||||
|
)
|
||||||
|
: !ip
|
||||||
|
? callout('warn', fmt(_('%s does not resolve right now, and V2RayTun on Android connects by IP address only.'), host))
|
||||||
|
: '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File / key / QR / V2RayTun switcher for a client configuration of a device
|
||||||
|
* of this kind; opens on the file unless asked otherwise. V2RayTun is left out
|
||||||
|
* for a router, for a computer while V2R_WINDOWS is off (shared/flags.ts) and
|
||||||
|
* for AmneziaWG 3.1 (the Maximum disguise), which it lacks.
|
||||||
|
*/
|
||||||
|
async function connectBlock(cfg: AwgConfig, kind: Kind, initial: ConnectView = 'file'): Promise<HTMLElement> {
|
||||||
if (!cfg.has_private_key)
|
if (!cfg.has_private_key)
|
||||||
return E(
|
return E(
|
||||||
'div',
|
'div',
|
||||||
@@ -228,7 +293,7 @@ export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr
|
|||||||
_('This device generated its own keys in the browser, so its full configuration only exists on that device.'),
|
_('This device generated its own keys in the browser, so its full configuration only exists on that device.'),
|
||||||
);
|
);
|
||||||
const key = await vpnKey(cfg, cfg.server);
|
const key = await vpnKey(cfg, cfg.server);
|
||||||
const panes: Record<string, () => Node> = {
|
const panes: Partial<Record<ConnectView, () => Node>> = {
|
||||||
qr: () =>
|
qr: () =>
|
||||||
E('div', { class: 'dl-qr-pane' }, [
|
E('div', { class: 'dl-qr-pane' }, [
|
||||||
qrCode(cfg.conf),
|
qrCode(cfg.conf),
|
||||||
@@ -252,19 +317,22 @@ export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr
|
|||||||
]),
|
]),
|
||||||
file: () => fileCard(cfg),
|
file: () => fileCard(cfg),
|
||||||
};
|
};
|
||||||
const body = E('div', { class: 'dl-connect-body' });
|
if (kind !== 'router' && (kind !== 'computer' || V2R_WINDOWS) && v2rFits(cfg.conf)) panes.v2r = () => v2rPane(cfg, kind);
|
||||||
const seg = E('div', { class: 'dl-seg' });
|
const labels: [ConnectView, string][] = [
|
||||||
const show = (id: string) => {
|
|
||||||
seg.querySelectorAll('button').forEach((b) => b.classList.toggle('on', b.dataset.id === id));
|
|
||||||
dom.content(body, panes[id]());
|
|
||||||
};
|
|
||||||
for (const [id, label] of [
|
|
||||||
['file', _('File')],
|
['file', _('File')],
|
||||||
['key', _('Key')],
|
['key', _('Key')],
|
||||||
['qr', _('QR code')],
|
['qr', _('QR code')],
|
||||||
])
|
['v2r', 'V2RayTun'],
|
||||||
seg.appendChild(E('button', { type: 'button', 'data-id': id, click: () => show(id) }, label));
|
];
|
||||||
show(initial);
|
const body = E('div', { class: 'dl-connect-body' });
|
||||||
|
const seg = E('div', { class: 'dl-seg' });
|
||||||
|
const show = (id: ConnectView) => {
|
||||||
|
seg.querySelectorAll('button').forEach((b) => b.classList.toggle('on', b.dataset.id === id));
|
||||||
|
dom.content(body, panes[id]!());
|
||||||
|
};
|
||||||
|
for (const [id, label] of labels)
|
||||||
|
if (panes[id]) seg.appendChild(E('button', { type: 'button', 'data-id': id, click: () => show(id) }, label));
|
||||||
|
show(panes[initial] ? initial : 'file');
|
||||||
return E('div', { class: 'dl-stack gap12' }, [seg, body]);
|
return E('div', { class: 'dl-stack gap12' }, [seg, body]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +365,7 @@ async function applyDisguise(ctx: CoreCtx, srv: Server, m: Method, same: boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Server → AmneziaWG: listening port, what goes into every configuration, disguise, tunnel. */
|
/** Server → AmneziaWG: listening port, what goes into every configuration, disguise, tunnel. */
|
||||||
export function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement {
|
function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement {
|
||||||
const st: Status = ctx.st;
|
const st: Status = ctx.st;
|
||||||
const port = input(String(srv.port), { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' });
|
const port = input(String(srv.port), { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' });
|
||||||
const mtu = input(srv.mtu ? String(srv.mtu) : '', {
|
const mtu = input(srv.mtu ? String(srv.mtu) : '', {
|
||||||
@@ -448,7 +516,7 @@ function overviewTile(srv: Server): HTMLElement {
|
|||||||
return E('div', { class: 'dl-bento-tile dl-disg' }, [
|
return E('div', { class: 'dl-bento-tile dl-disg' }, [
|
||||||
E('div', { class: 'dl-bento-head' }, [
|
E('div', { class: 'dl-bento-head' }, [
|
||||||
E('span', { class: 'dl-metric-label' }, _('Disguise')),
|
E('span', { class: 'dl-metric-label' }, _('Disguise')),
|
||||||
E('a', { href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(srv.id)}§ion=awg` }, _('Change')),
|
E('a', { href: `${L.url('admin/services/dawnline/server')}?server=${encodeURIComponent(srv.id)}§ion=awg` }, _('Change')),
|
||||||
]),
|
]),
|
||||||
E('div', { class: 'dl-disg-id' }, [
|
E('div', { class: 'dl-disg-id' }, [
|
||||||
E('span', { class: `dl-disg-ic${m?.id === 'off' ? ' off' : ''}` }, icon(m?.ic ?? 'shield')),
|
E('span', { class: `dl-disg-ic${m?.id === 'off' ? ' off' : ''}` }, icon(m?.ic ?? 'shield')),
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
// What every tunnel core gives the admin (cores/index.ts holds the registry),
|
// What every tunnel core gives the admin (cores/index.ts holds the registry),
|
||||||
// what a core's settings card gets from the Server page, and that card's head.
|
// what a core's settings card gets from the Server page, and that card's head.
|
||||||
|
|
||||||
import type { ClientConfig, Server, Status } from '../../shared/types';
|
import type { ClientConfig, Kind, Server, Status } from '../../shared/types';
|
||||||
import { E } from '../e';
|
import { E } from '../e';
|
||||||
|
|
||||||
|
/** The ways a device takes its configuration, as the set-up switcher names them. */
|
||||||
|
export type ConnectView = 'file' | 'key' | 'qr' | 'v2r';
|
||||||
|
|
||||||
/** What the Server page hands a core's settings card. */
|
/** What the Server page hands a core's settings card. */
|
||||||
export interface CoreCtx {
|
export interface CoreCtx {
|
||||||
st: Status;
|
st: Status;
|
||||||
@@ -21,8 +24,8 @@ export interface Core {
|
|||||||
settingsCard(ctx: CoreCtx, srv: Server): HTMLElement;
|
settingsCard(ctx: CoreCtx, srv: Server): HTMLElement;
|
||||||
/** Overview: how the tunnel looks on the wire (the disguise tile). */
|
/** Overview: how the tunnel looks on the wire (the disguise tile). */
|
||||||
overviewTile(srv: Server): HTMLElement;
|
overviewTile(srv: Server): HTMLElement;
|
||||||
/** How a device connects: file / key / QR. */
|
/** How a device of this kind connects: file / key / QR / V2RayTun's link, opening on `initial`. */
|
||||||
connectBlock(cfg: ClientConfig, initial?: 'file' | 'key' | 'qr'): Promise<HTMLElement>;
|
connectBlock(cfg: ClientConfig, kind: Kind, initial?: ConnectView): Promise<HTMLElement>;
|
||||||
/** What a QR code for the device carries. */
|
/** What a QR code for the device carries. */
|
||||||
qrText(cfg: ClientConfig): string;
|
qrText(cfg: ClientConfig): string;
|
||||||
/** The key the device's app imports (⋯ → Copy key), with the menu label. */
|
/** The key the device's app imports (⋯ → Copy key), with the menu label. */
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { Server } from '../../shared/types';
|
|||||||
import type { Core } from './common';
|
import type { Core } from './common';
|
||||||
import { awg } from './awg';
|
import { awg } from './awg';
|
||||||
|
|
||||||
export type { Core, CoreCtx } from './common';
|
export type { Core } from './common';
|
||||||
|
|
||||||
const CORES: Record<string, Core> = { awg };
|
const CORES: Record<string, Core> = { awg };
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,20 @@ import { isOn, sw } from './ui/controls';
|
|||||||
import { qrCode } from './ui/qr';
|
import { qrCode } from './ui/qr';
|
||||||
import { deviceNameHelp, type Help } from './netcheck';
|
import { deviceNameHelp, type Help } from './netcheck';
|
||||||
import { deviceStatus } from './ui/badges';
|
import { deviceStatus } from './ui/badges';
|
||||||
import { ago, bytes, defaultName, fitName, homeOf, isoDay, kindLabel, KINDS, netsLabel, todayOf } from '../shared/format';
|
import {
|
||||||
|
ago,
|
||||||
|
bytes,
|
||||||
|
defaultName,
|
||||||
|
fitName,
|
||||||
|
homeOf,
|
||||||
|
isoDay,
|
||||||
|
kindLabel,
|
||||||
|
netsLabel,
|
||||||
|
pickLabel,
|
||||||
|
PICKS,
|
||||||
|
todayOf,
|
||||||
|
type KindPick,
|
||||||
|
} from '../shared/format';
|
||||||
import { guardDeviceName } from '../shared/name-guard';
|
import { guardDeviceName } from '../shared/name-guard';
|
||||||
import { fill, fmt, locale, num } from '../shared/i18n';
|
import { fill, fmt, locale, num } from '../shared/i18n';
|
||||||
import { icon } from '../shared/icons';
|
import { icon } from '../shared/icons';
|
||||||
@@ -176,7 +189,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
|||||||
let today = o.today ?? isoDay(new Date());
|
let today = o.today ?? isoDay(new Date());
|
||||||
let srv = o.server;
|
let srv = o.server;
|
||||||
// Phones and tablets are set up by scanning; computers and routers by a file.
|
// Phones and tablets are set up by scanning; computers and routers by a file.
|
||||||
const block = (c: ClientConfig) => core.connectBlock(c, dev.kind === 'phone' || dev.kind === 'tablet' ? 'qr' : 'file');
|
const block = (c: ClientConfig) => core.connectBlock(c, dev.kind, dev.kind === 'phone' || dev.kind === 'tablet' ? 'qr' : 'file');
|
||||||
// An older configuration on the device: the new one waits for a click (the inline QR code is itself a delivery).
|
// An older configuration on the device: the new one waits for a click (the inline QR code is itself a delivery).
|
||||||
// `relinked`: its MTU or keep-alive was just changed here, which outdates the configuration on screen even where
|
// `relinked`: its MTU or keep-alive was just changed here, which outdates the configuration on screen even where
|
||||||
// the router keeps no record of what the device got (never "stale" then, e.g. after a JSON import).
|
// the router keeps no record of what the device got (never "stale" then, e.g. after a JSON import).
|
||||||
@@ -222,8 +235,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
|||||||
E('span', { class: 'dl-sub' }, `${p.name} · ${kindLabel(d.kind)}`),
|
E('span', { class: 'dl-sub' }, `${p.name} · ${kindLabel(d.kind)}`),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
const days = d.spark.map(([rx, tx]) => rx + tx);
|
const week = d.spark.reduce((a, [rx, tx]) => a + rx + tx, 0);
|
||||||
const week = days.reduce((a, b) => a + b, 0);
|
|
||||||
dom.content(
|
dom.content(
|
||||||
stats,
|
stats,
|
||||||
E('div', { class: 'dl-dstats' }, [
|
E('div', { class: 'dl-dstats' }, [
|
||||||
@@ -240,7 +252,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
|||||||
E('div', { class: 'dl-dstats-cell' }, [
|
E('div', { class: 'dl-dstats-cell' }, [
|
||||||
E('span', { class: 'dl-metric-label' }, _('Last 7 days')),
|
E('span', { class: 'dl-metric-label' }, _('Last 7 days')),
|
||||||
E('b', {}, bytes(week)),
|
E('b', {}, bytes(week)),
|
||||||
spark(days, 120, 22, today),
|
spark(d.spark, 120, 22, today),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
@@ -421,7 +433,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
|||||||
},
|
},
|
||||||
_('Clear'),
|
_('Clear'),
|
||||||
),
|
),
|
||||||
E('a', { href: `${L.url('admin/network/dawnline/diagnostics')}?tab=log` }, _('All activity')),
|
E('a', { href: `${L.url('admin/services/dawnline/diagnostics')}?tab=log` }, _('All activity')),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
log,
|
log,
|
||||||
@@ -610,49 +622,51 @@ export function addDevice(person: Person, o: DeviceOpts) {
|
|||||||
while (taken.some((t) => t.toLowerCase() === name.toLowerCase())) name = fitName(base, ` ${++n}`);
|
while (taken.some((t) => t.toLowerCase() === name.toLowerCase())) name = fitName(base, ` ${++n}`);
|
||||||
return name;
|
return name;
|
||||||
};
|
};
|
||||||
let kind: Kind = 'phone';
|
// Mobile from here is a phone: the admin is never on the device itself (see KindPick).
|
||||||
|
const kindOf = (p: KindPick): Kind => (p === 'mobile' ? 'phone' : p);
|
||||||
|
let pick: KindPick = 'mobile';
|
||||||
const nameInput = E('input', {
|
const nameInput = E('input', {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
class: 'cbi-input-text',
|
class: 'cbi-input-text',
|
||||||
placeholder: suggest(kind),
|
placeholder: suggest(kindOf(pick)),
|
||||||
}) as HTMLInputElement;
|
}) as HTMLInputElement;
|
||||||
const said = nameGuard(nameInput, () => nameRow.refresh());
|
const said = nameGuard(nameInput, () => nameRow.refresh());
|
||||||
const nameRow = liveField(_('Name'), nameInput, () =>
|
const nameRow = liveField(_('Name'), nameInput, () =>
|
||||||
said(
|
said(
|
||||||
nameInput.value.trim()
|
nameInput.value.trim()
|
||||||
? deviceNameHelp(nameInput.value, taken, _('Shown in the portal and in the app.'))
|
? deviceNameHelp(nameInput.value, taken, _('Shown in the portal and in the app.'))
|
||||||
: { text: fmt(_('Named after its type: %s.'), suggest(kind)), bad: false },
|
: { text: fmt(_('Named after its type: %s.'), suggest(kindOf(pick))), bad: false },
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const kinds = E(
|
const kinds = E(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'dl-kinds', role: 'radiogroup', 'aria-label': _('Type') },
|
{ class: 'dl-kinds', role: 'radiogroup', 'aria-label': _('Type') },
|
||||||
KINDS.map((k) =>
|
PICKS.map((k) =>
|
||||||
E(
|
E(
|
||||||
'button',
|
'button',
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
role: 'radio',
|
role: 'radio',
|
||||||
class: k === kind ? 'on' : '',
|
class: k === pick ? 'on' : '',
|
||||||
'aria-checked': k === kind ? 'true' : 'false',
|
'aria-checked': k === pick ? 'true' : 'false',
|
||||||
'data-kind': k,
|
'data-kind': k,
|
||||||
click: () => {
|
click: () => {
|
||||||
kind = k;
|
pick = k;
|
||||||
kinds.querySelectorAll('button').forEach((c) => {
|
kinds.querySelectorAll('button').forEach((c) => {
|
||||||
const on = (c as HTMLElement).dataset.kind === k;
|
const on = (c as HTMLElement).dataset.kind === k;
|
||||||
c.classList.toggle('on', on);
|
c.classList.toggle('on', on);
|
||||||
c.setAttribute('aria-checked', on ? 'true' : 'false');
|
c.setAttribute('aria-checked', on ? 'true' : 'false');
|
||||||
});
|
});
|
||||||
nameInput.placeholder = suggest(k);
|
nameInput.placeholder = suggest(kindOf(k));
|
||||||
nameRow.refresh();
|
nameRow.refresh();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[icon(k), E('span', {}, kindLabel(k))],
|
[icon(k), E('span', {}, pickLabel(k))],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
// LAN Bypass: off unless chosen (the person chooses it on the portal, the admin here).
|
// LAN Bypass: on unless turned off (the person chooses it on the portal, the admin here).
|
||||||
const bypass = sw(false, _('LAN Bypass'));
|
const bypass = sw(true, _('LAN Bypass'));
|
||||||
const over = person.devices.length >= person.device_limit;
|
const over = person.devices.length >= person.device_limit;
|
||||||
modal(
|
modal(
|
||||||
fmt(_('Add a device for %s'), person.name),
|
fmt(_('Add a device for %s'), person.name),
|
||||||
@@ -704,8 +718,8 @@ export function addDevice(person: Person, o: DeviceOpts) {
|
|||||||
notify(h.text, 'warning');
|
notify(h.text, 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const name = nameInput.value.trim() || suggest(kind);
|
const name = nameInput.value.trim() || suggest(kindOf(pick));
|
||||||
const r = await attempt(() => api.deviceCreate(person.id, name, kind, isOn(bypass)));
|
const r = await attempt(() => api.deviceCreate(person.id, name, kindOf(pick), isOn(bypass)));
|
||||||
if (!r) return;
|
if (!r) return;
|
||||||
closeModal();
|
closeModal();
|
||||||
notify(fmt(_('%s added'), name), 'success', 3000);
|
notify(fmt(_('%s added'), name), 'success', 3000);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { fmt } from '../shared/i18n';
|
|||||||
|
|
||||||
export type Method = 'balanced' | 'max' | 'off';
|
export type Method = 'balanced' | 'max' | 'off';
|
||||||
/** The router features a method may need (the boolean ones of AwgCaps). */
|
/** The router features a method may need (the boolean ones of AwgCaps). */
|
||||||
export type AwgNeed = 'v2' | 'v3';
|
type AwgNeed = 'v2' | 'v3';
|
||||||
|
|
||||||
export interface MethodInfo {
|
export interface MethodInfo {
|
||||||
id: Method;
|
id: Method;
|
||||||
@@ -26,7 +26,7 @@ export interface MethodInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The methods in picker order, in the page's language. */
|
/** The methods in picker order, in the page's language. */
|
||||||
export function methods(): MethodInfo[] {
|
function methods(): MethodInfo[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: 'off',
|
id: 'off',
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// The activity log's vocabulary: categories, who did what, problems, retention.
|
// The activity log's vocabulary: categories, who did what, problems, retention.
|
||||||
// No DOM and no RPC here (see ./render for rows).
|
// No DOM and no RPC here (see ./render for rows).
|
||||||
|
|
||||||
import type { LogEvent } from '../../shared/types';
|
import type { Kind, LogEvent } from '../../shared/types';
|
||||||
|
import { kindLabel } from '../../shared/format';
|
||||||
import type { LogCategory, LogsInfo, ServiceLogEntry } from '../api';
|
import type { LogCategory, LogsInfo, ServiceLogEntry } from '../api';
|
||||||
import { fmt, known, plural } from '../../shared/i18n';
|
import { fmt, known, plural } from '../../shared/i18n';
|
||||||
import { LOG_TEMPLATES } from './log-templates';
|
import { LOG_TEMPLATES } from './log-templates';
|
||||||
@@ -136,13 +137,25 @@ export function changedText(detail: string): string {
|
|||||||
.join(', ');
|
.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A device's settings a device_changed event lists (its link options, "mtu, keepalive"); anything else as written. */
|
/**
|
||||||
|
* A device's settings a device_changed event lists: each with what it became
|
||||||
|
* ("lan_bypass=on", "kind=phone", "mtu=1400", "keepalive=auto": the server's),
|
||||||
|
* or by name alone as events before 0.18 have them ("mtu, keepalive");
|
||||||
|
* anything else as written.
|
||||||
|
*/
|
||||||
export function deviceChangedText(detail: string): string {
|
export function deviceChangedText(detail: string): string {
|
||||||
const f: Record<string, string> = { mtu: 'MTU', keepalive: _('keep-alive'), lan_bypass: _('LAN Bypass') };
|
const f: Record<string, string> = { mtu: 'MTU', keepalive: _('keep-alive'), lan_bypass: _('LAN Bypass'), kind: _('type') };
|
||||||
return detail
|
const one = (part: string): string => {
|
||||||
.split(', ')
|
const at = part.indexOf('=');
|
||||||
.map((k) => f[k] ?? k)
|
if (at < 0) return f[part] ?? part;
|
||||||
.join(', ');
|
const k = part.slice(0, at);
|
||||||
|
const v = part.slice(at + 1);
|
||||||
|
if (k === 'lan_bypass') return v === 'on' ? _('LAN Bypass on') : _('LAN Bypass off');
|
||||||
|
if (k === 'kind') return fmt(_('type: %s'), ['computer', 'phone', 'tablet', 'router', 'other'].includes(v) ? kindLabel(v as Kind) : v);
|
||||||
|
if (v === 'auto') return fmt(_('%s: automatic'), f[k] ?? k);
|
||||||
|
return k === 'keepalive' ? fmt(_('keep-alive %s s'), v) : `${f[k] ?? k} ${v}`;
|
||||||
|
};
|
||||||
|
return detail.split(', ').map(one).join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -69,7 +69,8 @@ function eventIcon(st: Names, e: LogEvent): string {
|
|||||||
/** A router day (YYYY-MM-DD) in the page's language; anything else as it came. */
|
/** A router day (YYYY-MM-DD) in the page's language; anything else as it came. */
|
||||||
const routerDay = (s: string) => (/^\d{4}-\d{2}-\d{2}$/.test(s) ? fmtDay(s) : s);
|
const routerDay = (s: string) => (/^\d{4}-\d{2}-\d{2}$/.test(s) ? fmtDay(s) : s);
|
||||||
|
|
||||||
export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
|
export function eventText(st: Pick<Status, 'people'>, e: LogEvent, personId?: string): Node[] {
|
||||||
|
const scoped = personId !== undefined && e.person === personId;
|
||||||
const person = st.people.find((p) => p.id === e.person);
|
const person = st.people.find((p) => p.id === e.person);
|
||||||
const who = person?.name ?? e.pname ?? e.person ?? '';
|
const who = person?.name ?? e.pname ?? e.person ?? '';
|
||||||
const dev = person?.devices.find((d) => d.id === e.device)?.name ?? e.dname ?? '';
|
const dev = person?.devices.find((d) => d.id === e.device)?.name ?? e.dname ?? '';
|
||||||
@@ -88,33 +89,49 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
|
|||||||
const w = _('You');
|
const w = _('You');
|
||||||
return s.startsWith(`${w} `) ? [E('span', { class: 'dl-you' }, w), ...say(s.slice(w.length), ...args)] : say(s, ...args);
|
return s.startsWith(`${w} `) ? [E('span', { class: 'dl-you' }, w), ...say(s.slice(w.length), ...args)] : say(s, ...args);
|
||||||
};
|
};
|
||||||
const wd = b(dev ? `${who} · ${dev}` : who);
|
const wd = b(scoped ? dev || _('a device') : dev ? `${who} · ${dev}` : who);
|
||||||
const detail = plainDetail(e);
|
const detail = plainDetail(e);
|
||||||
const devName = b(detail || dev || _('a device'));
|
const devName = b(detail || dev || _('a device'));
|
||||||
const by = eventBy(e);
|
const by = eventBy(e);
|
||||||
if (by === 'admin')
|
if (by === 'admin')
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case 'device_added':
|
case 'device_added':
|
||||||
return you(_('You added device %s for %s'), devName, b(who));
|
return scoped ? you(_('You added device %s'), devName) : you(_('You added device %s for %s'), devName, b(who));
|
||||||
case 'device_removed':
|
case 'device_removed':
|
||||||
return you(_('You removed device %s from %s'), devName, b(who));
|
return scoped ? you(_('You removed device %s'), devName) : you(_('You removed device %s from %s'), devName, b(who));
|
||||||
case 'paused':
|
case 'paused':
|
||||||
return you(_('You paused person %s'), b(who));
|
return scoped ? you(_('You paused access')) : you(_('You paused person %s'), b(who));
|
||||||
case 'resumed':
|
case 'resumed':
|
||||||
return you(_('You resumed person %s'), b(who));
|
return scoped ? you(_('You resumed access')) : you(_('You resumed person %s'), b(who));
|
||||||
case 'device_changed': {
|
case 'device_changed': {
|
||||||
const d = b(dev || _('a device'));
|
const d = b(dev || _('a device'));
|
||||||
if (detail.startsWith('renamed from '))
|
if (detail.startsWith('renamed from '))
|
||||||
return [...you(_('You renamed device %s of %s'), d, b(who)), m(` · ${fmt(_('was %s'), detail.slice(13))}`)];
|
return [
|
||||||
if (detail === 'turned off') return you(_('You turned off device %s of %s'), d, b(who));
|
...(scoped ? you(_('You renamed device %s'), d) : you(_('You renamed device %s of %s'), d, b(who))),
|
||||||
if (detail === 'turned on') return you(_('You turned on device %s of %s'), d, b(who));
|
m(` · ${fmt(_('was %s'), detail.slice(13))}`),
|
||||||
|
];
|
||||||
|
if (detail === 'turned off')
|
||||||
|
return scoped ? you(_('You turned off device %s'), d) : you(_('You turned off device %s of %s'), d, b(who));
|
||||||
|
if (detail === 'turned on')
|
||||||
|
return scoped ? you(_('You turned on device %s'), d) : you(_('You turned on device %s of %s'), d, b(who));
|
||||||
// Its own link options by name ("mtu, keepalive"), as person_changed lists a person's.
|
// Its own link options by name ("mtu, keepalive"), as person_changed lists a person's.
|
||||||
return [...you(_('You changed device %s of %s'), d, b(who)), ...(detail ? [m(` · ${deviceChangedText(detail)}`)] : [])];
|
return [
|
||||||
|
...(scoped ? you(_('You changed device %s'), d) : you(_('You changed device %s of %s'), d, b(who))),
|
||||||
|
...(detail ? [m(` · ${deviceChangedText(detail)}`)] : []),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
case 'device_keys':
|
case 'device_keys':
|
||||||
return [...you(_('You issued new keys for device %s of %s'), devName, b(who)), m(` · ${_('it needs its new configuration')}`)];
|
return [
|
||||||
|
...(scoped
|
||||||
|
? you(_('You issued new keys for device %s'), devName)
|
||||||
|
: you(_('You issued new keys for device %s of %s'), devName, b(who))),
|
||||||
|
m(` · ${_('it needs its new configuration')}`),
|
||||||
|
];
|
||||||
case 'link_changed':
|
case 'link_changed':
|
||||||
return [...you(_('You issued a new link for person %s'), b(who)), m(` · ${_('the old link stopped working')}`)];
|
return [
|
||||||
|
...(scoped ? you(_('You issued a new personal link')) : you(_('You issued a new link for person %s'), b(who))),
|
||||||
|
m(` · ${_('the old link stopped working')}`),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
switch (e.type) {
|
switch (e.type) {
|
||||||
case 'connect':
|
case 'connect':
|
||||||
@@ -136,34 +153,84 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
|
|||||||
);
|
);
|
||||||
case 'device_added':
|
case 'device_added':
|
||||||
return by === 'portal'
|
return by === 'portal'
|
||||||
? say(_('Person %s added device %s on their portal'), b(who), devName)
|
? scoped
|
||||||
|
? say(_('Device %s added on the portal'), devName)
|
||||||
|
: say(_('Person %s added device %s on their portal'), b(who), devName)
|
||||||
|
: scoped
|
||||||
|
? say(_('Device %s added'), devName)
|
||||||
: say(_('Person %s added device %s'), b(who), devName);
|
: say(_('Person %s added device %s'), b(who), devName);
|
||||||
case 'device_removed':
|
case 'device_removed':
|
||||||
return by === 'portal'
|
return by === 'portal'
|
||||||
? say(_('Person %s removed device %s on their portal'), b(who), devName)
|
? scoped
|
||||||
|
? say(_('Device %s removed on the portal'), devName)
|
||||||
|
: say(_('Person %s removed device %s on their portal'), b(who), devName)
|
||||||
|
: scoped
|
||||||
|
? say(_('Device %s removed'), devName)
|
||||||
: say(_('Person %s removed device %s'), b(who), devName);
|
: say(_('Person %s removed device %s'), b(who), devName);
|
||||||
|
case 'device_changed':
|
||||||
|
if (detail.startsWith('renamed from '))
|
||||||
|
return [
|
||||||
|
...(by === 'portal'
|
||||||
|
? scoped
|
||||||
|
? say(_('Device %s renamed on the portal'), b(dev || _('a device')))
|
||||||
|
: say(_('Person %s renamed device %s on their portal'), b(who), b(dev || _('a device')))
|
||||||
|
: say(_('Device %s renamed'), wd)),
|
||||||
|
m(` · ${fmt(_('was %s'), detail.slice(13))}`),
|
||||||
|
];
|
||||||
|
if (detail === 'turned off') return say(_('Device %s turned off'), wd);
|
||||||
|
if (detail === 'turned on') return say(_('Device %s turned on'), wd);
|
||||||
|
// On the portal: LAN Bypass from its ⋯ menu, what it is and LAN Bypass with Reconnect.
|
||||||
|
if (by === 'portal')
|
||||||
|
return [
|
||||||
|
...(scoped
|
||||||
|
? say(_('Device %s changed on the portal'), b(dev || _('a device')))
|
||||||
|
: say(_('Person %s changed device %s on their portal'), b(who), b(dev || _('a device')))),
|
||||||
|
...(detail ? [m(` · ${deviceChangedText(detail)}`)] : []),
|
||||||
|
];
|
||||||
|
return [...say(_('Device %s changed'), wd), ...(detail ? [m(` · ${deviceChangedText(detail)}`)] : [])];
|
||||||
case 'device_keys':
|
case 'device_keys':
|
||||||
return say(_('Person %s issued new keys for device %s on their portal'), b(who), devName);
|
return scoped
|
||||||
|
? say(_('New keys issued for device %s on the portal'), devName)
|
||||||
|
: say(_('Person %s issued new keys for device %s on their portal'), b(who), devName);
|
||||||
case 'person_added':
|
case 'person_added':
|
||||||
return you(_('You added person %s'), b(e.detail ?? who));
|
return scoped ? you(_('You added this person')) : you(_('You added person %s'), b(e.detail ?? who));
|
||||||
case 'person_removed':
|
case 'person_removed':
|
||||||
return you(_('You removed person %s'), b(e.detail ?? who));
|
return scoped ? you(_('You removed this person')) : you(_('You removed person %s'), b(e.detail ?? who));
|
||||||
case 'person_changed':
|
case 'person_changed':
|
||||||
// The detail lists changed fields by their option names (device_limit, expire_action).
|
// The detail lists changed fields by their option names (device_limit, expire_action).
|
||||||
return [...you(_('You changed person %s'), b(who)), ...(detail ? [m(` · ${changedText(detail)}`)] : [])];
|
return [
|
||||||
|
...(scoped ? you(_('You changed settings')) : you(_('You changed person %s'), b(who))),
|
||||||
|
...(detail ? [m(` · ${changedText(detail)}`)] : []),
|
||||||
|
];
|
||||||
case 'expiring': {
|
case 'expiring': {
|
||||||
const n = daysOf(e.detail ?? '');
|
const n = daysOf(e.detail ?? '');
|
||||||
return n != null
|
return n != null
|
||||||
? say(N_(n, 'Person %s’s access ends in %s day', 'Person %s’s access ends in %s days'), b(who), m(num(n)))
|
? scoped
|
||||||
|
? say(N_(n, 'Access ends in %s day', 'Access ends in %s days'), m(num(n)))
|
||||||
|
: say(N_(n, 'Person %s’s access ends in %s day', 'Person %s’s access ends in %s days'), b(who), m(num(n)))
|
||||||
|
: scoped
|
||||||
|
? say(_('Access ends in a few days'))
|
||||||
: say(_('Person %s’s access ends in a few days'), b(who));
|
: say(_('Person %s’s access ends in a few days'), b(who));
|
||||||
}
|
}
|
||||||
case 'expired_kept':
|
case 'expired_kept':
|
||||||
return say(_('Person %s’s end date passed (%s) · access kept'), b(who), m(routerDay(e.detail ?? '')));
|
return scoped
|
||||||
|
? say(_('End date passed (%s) · access kept'), m(routerDay(e.detail ?? '')))
|
||||||
|
: say(_('Person %s’s end date passed (%s) · access kept'), b(who), m(routerDay(e.detail ?? '')));
|
||||||
case 'paused':
|
case 'paused':
|
||||||
return e.detail ? say(_('Person %s paused - %s'), b(who), m(reasonText(e.detail))) : say(_('Person %s paused'), b(who));
|
return e.detail
|
||||||
|
? scoped
|
||||||
|
? say(_('Access paused - %s'), m(reasonText(e.detail)))
|
||||||
|
: say(_('Person %s paused - %s'), b(who), m(reasonText(e.detail)))
|
||||||
|
: scoped
|
||||||
|
? say(_('Access paused'))
|
||||||
|
: say(_('Person %s paused'), b(who));
|
||||||
case 'resumed':
|
case 'resumed':
|
||||||
return e.detail && e.detail !== 'active'
|
return e.detail && e.detail !== 'active'
|
||||||
? say(_('Person %s resumed - %s'), b(who), m(reasonText(e.detail)))
|
? scoped
|
||||||
|
? say(_('Access resumed - %s'), m(reasonText(e.detail)))
|
||||||
|
: say(_('Person %s resumed - %s'), b(who), m(reasonText(e.detail)))
|
||||||
|
: scoped
|
||||||
|
? say(_('Access resumed'))
|
||||||
: say(_('Person %s resumed'), b(who));
|
: say(_('Person %s resumed'), b(who));
|
||||||
case 'portal_blocked':
|
case 'portal_blocked':
|
||||||
return say(
|
return say(
|
||||||
@@ -172,7 +239,7 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent): Node[] {
|
|||||||
e.detail === 'all Cloudflare visitors' ? m(_('all Cloudflare visitors')) : mono(e.detail ?? ''),
|
e.detail === 'all Cloudflare visitors' ? m(_('all Cloudflare visitors')) : mono(e.detail ?? ''),
|
||||||
);
|
);
|
||||||
case 'devices_removed':
|
case 'devices_removed':
|
||||||
return say(_('Person %s - all devices removed, end date reached'), b(who));
|
return scoped ? say(_('All devices removed, end date reached')) : say(_('Person %s - all devices removed, end date reached'), b(who));
|
||||||
case 'device_failing':
|
case 'device_failing':
|
||||||
return [...say(_('Device %s has a connection problem'), wd), ...(e.detail ? [m(` · ${linkStatesText(e.detail)}`)] : [])];
|
return [...say(_('Device %s has a connection problem'), wd), ...(e.detail ? [m(` · ${linkStatesText(e.detail)}`)] : [])];
|
||||||
case 'device_recovered':
|
case 'device_recovered':
|
||||||
@@ -196,7 +263,11 @@ function serverPill(st: Names, e: LogEvent): HTMLElement | '' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** An activity event as a row; `time` replaces the "5 min ago" (`now` is the router's clock). */
|
/** An activity event as a row; `time` replaces the "5 min ago" (`now` is the router's clock). */
|
||||||
export function eventRow(st: Names & { now?: number }, e: LogEvent, opts: { server?: boolean; time?: string } = {}): HTMLElement {
|
export function eventRow(
|
||||||
|
st: Names & { now?: number },
|
||||||
|
e: LogEvent,
|
||||||
|
opts: { server?: boolean; time?: string; person?: string } = {},
|
||||||
|
): HTMLElement {
|
||||||
const sys = SYSTEM_EVENT[e.type];
|
const sys = SYSTEM_EVENT[e.type];
|
||||||
const by = eventBy(e);
|
const by = eventBy(e);
|
||||||
return E('div', { class: `dl-row${by === 'admin' ? ' dl-ev-by-admin' : sys ? ` dl-ev-by-system ${sys[1]}` : ''}` }, [
|
return E('div', { class: `dl-row${by === 'admin' ? ' dl-ev-by-admin' : sys ? ` dl-ev-by-system ${sys[1]}` : ''}` }, [
|
||||||
@@ -205,7 +276,7 @@ export function eventRow(st: Names & { now?: number }, e: LogEvent, opts: { serv
|
|||||||
: sys
|
: sys
|
||||||
? E('span', { class: 'dl-ev-tile sys' }, icon(sys[0]))
|
? E('span', { class: 'dl-ev-tile sys' }, icon(sys[0]))
|
||||||
: E('span', { class: `dl-ev-tile ev ${EVENT_TONE[e.type] ?? ''}` }, icon(eventIcon(st, e))),
|
: E('span', { class: `dl-ev-tile ev ${EVENT_TONE[e.type] ?? ''}` }, icon(eventIcon(st, e))),
|
||||||
E('span', { class: 'dl-row-main' }, eventText(st, e)),
|
E('span', { class: 'dl-row-main' }, eventText(st, e, opts.person)),
|
||||||
opts.server === false ? '' : serverPill(st, e),
|
opts.server === false ? '' : serverPill(st, e),
|
||||||
E('span', { class: 'dl-faint dl-nowrap', title: new Date(e.ts * 1000).toLocaleString(locale()) }, opts.time ?? ago(e.ts, st.now)),
|
E('span', { class: 'dl-faint dl-nowrap', title: new Date(e.ts * 1000).toLocaleString(locale()) }, opts.time ?? ago(e.ts, st.now)),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ async function toPng(svg: string): Promise<Blob> {
|
|||||||
type Invitee = Pick<Person, 'id' | 'name'> & { link?: string | null; links?: string[] };
|
type Invitee = Pick<Person, 'id' | 'name'> & { link?: string | null; links?: string[] };
|
||||||
|
|
||||||
/** The personal link and its other addresses (person_links); null while the portal is off. */
|
/** The personal link and its other addresses (person_links); null while the portal is off. */
|
||||||
export async function personLinks(id: string): Promise<{ link: string; links: string[] } | null> {
|
async function personLinks(id: string): Promise<{ link: string; links: string[] } | null> {
|
||||||
const r = await attempt(() => api.personLinks(id));
|
const r = await attempt(() => api.personLinks(id));
|
||||||
if (!r) return null;
|
if (!r) return null;
|
||||||
if (!r.link) {
|
if (!r.link) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function moved(tab: '' | 'log') {
|
|||||||
return () => ({
|
return () => ({
|
||||||
load: () => {
|
load: () => {
|
||||||
ui.menu?.flushCache();
|
ui.menu?.flushCache();
|
||||||
location.replace(`${L.url('admin/network/dawnline/diagnostics')}${tab ? `?tab=${tab}` : ''}`);
|
location.replace(`${L.url('admin/services/dawnline/diagnostics')}${tab ? `?tab=${tab}` : ''}`);
|
||||||
return new Promise(() => {});
|
return new Promise(() => {});
|
||||||
},
|
},
|
||||||
render: () => document.createElement('div'),
|
render: () => document.createElement('div'),
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export interface MapData {
|
|||||||
* The latest point per device inside the time window: per device and city on a
|
* The latest point per device inside the time window: per device and city on a
|
||||||
* person's page, per city in a device's window.
|
* person's page, per city in a device's window.
|
||||||
*/
|
*/
|
||||||
export function visiblePoints(data: MapData, range: Range): GeoPoint[] {
|
function visiblePoints(data: MapData, range: Range): GeoPoint[] {
|
||||||
const best = new Map<string, GeoPoint>();
|
const best = new Map<string, GeoPoint>();
|
||||||
for (const p of data.geo.points) {
|
for (const p of data.geo.points) {
|
||||||
if (data.person && p.person !== data.person) continue;
|
if (data.person && p.person !== data.person) continue;
|
||||||
@@ -1233,7 +1233,7 @@ function face(slot: { el: HTMLElement; at: [number, number]; who?: string; where
|
|||||||
* when `quiet`: a redraw), gone ones leave the row at once and shrink away where they were, the
|
* when `quiet`: a redraw), gone ones leave the row at once and shrink away where they were, the
|
||||||
* "+N" is one element whose number changes, and the plate's width follows smoothly.
|
* "+N" is one element whose number changes, and the plate's width follows smoothly.
|
||||||
*/
|
*/
|
||||||
export function fillFaces(
|
function fillFaces(
|
||||||
box: HTMLElement,
|
box: HTMLElement,
|
||||||
faces: Face[],
|
faces: Face[],
|
||||||
on: { click: (f: Face, b: HTMLElement) => void; hover: (f: Face | null) => void },
|
on: { click: (f: Face, b: HTMLElement) => void; hover: (f: Face | null) => void },
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ export function portalPortHelp(port: number, taken: PortHold[], ipLinks: boolean
|
|||||||
export const chars = (s: string): number => Array.from(s).length;
|
export const chars = (s: string): number => Array.from(s).length;
|
||||||
|
|
||||||
const NAME_MAX = 48;
|
const NAME_MAX = 48;
|
||||||
|
// oxlint-disable-next-line no-control-regex -- control characters are what it refuses
|
||||||
const BAD_NAME = /[<>"\\\u0000-\u001f\u007f]/;
|
const BAD_NAME = /[<>"\\\u0000-\u001f\u007f]/;
|
||||||
|
|
||||||
/** "Up to 48 characters (50 now).": a name over its limit. */
|
/** "Up to 48 characters (50 now).": a name over its limit. */
|
||||||
@@ -147,7 +148,7 @@ export function isIpv4(s: string): boolean {
|
|||||||
return !!m && m.slice(1).every((x) => Number(x) <= 255);
|
return !!m && m.slice(1).every((x) => Number(x) <= 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIpv6(s: string): boolean {
|
function isIpv6(s: string): boolean {
|
||||||
return /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(s) && !/:::/.test(s);
|
return /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(s) && !/:::/.test(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ export function hostHelp(s: string, port?: number, empty: string | null = null):
|
|||||||
if (!t) return empty != null ? { text: empty, bad: false } : { text: _('Enter a hostname or IP address.'), bad: true };
|
if (!t) return empty != null ? { text: empty, bad: false } : { text: _('Enter a hostname or IP address.'), bad: true };
|
||||||
if (/^[a-z]+:\/\//i.test(t)) return { text: _('Leave out https:// - just the name.'), bad: true };
|
if (/^[a-z]+:\/\//i.test(t)) return { text: _('Leave out https:// - just the name.'), bad: true };
|
||||||
if (/\/.*/.test(t)) return { text: _('Just the name, without a path.'), bad: true };
|
if (/\/.*/.test(t)) return { text: _('Just the name, without a path.'), bad: true };
|
||||||
if (/^[^:\[]+:\d+$/.test(t)) return { text: _('Just the name, without a port (the port is on AmneziaWG).'), bad: true };
|
if (/^[^:[]+:\d+$/.test(t)) return { text: _('Just the name, without a port (the port is on AmneziaWG).'), bad: true };
|
||||||
if (/\s/.test(t)) return { text: _('A hostname has no spaces.'), bad: true };
|
if (/\s/.test(t)) return { text: _('A hostname has no spaces.'), bad: true };
|
||||||
if (t.length > 253 || !(HOSTNAME.test(t) || isIpv4(t) || isIpv6(t))) return { text: _('Use a hostname or an IP address.'), bad: true };
|
if (t.length > 253 || !(HOSTNAME.test(t) || isIpv4(t) || isIpv6(t))) return { text: _('Use a hostname or an IP address.'), bad: true };
|
||||||
const shown = isIpv6(t) ? `[${t}]` : t;
|
const shown = isIpv6(t) ? `[${t}]` : t;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export function activity(page: ComponentsPage): HTMLElement {
|
|||||||
E('div', { class: 'dl-panel-head pad' }, [
|
E('div', { class: 'dl-panel-head pad' }, [
|
||||||
E('h3', {}, _('Activity')),
|
E('h3', {}, _('Activity')),
|
||||||
E('span', { class: 'dl-spacer' }),
|
E('span', { class: 'dl-spacer' }),
|
||||||
E('a', { href: `${L.url('admin/network/dawnline/diagnostics')}?tab=log` }, _('All in Log →')),
|
E('a', { href: `${L.url('admin/services/dawnline/diagnostics')}?tab=log` }, _('All in Log →')),
|
||||||
]),
|
]),
|
||||||
h.length
|
h.length
|
||||||
? E('div', {}, h.slice(0, 8).map(row))
|
? E('div', {}, h.slice(0, 8).map(row))
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ export class ComponentsPage {
|
|||||||
E('div', { class: 'dl-row-actions' }, [
|
E('div', { class: 'dl-row-actions' }, [
|
||||||
E(
|
E(
|
||||||
'a',
|
'a',
|
||||||
{ class: 'cbi-button cbi-button-neutral dl-icon-btn', href: `${L.url('admin/network/dawnline/settings')}?section=updates` },
|
{ class: 'cbi-button cbi-button-neutral dl-icon-btn', href: `${L.url('admin/services/dawnline/settings')}?section=updates` },
|
||||||
[icon('edit'), ' ', _('Settings')],
|
[icon('edit'), ' ', _('Settings')],
|
||||||
),
|
),
|
||||||
button([icon('refresh'), ' ', _('Check all')], () => this.op('check', _('Checking all components')), 'neutral', {
|
button([icon('refresh'), ' ', _('Check all')], () => this.op('check', _('Checking all components')), 'neutral', {
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
// online, traffic, disguise, the connection map, activity and what needs
|
// online, traffic, disguise, the connection map, activity and what needs
|
||||||
// attention — all limited to the people on that server.
|
// attention — all limited to the people on that server.
|
||||||
|
|
||||||
import type { Device, Person, Status } from '../../shared/types';
|
import type { Device, GeoPoint, Person, Status } from '../../shared/types';
|
||||||
import { E } from '../e';
|
import { E } from '../e';
|
||||||
import { api } from '../api';
|
import { api } from '../api';
|
||||||
import { svg } from '../ui/layout';
|
import { attachTip, refreshTip } from '../ui/tooltip';
|
||||||
import { attachTip } from '../ui/tooltip';
|
|
||||||
import { icon } from '../../shared/icons';
|
import { icon } from '../../shared/icons';
|
||||||
import { ago, bits, bytes, date, daysLeft, duration, endsIn, endsSoon, initials, todayOf } from '../../shared/format';
|
import { ago, bits, bytes, date, daysLeft, duration, endsIn, endsSoon, initials, todayOf } from '../../shared/format';
|
||||||
import { fill, fmt, plural } from '../../shared/i18n';
|
import { fill, fmt, plural } from '../../shared/i18n';
|
||||||
@@ -17,6 +16,7 @@ import { scoped } from '../state/scope';
|
|||||||
import { focusInside, repaint } from '../state/poller';
|
import { focusInside, repaint } from '../state/poller';
|
||||||
import type { LiveMeter } from '../state/meter';
|
import type { LiveMeter } from '../state/meter';
|
||||||
import { daysTile, LiveSpeedTile } from '../widgets/tiles';
|
import { daysTile, LiveSpeedTile } from '../widgets/tiles';
|
||||||
|
import { SpeedLines } from '../widgets/lines';
|
||||||
import { coreOf } from '../cores';
|
import { coreOf } from '../cores';
|
||||||
import { healthNotices, runFix } from '../widgets/health';
|
import { healthNotices, runFix } from '../widgets/health';
|
||||||
import { attempt } from '../ui/toast';
|
import { attempt } from '../ui/toast';
|
||||||
@@ -34,7 +34,7 @@ interface Attention {
|
|||||||
function attention(st: Status): Attention[] {
|
function attention(st: Status): Attention[] {
|
||||||
const out: Attention[] = [];
|
const out: Attention[] = [];
|
||||||
const link = (href: string, t: string) => E('a', { href }, t);
|
const link = (href: string, t: string) => E('a', { href }, t);
|
||||||
const diagnostics = () => link(L.url('admin/network/dawnline/diagnostics'), _('Open Diagnostics'));
|
const diagnostics = () => link(L.url('admin/services/dawnline/diagnostics'), _('Open Diagnostics'));
|
||||||
const today = todayOf(st.series);
|
const today = todayOf(st.series);
|
||||||
// AmneziaWG itself can't run: the health notice says so once, not "Tunnel down" for every server.
|
// AmneziaWG itself can't run: the health notice says so once, not "Tunnel down" for every server.
|
||||||
const awg = !!st.awg_state && !st.awg_state.ok;
|
const awg = !!st.awg_state && !st.awg_state.ok;
|
||||||
@@ -111,12 +111,12 @@ function attention(st: Status): Attention[] {
|
|||||||
text: [
|
text: [
|
||||||
fmt(_('Internet through the LAN is off: %s'), st.like_home.error),
|
fmt(_('Internet through the LAN is off: %s'), st.like_home.error),
|
||||||
' ',
|
' ',
|
||||||
link(L.url('admin/network/dawnline/diagnostics'), _('Details')),
|
link(L.url('admin/services/dawnline/diagnostics'), _('Details')),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
// Only while setting up: an admin who keeps the portal off has decided so.
|
// Only while setting up: an admin who keeps the portal off has decided so.
|
||||||
if (!st.settings.portal_enabled && !st.people.length)
|
if (!st.settings.portal_enabled && !st.people.length)
|
||||||
out.push({ tone: '', text: [_('The personal portal is off.'), ' ', link(L.url('admin/network/dawnline/settings'), _('Turn on'))] });
|
out.push({ tone: '', text: [_('The personal portal is off.'), ' ', link(L.url('admin/services/dawnline/settings'), _('Turn on'))] });
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ export class ServerOverview {
|
|||||||
E(
|
E(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'dl-map-off' },
|
{ class: 'dl-map-off' },
|
||||||
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/network/dawnline/settings') }, _('Turn them on in Settings'))),
|
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/services/dawnline/settings') }, _('Turn them on in Settings'))),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
const map = (this.map = new ConnectionMap(
|
const map = (this.map = new ConnectionMap(
|
||||||
@@ -268,7 +268,7 @@ export class ServerOverview {
|
|||||||
E('div', { class: 'dl-panel-head pad' }, [
|
E('div', { class: 'dl-panel-head pad' }, [
|
||||||
E('h3', {}, _('Needs attention')),
|
E('h3', {}, _('Needs attention')),
|
||||||
E('span', { class: 'dl-spacer' }),
|
E('span', { class: 'dl-spacer' }),
|
||||||
E('a', { href: L.url('admin/network/dawnline/diagnostics') }, _('Health')),
|
E('a', { href: L.url('admin/services/dawnline/diagnostics') }, _('Health')),
|
||||||
]),
|
]),
|
||||||
att.length
|
att.length
|
||||||
? att
|
? att
|
||||||
@@ -292,7 +292,7 @@ export class ServerOverview {
|
|||||||
E('div', { class: 'dl-panel-head pad' }, [
|
E('div', { class: 'dl-panel-head pad' }, [
|
||||||
E('h3', {}, _('Activity')),
|
E('h3', {}, _('Activity')),
|
||||||
E('span', { class: 'dl-spacer' }),
|
E('span', { class: 'dl-spacer' }),
|
||||||
E('a', { href: `${L.url('admin/network/dawnline/diagnostics')}?tab=log` }, _('View all')),
|
E('a', { href: `${L.url('admin/services/dawnline/diagnostics')}?tab=log` }, _('View all')),
|
||||||
]),
|
]),
|
||||||
events.length
|
events.length
|
||||||
? events.map((e) => eventRow(st, e))
|
? events.map((e) => eventRow(st, e))
|
||||||
@@ -316,7 +316,11 @@ export class ServerOverview {
|
|||||||
const [rx, tx] = d.spark[d.spark.length - 1] ?? [0, 0];
|
const [rx, tx] = d.spark[d.spark.length - 1] ?? [0, 0];
|
||||||
return rx + tx;
|
return rx + tx;
|
||||||
};
|
};
|
||||||
const cityOf = (d: Device) => st.geo.points.find((g) => g.device === d.id && g.city)?.city;
|
// The address it is connected from now, else the newest one (the points come oldest first).
|
||||||
|
const cityOf = (d: Device) => {
|
||||||
|
const pts = st.geo.points.filter((g) => g.device === d.id && g.city);
|
||||||
|
return (pts.find((g) => g.online) ?? pts.reduce<GeoPoint | undefined>((a, g) => (a && a.ts >= g.ts ? a : g), undefined))?.city;
|
||||||
|
};
|
||||||
const home = (d: Device) => /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(d.endpoint ?? '');
|
const home = (d: Device) => /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(d.endpoint ?? '');
|
||||||
// Where a device is: its city, or "LAN" when it connects from the home network (the hover
|
// Where a device is: its city, or "LAN" when it connects from the home network (the hover
|
||||||
// card adds its address there).
|
// card adds its address there).
|
||||||
@@ -331,20 +335,22 @@ export class ServerOverview {
|
|||||||
const card = ({ p, devs }: { p: Person; devs: Device[] }): Node[] => {
|
const card = ({ p, devs }: { p: Person; devs: Device[] }): Node[] => {
|
||||||
const starts = devs.map(connectedAt).filter(Boolean);
|
const starts = devs.map(connectedAt).filter(Boolean);
|
||||||
const since = starts.length ? Math.min(...starts) : 0;
|
const since = starts.length ? Math.min(...starts) : 0;
|
||||||
const pts = (p.rate ?? []).slice(-15);
|
// The live meter's last 2 minutes of their devices while it has them (the card is drawn again each
|
||||||
|
// second it shows, paintSpeed), else their last 15 minutes.
|
||||||
|
const ls = this.meter.speed(
|
||||||
|
p.server,
|
||||||
|
Date.now(),
|
||||||
|
p.devices.map((d) => d.id),
|
||||||
|
);
|
||||||
|
const live = ls.pts.length > 1;
|
||||||
|
const pts = live ? ls.pts : (p.rate ?? []).slice(-15);
|
||||||
|
const xs = live ? ls.xs : pts.map((_x, i) => (pts.length > 1 ? i / (pts.length - 1) : 1));
|
||||||
const last = pts[pts.length - 1];
|
const last = pts[pts.length - 1];
|
||||||
const fresh = last && st.now - last[0] < 180 ? last : null;
|
const fresh = live ? ([0, ls.rx, ls.tx] as const) : last && st.now - last[0] < 180 ? last : null;
|
||||||
const W = 200,
|
// The card's speed box is 228 px inside (280, less the card's and the box's padding).
|
||||||
H = 30,
|
const lines = pts.length > 1 ? new SpeedLines(30, true, 228) : null;
|
||||||
max = Math.max(1, ...pts.map((x) => Math.max(x[1], x[2])));
|
lines?.set(pts, xs);
|
||||||
const line = (k: 1 | 2) => pts.map((x, i) => `${pts.length > 1 ? (i / (pts.length - 1)) * W : W},${H - 2 - (x[k] / max) * (H - 6)}`);
|
const chart = lines?.el ?? '';
|
||||||
const chart =
|
|
||||||
pts.length > 1
|
|
||||||
? svg(
|
|
||||||
`<svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" class="dl-hc-chart" aria-hidden="true">` +
|
|
||||||
`<path d="M${line(2).join(' L')} L${W},${H} L0,${H}Z" class="area"/><path d="M${line(2).join(' L')}" class="dn"/><path d="M${line(1).join(' L')}" class="up"/></svg>`,
|
|
||||||
)
|
|
||||||
: '';
|
|
||||||
const idle = !fresh || (fresh[1] < 64 && fresh[2] < 64);
|
const idle = !fresh || (fresh[1] < 64 && fresh[2] < 64);
|
||||||
const reach = p.access === 'both' ? ['home', 'globe'] : p.access === 'lan' ? ['home'] : ['globe'];
|
const reach = p.access === 'both' ? ['home', 'globe'] : p.access === 'lan' ? ['home'] : ['globe'];
|
||||||
return [
|
return [
|
||||||
@@ -371,7 +377,7 @@ export class ServerOverview {
|
|||||||
E('span', {}, [E('span', { class: 'dl-dn' }, '↓'), ` ${bits(fresh![2])}`]),
|
E('span', {}, [E('span', { class: 'dl-dn' }, '↓'), ` ${bits(fresh![2])}`]),
|
||||||
E('span', {}, [E('span', { class: 'dl-up' }, '↑'), ` ${bits(fresh![1])}`]),
|
E('span', {}, [E('span', { class: 'dl-up' }, '↑'), ` ${bits(fresh![1])}`]),
|
||||||
E('span', { class: 'dl-spacer' }),
|
E('span', { class: 'dl-spacer' }),
|
||||||
E('span', { class: 'dl-faint' }, _('15 min')),
|
E('span', { class: 'dl-faint' }, live ? _('2 min') : _('15 min')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
chart,
|
chart,
|
||||||
@@ -395,17 +401,32 @@ export class ServerOverview {
|
|||||||
const person = (x: { p: Person; devs: Device[] }) => {
|
const person = (x: { p: Person; devs: Device[] }) => {
|
||||||
const { p, devs } = x;
|
const { p, devs } = x;
|
||||||
const badge = E('span', { class: 'dl-onl-dev' }, devs.length > 1 ? String(devs.length) : icon(devs[0].kind));
|
const badge = E('span', { class: 'dl-onl-dev' }, devs.length > 1 ? String(devs.length) : icon(devs[0].kind));
|
||||||
const el = E('a', { class: `dl-onl-p${big ? '' : ' sm'}`, href: personUrl(p.id), 'aria-label': fmt(_('%s, online'), p.name) }, [
|
// Every place their devices are, once, the busiest device's first: "Krasnodar · Moscow", or
|
||||||
E('span', { class: 'dl-onl-av' }, [initials(p.name), badge]),
|
// "Krasnodar +1" when two do not fit under the avatar, "3 cities" from three on (the card names each).
|
||||||
big ? E('span', { class: 'dl-onl-name' }, p.name) : '',
|
const places = [...new Set(devs.map((d) => where(d)).filter(Boolean))];
|
||||||
big
|
const full = places.length > 2 ? plural(places.length, '%s city', '%s cities') : places.join(' · ');
|
||||||
|
const place = E('span', {}, full ? [' · ', full] : '');
|
||||||
|
const meta = big
|
||||||
? E('span', { class: 'dl-onl-meta' }, [
|
? E('span', { class: 'dl-onl-meta' }, [
|
||||||
...devs.slice(0, 3).map((d) => icon(d.kind)),
|
...devs.slice(0, 3).map((d) => icon(d.kind)),
|
||||||
devs.length > 3 ? `+${devs.length - 3}` : '',
|
devs.length > 3 ? `+${devs.length - 3}` : '',
|
||||||
where(devs[0]) ? E('span', {}, [' · ', where(devs[0])]) : '',
|
place,
|
||||||
])
|
])
|
||||||
: '',
|
: '';
|
||||||
|
const el = E('a', { class: `dl-onl-p${big ? '' : ' sm'}`, href: personUrl(p.id), 'aria-label': fmt(_('%s, online'), p.name) }, [
|
||||||
|
E('span', { class: 'dl-onl-av' }, [initials(p.name), badge]),
|
||||||
|
big ? E('span', { class: 'dl-onl-name' }, p.name) : '',
|
||||||
|
meta,
|
||||||
]);
|
]);
|
||||||
|
if (meta && places.length === 2) {
|
||||||
|
// Measured where it stands (the person is a fixed width, so swapping the words never resizes what is observed).
|
||||||
|
const fit = new ResizeObserver(() => {
|
||||||
|
if (!el.isConnected) return fit.disconnect();
|
||||||
|
place.textContent = ` · ${full}`;
|
||||||
|
if (meta.scrollWidth > meta.clientWidth) place.textContent = ` · ${places[0]} +1`;
|
||||||
|
});
|
||||||
|
fit.observe(el);
|
||||||
|
}
|
||||||
attachTip(el, () => card(x));
|
attachTip(el, () => card(x));
|
||||||
return el;
|
return el;
|
||||||
};
|
};
|
||||||
@@ -428,7 +449,7 @@ export class ServerOverview {
|
|||||||
'a',
|
'a',
|
||||||
{
|
{
|
||||||
class: 'dl-onl-p sm more',
|
class: 'dl-onl-p sm more',
|
||||||
href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,
|
href: `${L.url('admin/services/dawnline/server')}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,
|
||||||
title: _('Everyone online'),
|
title: _('Everyone online'),
|
||||||
click: (ev: Event) => {
|
click: (ev: Event) => {
|
||||||
if (this.go) {
|
if (this.go) {
|
||||||
@@ -465,6 +486,8 @@ export class ServerOverview {
|
|||||||
if (!this.st) return;
|
if (!this.st) return;
|
||||||
const srv = this.st.servers[0];
|
const srv = this.st.servers[0];
|
||||||
this.speed.update(this.meter.speed(this.srvId, Date.now()), this.st.totals.today, srv ? !srv.enabled : false);
|
this.speed.update(this.meter.speed(this.srvId, Date.now()), this.st.totals.today, srv ? !srv.enabled : false);
|
||||||
|
// A person's card under the pointer follows the same second.
|
||||||
|
refreshTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The last 30 days, today on the right, with the peak. */
|
/** The last 30 days, today on the right, with the peak. */
|
||||||
|
|||||||
@@ -10,13 +10,16 @@ import { cancelButton, closeModal, confirmDialog, modal } from '../ui/modal';
|
|||||||
import { copyText } from '../ui/files';
|
import { copyText } from '../ui/files';
|
||||||
import { dropdown, type MenuItem } from '../ui/menu';
|
import { dropdown, type MenuItem } from '../ui/menu';
|
||||||
import { attempt, notify } from '../ui/toast';
|
import { attempt, notify } from '../ui/toast';
|
||||||
import { attachTip } from '../ui/tooltip';
|
import { pointTip } from '../ui/glide';
|
||||||
|
import { limitMeter, splitMeter } from '../widgets/meter';
|
||||||
|
import { paceOf, paceWords, weekAhead } from '../../shared/pace';
|
||||||
import { accessBadge } from '../ui/badges';
|
import { accessBadge } from '../ui/badges';
|
||||||
import { addDevice, openDevice, type DeviceOpts } from '../device';
|
import { addDevice, openDevice, type DeviceOpts } from '../device';
|
||||||
import { copyPersonLink, inviteCard } from '../invite';
|
import { copyPersonLink, inviteCard } from '../invite';
|
||||||
import { personUrl } from '../urls';
|
import { personUrl } from '../urls';
|
||||||
import { scoped } from '../state/scope';
|
import { scoped } from '../state/scope';
|
||||||
import { createPoller, focusInside, type Poller } from '../state/poller';
|
import { createPoller, focusInside, type Poller } from '../state/poller';
|
||||||
|
import type { LiveMeter, Rate } from '../state/meter';
|
||||||
import { onNavigate } from '../ui/nav';
|
import { onNavigate } from '../ui/nav';
|
||||||
import { accessPicker } from '../widgets/access-picker';
|
import { accessPicker } from '../widgets/access-picker';
|
||||||
import { firstBad, liveField } from '../ui/layout';
|
import { firstBad, liveField } from '../ui/layout';
|
||||||
@@ -122,6 +125,11 @@ export class PeoplePage {
|
|||||||
serverId: string | null = null;
|
serverId: string | null = null;
|
||||||
el: HTMLElement | null = null;
|
el: HTMLElement | null = null;
|
||||||
poller?: Poller<Status>;
|
poller?: Poller<Status>;
|
||||||
|
/** Each online person's speed in their card, put in place each second from the meter (a server's People list). */
|
||||||
|
private speedEls = new Map<string, { p: Person; down: HTMLElement; up: HTMLElement }>();
|
||||||
|
|
||||||
|
/** `meter`: the Servers page's live meter, which it polls while this list shows (none on its own page). */
|
||||||
|
constructor(private meter?: LiveMeter) {}
|
||||||
|
|
||||||
async load(): Promise<Status> {
|
async load(): Promise<Status> {
|
||||||
return api.status(30);
|
return api.status(30);
|
||||||
@@ -226,22 +234,21 @@ export class PeoplePage {
|
|||||||
render(stAll: Status): Promise<Node> {
|
render(stAll: Status): Promise<Node> {
|
||||||
const st = this.scope(stAll);
|
const st = this.scope(stAll);
|
||||||
this.st = st;
|
this.st = st;
|
||||||
const page = this;
|
|
||||||
const sort = E(
|
const sort = E(
|
||||||
'select',
|
'select',
|
||||||
{
|
{
|
||||||
class: 'dl-select',
|
class: 'dl-select',
|
||||||
'aria-label': _('Sort'),
|
'aria-label': _('Sort'),
|
||||||
change: (ev: Event) => {
|
change: (ev: Event) => {
|
||||||
page.sort = (ev.target as HTMLSelectElement).value as SortBy;
|
this.sort = (ev.target as HTMLSelectElement).value as SortBy;
|
||||||
remember('dl.people.sort', page.sort);
|
remember('dl.people.sort', this.sort);
|
||||||
page.decorate();
|
this.decorate();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
E('option', { value: 'seen', selected: page.sort === 'seen' ? 'selected' : null }, _('Last seen', 'sort')),
|
E('option', { value: 'seen', selected: this.sort === 'seen' ? 'selected' : null }, _('Last seen', 'sort')),
|
||||||
E('option', { value: 'name', selected: page.sort === 'name' ? 'selected' : null }, _('Name', 'sort')),
|
E('option', { value: 'name', selected: this.sort === 'name' ? 'selected' : null }, _('Name', 'sort')),
|
||||||
E('option', { value: 'usage', selected: page.sort === 'usage' ? 'selected' : null }, _('Usage', 'sort')),
|
E('option', { value: 'usage', selected: this.sort === 'usage' ? 'selected' : null }, _('Usage', 'sort')),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
// Find, once the list is long enough to need it; "/" focuses it.
|
// Find, once the list is long enough to need it; "/" focuses it.
|
||||||
@@ -252,8 +259,8 @@ export class PeoplePage {
|
|||||||
'aria-label': _('Find a person or device'),
|
'aria-label': _('Find a person or device'),
|
||||||
hidden: st.people.length > 8 ? null : 'hidden',
|
hidden: st.people.length > 8 ? null : 'hidden',
|
||||||
input: (ev: Event) => {
|
input: (ev: Event) => {
|
||||||
page.query = (ev.target as HTMLInputElement).value.trim().toLowerCase();
|
this.query = (ev.target as HTMLInputElement).value.trim().toLowerCase();
|
||||||
page.decorate();
|
this.decorate();
|
||||||
},
|
},
|
||||||
}) as HTMLInputElement;
|
}) as HTMLInputElement;
|
||||||
const onSlash = (ev: KeyboardEvent) => {
|
const onSlash = (ev: KeyboardEvent) => {
|
||||||
@@ -266,14 +273,14 @@ export class PeoplePage {
|
|||||||
document.addEventListener('keydown', onSlash);
|
document.addEventListener('keydown', onSlash);
|
||||||
onNavigate(() => document.removeEventListener('keydown', onSlash));
|
onNavigate(() => document.removeEventListener('keydown', onSlash));
|
||||||
const wrap = E('div', { class: 'dl-root' }, [
|
const wrap = E('div', { class: 'dl-root' }, [
|
||||||
page.serverId
|
this.serverId
|
||||||
? ''
|
? ''
|
||||||
: E('div', { class: 'dl-pagehead' }, [
|
: E('div', { class: 'dl-pagehead' }, [
|
||||||
E('div', { class: 'dl-stack' }, [
|
E('div', { class: 'dl-stack' }, [
|
||||||
E('h2', { class: 'dl-h1' }, _('People')),
|
E('h2', { class: 'dl-h1' }, _('People')),
|
||||||
E('span', { class: 'dl-muted dl-people-count' }, this.countText()),
|
E('span', { class: 'dl-muted dl-people-count' }, this.countText()),
|
||||||
]),
|
]),
|
||||||
st.servers.length ? button([icon('plus'), ` ${_('Add person')}`], () => page.openCreate(), 'add') : '',
|
st.servers.length ? button([icon('plus'), ` ${_('Add person')}`], () => this.openCreate(), 'add') : '',
|
||||||
]),
|
]),
|
||||||
st.servers.length
|
st.servers.length
|
||||||
? ''
|
? ''
|
||||||
@@ -282,7 +289,7 @@ export class PeoplePage {
|
|||||||
{ class: 'alert-message warning' },
|
{ class: 'alert-message warning' },
|
||||||
fill(
|
fill(
|
||||||
_('No server yet. %s before adding people.'),
|
_('No server yet. %s before adding people.'),
|
||||||
E('a', { href: L.url('admin/network/dawnline/server') }, _('Run the setup wizard')),
|
E('a', { href: L.url('admin/services/dawnline/server') }, _('Run the setup wizard')),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
E('div', { class: 'dl-toolbar' }, [
|
E('div', { class: 'dl-toolbar' }, [
|
||||||
@@ -291,7 +298,7 @@ export class PeoplePage {
|
|||||||
E('div', { class: 'dl-toolbar-end' }, [
|
E('div', { class: 'dl-toolbar-end' }, [
|
||||||
find,
|
find,
|
||||||
sort,
|
sort,
|
||||||
page.serverId ? button([icon('plus'), ` ${_('Add person')}`], () => page.openCreate(), 'add') : '',
|
this.serverId ? button([icon('plus'), ` ${_('Add person')}`], () => this.openCreate(), 'add') : '',
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
this.list,
|
this.list,
|
||||||
@@ -303,13 +310,13 @@ export class PeoplePage {
|
|||||||
fetch: () => api.status(30),
|
fetch: () => api.status(30),
|
||||||
every: 30,
|
every: 30,
|
||||||
live: true,
|
live: true,
|
||||||
active: () => !!page.el?.isConnected,
|
active: () => !!this.el?.isConnected,
|
||||||
apply: (st, quiet) => page.take(st, quiet),
|
apply: (st, quiet) => this.take(st, quiet),
|
||||||
});
|
});
|
||||||
// ?add=1 opens Add person once, not again on every server's People tab.
|
// ?add=1 opens Add person once, not again on every server's People tab.
|
||||||
if (!addOpened && new URLSearchParams(location.search).get('add')) {
|
if (!addOpened && new URLSearchParams(location.search).get('add')) {
|
||||||
addOpened = true;
|
addOpened = true;
|
||||||
setTimeout(() => page.openCreate(), 100);
|
setTimeout(() => this.openCreate(), 100);
|
||||||
}
|
}
|
||||||
return Promise.resolve(wrap);
|
return Promise.resolve(wrap);
|
||||||
}
|
}
|
||||||
@@ -602,49 +609,60 @@ export class PeoplePage {
|
|||||||
const used = p.quota_used || p.month[0] + p.month[1];
|
const used = p.quota_used || p.month[0] + p.month[1];
|
||||||
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
||||||
const today = p.devices.reduce((a, d) => a + (d.spark[d.spark.length - 1] ?? [0, 0]).reduce((x, y) => x + y), 0);
|
const today = p.devices.reduce((a, d) => a + (d.spark[d.spark.length - 1] ?? [0, 0]).reduce((x, y) => x + y), 0);
|
||||||
const r = p.rate?.[p.rate.length - 1];
|
const r = p.online ? this.speedOf(p) : null;
|
||||||
const live = p.online && r && this.st.now - r[0] < 180;
|
const live = !!r;
|
||||||
|
|
||||||
const bar = E('div', { class: `dl-usebar${pct >= 100 ? ' bad' : pct >= 90 ? ' warn' : ''}` });
|
// The pace lately: their devices' days added up (each device's last 7, today last).
|
||||||
|
const week = Array.from({ length: 7 }, (_x, k) => p.devices.reduce((a, d) => a + (d.spark[k]?.[0] ?? 0) + (d.spark[k]?.[1] ?? 0), 0));
|
||||||
|
const pace = paceOf(week);
|
||||||
|
const paceText = paceWords(used, p.quota_limit, pace, p.quota_period === 'month', this.today);
|
||||||
|
let bar: HTMLElement;
|
||||||
if (p.quota_limit) {
|
if (p.quota_limit) {
|
||||||
const fill = E('i', { class: 'fill' });
|
bar = limitMeter(pct, weekAhead(p.quota_used, p.quota_limit, pace));
|
||||||
fill.style.width = `${pct}%`;
|
// Above where the fill ends: the value's own place.
|
||||||
bar.appendChild(fill);
|
pointTip(
|
||||||
attachTip(bar, () => [
|
bar,
|
||||||
E('div', { class: 'dl-tip-title' }, fmt(_('%s%% used'), num(pct, 1))),
|
() => [
|
||||||
|
E('div', { class: 'dl-glide-head' }, [
|
||||||
|
E('b', {}, fmt(_('%s%% used'), num(pct, 1))),
|
||||||
E(
|
E(
|
||||||
'div',
|
'span',
|
||||||
{ class: 'dl-muted' },
|
|
||||||
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
|
||||||
),
|
|
||||||
E(
|
|
||||||
'div',
|
|
||||||
{ class: 'dl-faint' },
|
{ class: 'dl-faint' },
|
||||||
p.quota_period === 'total'
|
p.quota_period === 'total'
|
||||||
? _('In total')
|
? _('In total')
|
||||||
: [_('This month'), p.bonus_gb ? fmt(_('includes +%s GB extra'), num(p.bonus_gb)) : ''].filter(Boolean).join(' · '),
|
: [_('This month'), p.bonus_gb ? fmt(_('includes +%s GB extra'), num(p.bonus_gb)) : ''].filter(Boolean).join(' · '),
|
||||||
),
|
),
|
||||||
]);
|
]),
|
||||||
|
E(
|
||||||
|
'div',
|
||||||
|
{ class: 'dl-muted' },
|
||||||
|
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
||||||
|
),
|
||||||
|
pct < 100 && paceText ? E('div', { class: 'dl-glide-note' }, paceText) : '',
|
||||||
|
],
|
||||||
|
() => {
|
||||||
|
const r = bar.getBoundingClientRect();
|
||||||
|
return [r.left + (r.width * pct) / 100, r.top];
|
||||||
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
const devs = p.devices
|
const devs = p.devices
|
||||||
.map((d) => ({ d, v: d.month[0] + d.month[1] }))
|
.map((d) => ({ d, v: d.month[0] + d.month[1] }))
|
||||||
.filter((x) => x.v > 0)
|
.filter((x) => x.v > 0)
|
||||||
.sort((a, b) => b.v - a.v);
|
.sort((a, b) => b.v - a.v);
|
||||||
devs.forEach((x, i) => {
|
bar = splitMeter(devs.map((x) => x.v));
|
||||||
const seg = E('i', { class: `c${Math.min(i, 4)}` });
|
|
||||||
seg.style.flexGrow = String(x.v);
|
|
||||||
bar.appendChild(seg);
|
|
||||||
});
|
|
||||||
if (devs.length)
|
if (devs.length)
|
||||||
attachTip(bar, () => [
|
pointTip(bar, () => [
|
||||||
E('div', { class: 'dl-tip-title' }, _('This month by device')),
|
E('div', { class: 'dl-glide-head' }, [E('b', {}, _('This month by device')), E('span', { class: 'dl-faint' }, bytes(used))]),
|
||||||
...devs.map((x, i) =>
|
...devs.map((x, i) =>
|
||||||
E('div', { class: 'dl-tip-row' }, [
|
E('div', { class: 'dl-tip-row' }, [
|
||||||
E('span', { class: `dl-swatch c${Math.min(i, 4)}` }),
|
E('span', { class: `dl-swatch c${Math.min(i, 4)}` }),
|
||||||
E('span', {}, x.d.name),
|
E('span', {}, x.d.name),
|
||||||
|
E('span', { class: 'dl-faint' }, `${num(Math.round((x.v / Math.max(1, used)) * 100))}%`),
|
||||||
E('b', {}, bytes(x.v)),
|
E('b', {}, bytes(x.v)),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
paceText ? E('div', { class: 'dl-glide-note' }, paceText) : '',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,15 +687,42 @@ export class PeoplePage {
|
|||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
bar,
|
bar,
|
||||||
live
|
r
|
||||||
? E('div', { class: 'dl-use-live', title: _('Right now') }, [
|
? this.speedRow(p, r)
|
||||||
`↓ ${bits(r![2])}`,
|
|
||||||
E('span', { class: 'dl-faint' }, `↑ ${bits(r![1])}`),
|
|
||||||
])
|
|
||||||
: E('div', { class: 'dl-faint dl-pside-foot' }, today ? `${fmt(_('today %s'), bytes(today))} · ${limitText}` : limitText),
|
: E('div', { class: 'dl-faint dl-pside-foot' }, today ? `${fmt(_('today %s'), bytes(today))} · ${limitText}` : limitText),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Their speed now ([ts, rx, tx]): the live meter's while it has points, else their newest minute while it is recent. */
|
||||||
|
private speedOf(p: Person): Rate | null {
|
||||||
|
const s = this.meter?.speed(
|
||||||
|
p.server,
|
||||||
|
Date.now(),
|
||||||
|
p.devices.map((d) => d.id),
|
||||||
|
);
|
||||||
|
if (s?.pts.length) return [0, s.rx, s.tx];
|
||||||
|
const r = p.rate?.[p.rate.length - 1];
|
||||||
|
return r && this.st.now - r[0] < 180 ? r : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private speedRow(p: Person, r: Rate): HTMLElement {
|
||||||
|
const down = E('span', {}, `↓ ${bits(r[2])}`);
|
||||||
|
const up = E('span', { class: 'dl-faint' }, `↑ ${bits(r[1])}`);
|
||||||
|
this.speedEls.set(p.id, { p, down, up });
|
||||||
|
return E('div', { class: 'dl-use-live', title: _('Right now') }, [down, up]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Each second's meter answer: the speeds in the cards on screen (whether someone is online waits for the status). */
|
||||||
|
paintSpeed() {
|
||||||
|
for (const { p, down, up } of this.speedEls.values()) {
|
||||||
|
if (!down.isConnected) continue;
|
||||||
|
const r = this.speedOf(p);
|
||||||
|
if (!r) continue;
|
||||||
|
down.textContent = `↓ ${bits(r[2])}`;
|
||||||
|
up.textContent = `↑ ${bits(r[1])}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async togglePause(p: Person) {
|
async togglePause(p: Person) {
|
||||||
if (await attempt(() => api.personPause(p.id, !p.paused), fmt(p.paused ? _('%s resumed') : _('%s paused'), p.name)))
|
if (await attempt(() => api.personPause(p.id, !p.paused), fmt(p.paused ? _('%s resumed') : _('%s paused'), p.name)))
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
@@ -848,7 +893,7 @@ export class PeoplePage {
|
|||||||
' ',
|
' ',
|
||||||
E(
|
E(
|
||||||
'a',
|
'a',
|
||||||
{ class: 'cbi-button cbi-button-neutral', href: `${L.url('admin/network/dawnline/settings')}?section=portal` },
|
{ class: 'cbi-button cbi-button-neutral', href: `${L.url('admin/services/dawnline/settings')}?section=portal` },
|
||||||
_('Open Settings'),
|
_('Open Settings'),
|
||||||
),
|
),
|
||||||
' ',
|
' ',
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function mapCard(page: PersonPage): HTMLElement {
|
|||||||
E(
|
E(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'dl-map-off' },
|
{ class: 'dl-map-off' },
|
||||||
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/network/dawnline/settings') }, _('Turn them on in Settings'))),
|
fill(_('Locations are off. %s.'), E('a', { href: L.url('admin/services/dawnline/settings') }, _('Turn them on in Settings'))),
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
const map = new ConnectionMap(
|
const map = new ConnectionMap(
|
||||||
@@ -64,7 +64,7 @@ export function placesPart(page: PersonPage): HTMLElement | null {
|
|||||||
E('span', { class: 'dl-sub' }, _('City-level, from the client IP')),
|
E('span', { class: 'dl-sub' }, _('City-level, from the client IP')),
|
||||||
]),
|
]),
|
||||||
E('span', { class: 'dl-spacer' }),
|
E('span', { class: 'dl-spacer' }),
|
||||||
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/network/dawnline/settings') }, _('Turn on')),
|
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/services/dawnline/settings') }, _('Turn on')),
|
||||||
]);
|
]);
|
||||||
if (page.mapOpen) return page.map && page.parts.places.contains(page.map.el) ? null : mapCard(page);
|
if (page.mapOpen) return page.map && page.parts.places.contains(page.map.el) ? null : mapCard(page);
|
||||||
const since = st.now - 30 * 86400;
|
const since = st.now - 30 * 86400;
|
||||||
@@ -108,10 +108,10 @@ export function activityPart(page: PersonPage): HTMLElement {
|
|||||||
const e = latest[i];
|
const e = latest[i];
|
||||||
let n = 1;
|
let n = 1;
|
||||||
while (e.type === 'roam' && latest[i + n]?.type === 'roam' && latest[i + n].device === e.device) n++;
|
while (e.type === 'roam' && latest[i + n]?.type === 'roam' && latest[i + n].device === e.device) n++;
|
||||||
const row = eventRow(st, e, { server: false });
|
const row = eventRow(st, e, { server: false, person: p.id });
|
||||||
if (n > 1) {
|
if (n > 1) {
|
||||||
const main = row.querySelector('.dl-row-main') as HTMLElement;
|
const main = row.querySelector('.dl-row-main') as HTMLElement;
|
||||||
dom.content(main, [...eventText(st, e).slice(0, 3), E('span', { class: 'dl-muted' }, plural(n, '%s time', '%s times'))]);
|
dom.content(main, [...eventText(st, e, p.id).slice(0, 3), E('span', { class: 'dl-muted' }, plural(n, '%s time', '%s times'))]);
|
||||||
main.title = latest
|
main.title = latest
|
||||||
.slice(i, i + n)
|
.slice(i, i + n)
|
||||||
.map((x) => x.detail ?? '')
|
.map((x) => x.detail ?? '')
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import type { PersonPage } from './index';
|
|||||||
async function showDeviceQr(page: PersonPage, d: Device) {
|
async function showDeviceQr(page: PersonPage, d: Device) {
|
||||||
const cfg = await attempt(() => api.deviceConfig(d.id, true));
|
const cfg = await attempt(() => api.deviceConfig(d.id, true));
|
||||||
if (!cfg) return;
|
if (!cfg) return;
|
||||||
modal(fmt(_('Set up %s'), d.name), [await page.core.connectBlock(cfg, 'qr')], [cancelButton(_('Close'))]);
|
modal(fmt(_('Set up %s'), d.name), [await page.core.connectBlock(cfg, d.kind, 'qr')], [cancelButton(_('Close'))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadConfig(page: PersonPage, d: Device) {
|
async function downloadConfig(page: PersonPage, d: Device) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { icon } from '../../../shared/icons';
|
|||||||
import { ago, bytes, date, initials, isoDay } from '../../../shared/format';
|
import { ago, bytes, date, initials, isoDay } from '../../../shared/format';
|
||||||
import { fmt } from '../../../shared/i18n';
|
import { fmt } from '../../../shared/i18n';
|
||||||
import { copyPersonLink } from '../../invite';
|
import { copyPersonLink } from '../../invite';
|
||||||
import { daysTile, speedTile } from '../../widgets/tiles';
|
import { daysTile } from '../../widgets/tiles';
|
||||||
import { editNote, invite, moveToServer, newLink, remove, rename } from './dialogs';
|
import { editNote, invite, moveToServer, newLink, remove, rename } from './dialogs';
|
||||||
import type { PersonPage } from './index';
|
import type { PersonPage } from './index';
|
||||||
|
|
||||||
@@ -66,13 +66,12 @@ export function headPart(page: PersonPage): HTMLElement {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Speed now and the last 30 days, the same tiles as the server Overview; speed only while a device is online. */
|
/** Speed now (live) and the last 30 days, the same tiles as the server Overview; speed only while a device is online. */
|
||||||
export function trafficPart(page: PersonPage): HTMLElement {
|
export function trafficPart(page: PersonPage): HTMLElement {
|
||||||
const p = page.p;
|
const p = page.p;
|
||||||
// Today on the router: the last day of the series.
|
if (p.online) page.paintSpeed();
|
||||||
const todayUse = page.series[page.series.length - 1];
|
|
||||||
return E('div', { class: `dl-person-live${p.online ? '' : ' solo'}` }, [
|
return E('div', { class: `dl-person-live${p.online ? '' : ' solo'}` }, [
|
||||||
p.online ? speedTile(p.rate ?? [], page.st.now, todayUse ? [todayUse.rx, todayUse.tx] : [0, 0]) : '',
|
p.online ? page.speed.el : '',
|
||||||
daysTile(page.series, fmt(_('%s this month'), bytes(p.month[0] + p.month[1]))),
|
daysTile(page.series, fmt(_('%s this month'), bytes(p.month[0] + p.month[1]))),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Person page (admin/network/dawnline/person?id=…): devices as cards,
|
// Person page (admin/services/dawnline/person?id=…): devices as cards,
|
||||||
// locations, activity, and access & limits that apply immediately.
|
// locations, activity, and access & limits that apply immediately.
|
||||||
// The parts live in ./header, ./devices, ./limits, ./pickers, ./activity and
|
// The parts live in ./header, ./devices, ./limits, ./pickers, ./activity and
|
||||||
// ./dialogs; this class holds the state, the poller and the edits.
|
// ./dialogs; this class holds the state, the poller and the edits.
|
||||||
@@ -13,6 +13,9 @@ import { peopleUrl } from '../../urls';
|
|||||||
import { addDevice, openDevice, type DeviceOpts } from '../../device';
|
import { addDevice, openDevice, type DeviceOpts } from '../../device';
|
||||||
import { coreFor, type Core } from '../../cores';
|
import { coreFor, type Core } from '../../cores';
|
||||||
import { createPoller, repaint, type Poller } from '../../state/poller';
|
import { createPoller, repaint, type Poller } from '../../state/poller';
|
||||||
|
import { LiveMeter, type MeterAnswer } from '../../state/meter';
|
||||||
|
import { pollMeter } from '../../state/meterpoll';
|
||||||
|
import { LiveSpeedTile } from '../../widgets/tiles';
|
||||||
import { headPart, trafficPart } from './header';
|
import { headPart, trafficPart } from './header';
|
||||||
import { devicesPart } from './devices';
|
import { devicesPart } from './devices';
|
||||||
import { limitsPart } from './limits';
|
import { limitsPart } from './limits';
|
||||||
@@ -40,6 +43,10 @@ export class PersonPage {
|
|||||||
/** The same per device. */
|
/** The same per device. */
|
||||||
devSeries: Record<string, DayUsage[]> = {};
|
devSeries: Record<string, DayUsage[]> = {};
|
||||||
poller?: Poller<Loaded>;
|
poller?: Poller<Loaded>;
|
||||||
|
/** Speed now, live (the meter's last 2 minutes of their devices): one tile for the page's life, and its poller. */
|
||||||
|
meter = new LiveMeter();
|
||||||
|
speed = new LiveSpeedTile();
|
||||||
|
meterPoller?: Poller<MeterAnswer>;
|
||||||
/** Status every 15 s; the log and the traffic history every fourth time (and after a change). */
|
/** Status every 15 s; the log and the traffic history every fourth time (and after a change). */
|
||||||
private ticks = 0;
|
private ticks = 0;
|
||||||
private fullNext = false;
|
private fullNext = false;
|
||||||
@@ -66,7 +73,7 @@ export class PersonPage {
|
|||||||
return E('div', { class: 'dl-empty' }, [
|
return E('div', { class: 'dl-empty' }, [
|
||||||
E('h3', {}, _('Person not found')),
|
E('h3', {}, _('Person not found')),
|
||||||
E('p', {}, _('They may have been removed.')),
|
E('p', {}, _('They may have been removed.')),
|
||||||
E('a', { class: 'cbi-button', href: L.url('admin/network/dawnline/server') }, _('Back to Servers')),
|
E('a', { class: 'cbi-button', href: L.url('admin/services/dawnline/server') }, _('Back to Servers')),
|
||||||
]);
|
]);
|
||||||
this.p = p;
|
this.p = p;
|
||||||
for (const k of ['crumbs', 'head', 'devices', 'traffic', 'places', 'activity', 'limits'] as Part[]) this.parts[k] = E('div', {});
|
for (const k of ['crumbs', 'head', 'devices', 'traffic', 'places', 'activity', 'limits'] as Part[]) this.parts[k] = E('div', {});
|
||||||
@@ -96,9 +103,30 @@ export class PersonPage {
|
|||||||
active: () => root.isConnected,
|
active: () => root.isConnected,
|
||||||
apply: (data, quiet) => this.apply(data, quiet),
|
apply: (data, quiet) => this.apply(data, quiet),
|
||||||
});
|
});
|
||||||
|
// One meter call a second while a device of theirs is online on a running server.
|
||||||
|
this.meterPoller?.stop();
|
||||||
|
this.meterPoller = pollMeter(
|
||||||
|
this.meter,
|
||||||
|
() => root.isConnected && this.p.online > 0 && !!this.st.servers.find((x) => x.id === this.p.server)?.enabled,
|
||||||
|
() => this.paintSpeed(),
|
||||||
|
);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The speed tile from the meter as it stands, with today's traffic. */
|
||||||
|
paintSpeed() {
|
||||||
|
const day = this.series[this.series.length - 1];
|
||||||
|
this.speed.update(
|
||||||
|
this.meter.speed(
|
||||||
|
this.p.server,
|
||||||
|
Date.now(),
|
||||||
|
this.p.devices.map((d) => d.id),
|
||||||
|
),
|
||||||
|
day ? [day.rx, day.tx] : [0, 0],
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private take(d: Loaded) {
|
private take(d: Loaded) {
|
||||||
this.st = d.st;
|
this.st = d.st;
|
||||||
if (d.ev) this.events = d.ev;
|
if (d.ev) this.events = d.ev;
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import { button } from '../../ui/button';
|
|||||||
import { cancelButton, closeModal, modal } from '../../ui/modal';
|
import { cancelButton, closeModal, modal } from '../../ui/modal';
|
||||||
import { liveField } from '../../ui/layout';
|
import { liveField } from '../../ui/layout';
|
||||||
import { quotaHelp } from '../../netcheck';
|
import { quotaHelp } from '../../netcheck';
|
||||||
import { attachTip } from '../../ui/tooltip';
|
import { pointTip } from '../../ui/glide';
|
||||||
|
import { limitMeter } from '../../widgets/meter';
|
||||||
|
import { paceOf, paceWords, weekAhead } from '../../../shared/pace';
|
||||||
import { icon } from '../../../shared/icons';
|
import { icon } from '../../../shared/icons';
|
||||||
import { accessLabel, bytes, date, daysLeft, endsSoon, shiftDay } from '../../../shared/format';
|
import { accessLabel, bytes, date, daysLeft, endsSoon, shiftDay } from '../../../shared/format';
|
||||||
import { fmt, num, plural } from '../../../shared/i18n';
|
import { fmt, num, plural } from '../../../shared/i18n';
|
||||||
@@ -128,21 +130,31 @@ function dataTile(page: PersonPage): HTMLElement {
|
|||||||
const p = page.p;
|
const p = page.p;
|
||||||
const used = p.quota_used || p.month[0] + p.month[1];
|
const used = p.quota_used || p.month[0] + p.month[1];
|
||||||
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0;
|
||||||
const bar = E('div', { class: `dl-meter${pct >= 100 ? ' bad' : pct >= 90 ? ' warn' : ''}` }, [
|
// The pace lately (the person's days) and where a week at it takes them, dashed past the fill.
|
||||||
E('i'),
|
const pace = paceOf(page.series.map((d) => d.rx + d.tx));
|
||||||
p.quota_limit ? E('span', { class: 'mark', title: _('Alert at 90%') }) : '',
|
const bar = limitMeter(pct, p.quota_limit ? weekAhead(p.quota_used, p.quota_limit, pace) : 0, p.quota_limit ? 0.9 : undefined);
|
||||||
]);
|
if (p.quota_limit) {
|
||||||
(bar.firstChild as HTMLElement).style.width = `${pct}%`;
|
const paceText = paceWords(p.quota_used, p.quota_limit, pace, p.quota_period === 'month', page.today);
|
||||||
if (p.quota_limit)
|
pointTip(
|
||||||
attachTip(bar, () => [
|
bar,
|
||||||
E('div', { class: 'dl-tip-title' }, fmt(_('%s%% used'), num(pct, 1))),
|
() => [
|
||||||
|
E('div', { class: 'dl-glide-head' }, [
|
||||||
|
E('b', {}, fmt(_('%s%% used'), num(pct, 1))),
|
||||||
|
E('span', { class: 'dl-faint' }, _('Alert at 90%')),
|
||||||
|
]),
|
||||||
E(
|
E(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'dl-muted' },
|
{ class: 'dl-muted' },
|
||||||
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
`${fmt(_('%s of %s'), bytes(p.quota_used), bytes(p.quota_limit))} · ${fmt(_('%s left'), bytes(Math.max(0, p.quota_limit - p.quota_used)))}`,
|
||||||
),
|
),
|
||||||
E('div', { class: 'dl-faint' }, _('Alert at 90%')),
|
pct < 100 && paceText ? E('div', { class: 'dl-glide-note' }, paceText) : '',
|
||||||
]);
|
],
|
||||||
|
() => {
|
||||||
|
const r = bar.getBoundingClientRect();
|
||||||
|
return [r.left + (r.width * pct) / 100, r.top];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
const period = seg(
|
const period = seg(
|
||||||
[
|
[
|
||||||
['month', _('Monthly')],
|
['month', _('Monthly')],
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { coreOf } from '../cores';
|
|||||||
import { installAwg } from '../pkgs';
|
import { installAwg } from '../pkgs';
|
||||||
import { createPoller, focusInside, repaint, type Poller } from '../state/poller';
|
import { createPoller, focusInside, repaint, type Poller } from '../state/poller';
|
||||||
import { LiveMeter, type MeterAnswer } from '../state/meter';
|
import { LiveMeter, type MeterAnswer } from '../state/meter';
|
||||||
|
import { pollMeter } from '../state/meterpoll';
|
||||||
import { ServerOverview } from './overview';
|
import { ServerOverview } from './overview';
|
||||||
import { PeoplePage } from './people';
|
import { PeoplePage } from './people';
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ const url = (server?: string, section?: string) => {
|
|||||||
if (server) q.set('server', server);
|
if (server) q.set('server', server);
|
||||||
if (section && section !== 'overview') q.set('section', section);
|
if (section && section !== 'overview') q.set('section', section);
|
||||||
const s = q.toString();
|
const s = q.toString();
|
||||||
return `${L.url('admin/network/dawnline/server')}${s ? `?${s}` : ''}`;
|
return `${L.url('admin/services/dawnline/server')}${s ? `?${s}` : ''}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ServerPage {
|
export class ServerPage {
|
||||||
@@ -65,7 +66,7 @@ export class ServerPage {
|
|||||||
secEl = E('div', {});
|
secEl = E('div', {});
|
||||||
bodyEl = E('div', { class: 'dl-srvbody' });
|
bodyEl = E('div', { class: 'dl-srvbody' });
|
||||||
poller?: Poller<Status>;
|
poller?: Poller<Status>;
|
||||||
/** The live meter's last 2 minutes, every server's (the Overviews' Speed now), and its poller. */
|
/** The live meter's last 2 minutes, every server's (Speed now on the Overviews and People lists), and its poller. */
|
||||||
meter = new LiveMeter();
|
meter = new LiveMeter();
|
||||||
meterPoller?: Poller<MeterAnswer>;
|
meterPoller?: Poller<MeterAnswer>;
|
||||||
|
|
||||||
@@ -104,23 +105,16 @@ export class ServerPage {
|
|||||||
this.ov[this.current().id]?.update(n, quiet);
|
this.ov[this.current().id]?.update(n, quiet);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// Speed now, live: one meter call a second while the Overview of a running server is on screen
|
// Speed now, live, while the Overview of a running server or its People list is on screen.
|
||||||
// (the router keeps the last two minutes and writes them out while someone asks). A failed call is said in the tile, not in a
|
|
||||||
// second "not answering" toast beside the status poller's.
|
|
||||||
this.meterPoller?.stop();
|
this.meterPoller?.stop();
|
||||||
this.meterPoller = createPoller<MeterAnswer>({
|
this.meterPoller = pollMeter(
|
||||||
fetch: () =>
|
this.meter,
|
||||||
api.meter(this.meter.since(Date.now())).then(
|
() => (this.section === 'overview' || this.section === 'people') && this.root.isConnected && this.current().enabled,
|
||||||
(meter) => ({ meter }),
|
() => {
|
||||||
(e) => ({ error: errorText(e) }),
|
|
||||||
),
|
|
||||||
every: 1,
|
|
||||||
active: () => this.section === 'overview' && this.root.isConnected && this.current().enabled,
|
|
||||||
apply: (r) => {
|
|
||||||
this.meter.take(r, Date.now());
|
|
||||||
this.ov[this.current().id]?.paintSpeed();
|
this.ov[this.current().id]?.paintSpeed();
|
||||||
|
this.pp[this.current().id]?.paintSpeed();
|
||||||
},
|
},
|
||||||
});
|
);
|
||||||
return this.root;
|
return this.root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +214,7 @@ export class ServerPage {
|
|||||||
pp.filter = filter as PeoplePage['filter'];
|
pp.filter = filter as PeoplePage['filter'];
|
||||||
if (pp.el) pp.decorate();
|
if (pp.el) pp.decorate();
|
||||||
} else if (filter) {
|
} else if (filter) {
|
||||||
const page = (this.pp[this.current().id] = new PeoplePage());
|
const page = (this.pp[this.current().id] = new PeoplePage(this.meter));
|
||||||
page.filter = filter as PeoplePage['filter'];
|
page.filter = filter as PeoplePage['filter'];
|
||||||
}
|
}
|
||||||
this.showSection(k);
|
this.showSection(k);
|
||||||
@@ -261,7 +255,7 @@ export class ServerPage {
|
|||||||
return pp.el;
|
return pp.el;
|
||||||
}
|
}
|
||||||
const holder = E('div', {}, E('p', { class: 'dl-muted' }, _('Loading people…')));
|
const holder = E('div', {}, E('p', { class: 'dl-muted' }, _('Loading people…')));
|
||||||
const page = (this.pp[srv.id] ??= new PeoplePage());
|
const page = (this.pp[srv.id] ??= new PeoplePage(this.meter));
|
||||||
page
|
page
|
||||||
.embed(st, srv.id)
|
.embed(st, srv.id)
|
||||||
.then((node) => {
|
.then((node) => {
|
||||||
@@ -846,7 +840,7 @@ export class ServerPage {
|
|||||||
'warn',
|
'warn',
|
||||||
_('AmneziaWG’s kernel module doesn’t load on this firmware'),
|
_('AmneziaWG’s kernel module doesn’t load on this firmware'),
|
||||||
_('Try another build in Components, or update OpenWrt. The server can’t start until it loads.'),
|
_('Try another build in Components, or update OpenWrt. The server can’t start until it loads.'),
|
||||||
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/network/dawnline/updates') }, _('Open Components')),
|
E('a', { class: 'cbi-button cbi-button-neutral', href: L.url('admin/services/dawnline/updates') }, _('Open Components')),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
: '';
|
: '';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Settings → Logs & history: retention, what is recorded, and the stored data.
|
// Settings → Logs & history: retention, what is recorded, what goes to the
|
||||||
|
// router's system log, and the stored data.
|
||||||
|
|
||||||
import { E } from '../../e';
|
import { E } from '../../e';
|
||||||
import { api } from '../../api';
|
import { api } from '../../api';
|
||||||
@@ -67,6 +68,17 @@ export function logsCard(host: SettingsHost): HTMLElement {
|
|||||||
String(p.usage_months),
|
String(p.usage_months),
|
||||||
_('Monthly traffic'),
|
_('Monthly traffic'),
|
||||||
);
|
);
|
||||||
|
// The router's system log (logread): dawnline.util syslog() writes at these levels.
|
||||||
|
const level = select(
|
||||||
|
[
|
||||||
|
['error', _('Errors only')],
|
||||||
|
['warn', _('Warnings and errors')],
|
||||||
|
['info', _('Normal')],
|
||||||
|
['debug', _('Verbose (debug)')],
|
||||||
|
],
|
||||||
|
String(host.d.effective.log_level ?? 'info'),
|
||||||
|
_('System log'),
|
||||||
|
);
|
||||||
const cats = multiSelect(
|
const cats = multiSelect(
|
||||||
CATEGORIES.map((c): [string, Node] => [
|
CATEGORIES.map((c): [string, Node] => [
|
||||||
c,
|
c,
|
||||||
@@ -111,6 +123,13 @@ export function logsCard(host: SettingsHost): HTMLElement {
|
|||||||
persist,
|
persist,
|
||||||
_('The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot.'),
|
_('The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot.'),
|
||||||
),
|
),
|
||||||
|
row(
|
||||||
|
_('System log'),
|
||||||
|
level,
|
||||||
|
_(
|
||||||
|
'What Dawnline writes to the router’s system log (logread -e dawnline). Verbose adds each step of a start and of applying settings.',
|
||||||
|
),
|
||||||
|
),
|
||||||
row(_('Daily traffic'), days, _('Per-day history behind the charts.')),
|
row(_('Daily traffic'), days, _('Per-day history behind the charts.')),
|
||||||
row(_('Monthly traffic'), months, _('Per-month totals; data limits use the current month.')),
|
row(_('Monthly traffic'), months, _('Per-month totals; data limits use the current month.')),
|
||||||
E('h4', { class: 'dl-setsub' }, _('Stored data')),
|
E('h4', { class: 'dl-setsub' }, _('Stored data')),
|
||||||
@@ -173,6 +192,7 @@ export function logsCard(host: SettingsHost): HTMLElement {
|
|||||||
usage_keep_days: days.value,
|
usage_keep_days: days.value,
|
||||||
usage_keep_months: months.value,
|
usage_keep_months: months.value,
|
||||||
log_category: cats.value(),
|
log_category: cats.value(),
|
||||||
|
log_level: level.value,
|
||||||
},
|
},
|
||||||
_('Saved'),
|
_('Saved'),
|
||||||
'logs',
|
'logs',
|
||||||
|
|||||||
@@ -134,9 +134,9 @@ export const MOVE_MS = 1600;
|
|||||||
/** The shimmer sets off once the place it leaves has started to go gray (a share of the move). */
|
/** The shimmer sets off once the place it leaves has started to go gray (a share of the move). */
|
||||||
const LEAVE = 0.12;
|
const LEAVE = 0.12;
|
||||||
/** The shimmer's length, a share of the arc: longer than the arc, so most of it is lit mid-move. */
|
/** The shimmer's length, a share of the arc: longer than the arc, so most of it is lit mid-move. */
|
||||||
export const BAND = 1.3;
|
const BAND = 1.3;
|
||||||
/** ± this around the shimmer's middle is fully lit; it fades out to ±BAND/2. */
|
/** ± this around the shimmer's middle is fully lit; it fades out to ±BAND/2. */
|
||||||
export const FLAT = 0.32;
|
const FLAT = 0.32;
|
||||||
|
|
||||||
/** A move into stay `k` (from stay k − 1), or stay `k` itself, `ms` long from `start`. */
|
/** A move into stay `k` (from stay k − 1), or stay `k` itself, `ms` long from `start`. */
|
||||||
export interface Step {
|
export interface Step {
|
||||||
@@ -181,7 +181,7 @@ export function msAt(st: Stay[], steps: Step[], t: number): number {
|
|||||||
return step.start + step.ms * Math.min(0.999, Math.max(0, (t - s.from) / Math.max(1, s.to - s.from)));
|
return step.start + step.ms * Math.min(0.999, Math.max(0, (t - s.from) / Math.max(1, s.to - s.from)));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ease = (x: number) => (x <= 0 ? 0 : x >= 1 ? 1 : x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2);
|
const ease = (x: number) => (x <= 0 ? 0 : x >= 1 ? 1 : x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2);
|
||||||
|
|
||||||
/** The shimmer's middle (a share of the arc) `q` into a move: it enters before the place it leaves and runs out past the next. */
|
/** The shimmer's middle (a share of the arc) `q` into a move: it enters before the place it leaves and runs out past the next. */
|
||||||
export function bandMiddle(q: number): number {
|
export function bandMiddle(q: number): number {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// The live meter as the Servers page keeps it (rpc meter, polled once a
|
// The live meter as a page keeps it (rpc meter, polled once a second while a
|
||||||
// second while an Overview is on screen): the answers merged into the last two
|
// speed is on screen): the answers merged into the last two minutes, and one
|
||||||
// minutes, and one server's part of them for its Speed now tile. No DOM and no
|
// server's part of them, or one person's devices on it, for Speed now. No DOM
|
||||||
// RPC here: the poller is the page's (pages/server.ts), the tile widgets/tiles.
|
// and no RPC here: the poller is the page's (pages/server.ts, pages/person),
|
||||||
|
// the tile widgets/tiles.
|
||||||
|
|
||||||
import type { Meter, MeterPoint } from '../api';
|
import type { Meter, MeterPoint } from '../api';
|
||||||
|
|
||||||
@@ -84,12 +85,26 @@ export class LiveMeter {
|
|||||||
this.error = '';
|
this.error = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Server `id`'s points at page time `ms` (none once they are not live), placed against the meter's newest point. */
|
/**
|
||||||
speed(id: string, ms: number): LiveSpeed {
|
* Server `id`'s points at page time `ms` (none once they are not live), placed against the meter's newest point;
|
||||||
|
* with `devices`, only theirs added up (a person's speed).
|
||||||
|
*/
|
||||||
|
speed(id: string, ms: number, devices?: string[]): LiveSpeed {
|
||||||
const error = this.failed >= LOST_AFTER ? this.error : null;
|
const error = this.failed >= LOST_AFTER ? this.error : null;
|
||||||
const live = this.live(ms) ? this.points : [];
|
const live = this.live(ms) ? this.points : [];
|
||||||
|
const sum = (p: MeterPoint): Rate => {
|
||||||
|
if (!devices) return [p.ts, p.servers[id][0], p.servers[id][1]];
|
||||||
|
const r: Rate = [p.ts, 0, 0];
|
||||||
|
for (const d of devices) {
|
||||||
|
const v = p.dev?.[d];
|
||||||
|
if (!v) continue;
|
||||||
|
r[1] += v[0];
|
||||||
|
r[2] += v[1];
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
};
|
||||||
// A second its tunnel was not read has no point of its own.
|
// A second its tunnel was not read has no point of its own.
|
||||||
const pts = live.flatMap((p): Rate[] => (p.servers[id] ? [[p.ts, p.servers[id][0], p.servers[id][1]]] : []));
|
const pts = live.flatMap((p): Rate[] => (p.servers[id] ? [sum(p)] : []));
|
||||||
const end = live.length ? live[live.length - 1].ts : 0;
|
const end = live.length ? live[live.length - 1].ts : 0;
|
||||||
const span = this.keep - 1;
|
const span = this.keep - 1;
|
||||||
const last = pts[pts.length - 1];
|
const last = pts[pts.length - 1];
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// The live meter's poller: one meter call a second while a speed is on screen
|
||||||
|
// (the router keeps the last two minutes and writes them out while someone
|
||||||
|
// asks). A failed call is said in the tile, not in a second "not answering"
|
||||||
|
// toast beside the page's status poller.
|
||||||
|
|
||||||
|
import { api } from '../api';
|
||||||
|
import { errorText } from '../ui/toast';
|
||||||
|
import { createPoller, type Poller } from './poller';
|
||||||
|
import type { LiveMeter, MeterAnswer } from './meter';
|
||||||
|
|
||||||
|
export function pollMeter(meter: LiveMeter, active: () => boolean, paint: () => void): Poller<MeterAnswer> {
|
||||||
|
return createPoller<MeterAnswer>({
|
||||||
|
fetch: () =>
|
||||||
|
api.meter(meter.since(Date.now())).then(
|
||||||
|
(m) => ({ meter: m }),
|
||||||
|
(e) => ({ error: errorText(e) }),
|
||||||
|
),
|
||||||
|
every: 1,
|
||||||
|
active,
|
||||||
|
apply: (r) => {
|
||||||
|
meter.take(r, Date.now());
|
||||||
|
paint();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||