Compare commits

..

1 Commits

Author SHA1 Message Date
Maxi Quoß f21161dc7d add debug logging for wake cron #669 2024-07-31 18:16:38 +02:00
178 changed files with 10952 additions and 11249 deletions
-6
View File
@@ -8,9 +8,6 @@ updates:
open-pull-requests-limit: 10
commit-message:
prefix: go-dep
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
- package-ecosystem: npm
directory: "/frontend"
schedule:
@@ -18,9 +15,6 @@ updates:
open-pull-requests-limit: 10
commit-message:
prefix: npm-dep
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
- package-ecosystem: github-actions
directory: "/"
schedule:
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
codeberg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pixta-dev/repository-mirroring-action@v1
+2 -2
View File
@@ -25,9 +25,9 @@ jobs:
needs: check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v6
uses: actions/setup-go@v5
with:
go-version-file: "./backend/go.mod"
cache-dependency-path: "./backend/go.sum"
+33 -98
View File
@@ -15,9 +15,7 @@ jobs:
- name: Set runner
id: set-runner
run: |
runners=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runners")
runners=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners")
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
if [ -n "$available" ]; then
echo "runner-label=self-hosted" >> "$GITHUB_OUTPUT"
@@ -25,153 +23,92 @@ jobs:
echo "runner-label=ubuntu-latest" >> "$GITHUB_OUTPUT"
fi
frontend:
goreleaser:
needs: check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- uses: pnpm/action-setup@v4
with:
version: latest
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: latest
cache: pnpm
cache-dependency-path: frontend/pnpm-lock.yaml
- name: Cache frontend build
uses: actions/cache@v5
with:
path: |
frontend/node_modules
frontend/.svelte-kit
key: ${{ runner.os }}-pnpm-${{ hashFiles('frontend/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Build frontend
run: |
pnpm --prefix=./frontend install --frozen-lockfile --prefer-offline
PUBLIC_VERSION=${GITHUB_REF##*/} pnpm --prefix=./frontend run build
tar -czf frontend-dist.tar.gz -C frontend/build .
- name: Upload frontend artifact
uses: actions/upload-artifact@v6
with:
name: frontend-dist
path: frontend-dist.tar.gz
goreleaser:
needs:
- check-runner
- frontend
runs-on: ${{ needs.check-runner.outputs.runner-label }}
steps:
- uses: actions/checkout@v6
# pull code
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download frontend artifact
uses: actions/download-artifact@v7
# install latest node
- name: Set up Node.js
uses: actions/setup-node@v4
with:
name: frontend-dist
node-version: latest
- name: Extract frontend into backend
# build sveltekit frontend
- name: Build frontend
run: |
mkdir -p backend/pb_public
tar -xzf frontend-dist.tar.gz -C backend/pb_public
git reset --hard
git clean -fd
npm i -g pnpm
pnpm --prefix=./frontend i
PUBLIC_VERSION=${GITHUB_REF##*/} pnpm --prefix=./frontend run build
cp -r ./frontend/build/* ./backend/pb_public/
# setup go
- name: Set up Go
uses: actions/setup-go@v6
uses: actions/setup-go@v5
with:
go-version-file: backend/go.mod
cache-dependency-path: backend/go.sum
- name: Cache Go build
uses: actions/cache@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('backend/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
go-version-file: "./backend/go.mod"
cache-dependency-path: "./backend/go.sum"
# build
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
version: latest
args: release --clean
workdir: backend
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AUR_KEY: ${{ secrets.AUR_KEY }}
- name: Upload backend artifact
uses: actions/upload-artifact@v6
with:
name: backend-dist
path: backend/dist
docker:
needs:
- check-runner
- frontend
- goreleaser
- check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download backend artifact
uses: actions/download-artifact@v7
with:
name: backend-dist
path: backend/dist
# pull code
- name: Check Out Repo
uses: actions/checkout@v4
# image tags
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/seriousm4x/UpSnap
seriousm4x/UpSnap
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
# qemu
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# docker buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
# ghcr.io login
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# build and push
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
@@ -179,7 +116,5 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ github.ref_name }}
VERSION=${{github.ref_name}}
+4 -39
View File
@@ -1,5 +1,5 @@
# Created by https://www.toptal.com/developers/gitignore/api/go,node,svelte,visualstudiocode,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=go,node,svelte,visualstudiocode,macos
# Created by https://www.toptal.com/developers/gitignore/api/go,visualstudiocode,svelte,node
# Edit at https://www.toptal.com/developers/gitignore?templates=go,visualstudiocode,svelte,node
### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
@@ -24,39 +24,6 @@
# Go workspace file
go.work
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### macOS Patch ###
# iCloud generated files
*.icloud
### Node ###
# Logs
logs
@@ -133,7 +100,7 @@ web_modules/
.yarn-integrity
# dotenv environment variable files
.env
#.env
.env.development.local
.env.test.local
.env.production.local
@@ -223,7 +190,7 @@ package
.history
.ionide
# End of https://www.toptal.com/developers/gitignore/api/go,node,svelte,visualstudiocode,macos
# End of https://www.toptal.com/developers/gitignore/api/go,visualstudiocode,svelte,node
build
data
@@ -234,5 +201,3 @@ backend/pb_public/*
dist/
vite.config.js.timestamp*
frontend/src/lib/paraglide
+3 -5
View File
@@ -1,4 +1,4 @@
FROM alpine:3 AS downloader
FROM alpine:3 as downloader
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
@@ -14,13 +14,11 @@ RUN wget https://github.com/seriousm4x/UpSnap/releases/download/${VERSION}/UpSna
setcap 'cap_net_raw=+ep' ./upsnap
FROM alpine:3
ARG UPSNAP_HTTP_LISTEN=0.0.0.0:8090
ENV UPSNAP_HTTP_LISTEN=${UPSNAP_HTTP_LISTEN}
RUN apk update &&\
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
rm -rf /var/cache/apk/*
WORKDIR /app
COPY --from=downloader /app/upsnap upsnap
HEALTHCHECK --interval=10s \
CMD curl -fs "http://${UPSNAP_HTTP_LISTEN}/api/health" || exit 1
ENTRYPOINT ["sh", "-c", "./upsnap serve --http ${UPSNAP_HTTP_LISTEN}"]
CMD curl -fs "http://localhost:8090/api/health" || exit 1
ENTRYPOINT ["./upsnap", "serve", "--http=0.0.0.0:8090"]
+4 -6
View File
@@ -1,11 +1,11 @@
FROM node:alpine AS node
FROM node:alpine as node
WORKDIR /app
COPY frontend/ .
RUN npm i -g pnpm &&\
pnpm i &&\
pnpm run build
FROM golang:alpine AS go
FROM golang:alpine as go
WORKDIR /app
COPY backend/ .
COPY --from=node /app/build ./pb_public
@@ -17,13 +17,11 @@ RUN go build -o upsnap main.go &&\
setcap 'cap_net_raw=+ep' ./upsnap
FROM alpine:3
ARG UPSNAP_HTTP_LISTEN=0.0.0.0:8090
ENV UPSNAP_HTTP_LISTEN=${UPSNAP_HTTP_LISTEN}
RUN apk update &&\
apk add --no-cache tzdata ca-certificates nmap samba samba-common-tools openssh sshpass curl &&\
rm -rf /var/cache/apk/*
WORKDIR /app
COPY --from=go /app/upsnap upsnap
HEALTHCHECK --interval=10s \
CMD curl -fs "http://${UPSNAP_HTTP_LISTEN}/api/health" || exit 1
ENTRYPOINT ["sh", "-c", "./upsnap serve --http ${UPSNAP_HTTP_LISTEN}"]
CMD curl -fs "http://localhost:8090/api/health" || exit 1
ENTRYPOINT ["./upsnap", "serve", "--http=0.0.0.0:8090"]
+33 -94
View File
@@ -5,29 +5,14 @@
<div align="center" width="100%">
<h2>UpSnap</h2>
<p>A simple wake on lan web app written with SvelteKit, Go and PocketBase.</p>
<div>
<a target="_blank" href="https://github.com/seriousm4x/upsnap"><img src="https://img.shields.io/github/stars/seriousm4x/UpSnap?style=flat&label=Stars" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/pkgs/container/upsnap"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fipitio%2Fbackage%2Findex%2Fseriousm4x%2FUpSnap%2Fupsnap.json&query=downloads&label=ghcr.io%20pulls" /></a>
<a target="_blank" href="https://hub.docker.com/r/seriousm4x/upsnap"><img src="https://img.shields.io/docker/pulls/seriousm4x/upsnap?label=docker%20hub%20pulls" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/downloads/seriousm4x/upsnap/total?label=binary%20downloads" /></a>
</div>
<div>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/go-mod/go-version/seriousm4x/UpSnap?filename=backend/go.mod" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/v/release/seriousm4x/upsnap?display_name=tag&label=Latest%20release" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/actions"><img src="https://github.com/seriousm4x/upsnap/actions/workflows/release.yml/badge.svg?event=push" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/commits/master"><img src="https://img.shields.io/github/last-commit/seriousm4x/upsnap" /></a>
</div>
<a target="_blank" href="https://github.com/seriousm4x/upsnap"><img src="https://img.shields.io/github/stars/seriousm4x/upsnap" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/downloads/seriousm4x/upsnap/total" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/go-mod/go-version/seriousm4x/UpSnap?filename=backend/go.mod" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/v/release/seriousm4x/upsnap?display_name=tag" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/actions"><img src="https://github.com/seriousm4x/upsnap/actions/workflows/release.yml/badge.svg?event=push" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/commits/master"><img src="https://img.shields.io/github/last-commit/seriousm4x/upsnap" /></a>
</div>
> [!NOTE]
>
> #### UpSnap is, and always will be, free and open source software.
>
> If someone is asking you to pay money for access to UpSnap binaries, source code, or licenses, you are being scammed.
>
> The official and only trusted source for UpSnap is this repository (and its linked releases).
> Do not pay third parties for something that is provided here for free.
## ✨ Features
- 🚀 One-Click Device Wake-Up Dashboard
@@ -35,21 +20,27 @@
- 🔌 Ping Any Port You Choose
- 🔍 Discover Devices with Network Scanning (nmap required)
- 👤 Secured User Management
- 🌐 i18n support for [these](/frontend/translations) languages
- 🎨 35 Themes
- 🌐 i18n support for [these](https://github.com/seriousm4x/UpSnap/tree/master/frontend/src/lib/i18n) languages
- 🎨 29 Themes
- 🐳 [Docker images](https://github.com/seriousm4x/UpSnap/pkgs/container/upsnap) for amd64, arm64, arm/v7, arm/v6
- 🏠 Self-Hostable
## 📸 Screenshots
| Silk | Dim |
| ---------------------------------- | --------------------------------- |
| ![](/assets/home-light.webp) | ![](/assets/home-dark.webp) |
| ![](/assets/account-light.webp) | ![](/assets/account-dark.webp) |
| ![](/assets/new-manual-light.webp) | ![](/assets/new-manual-dark.webp) |
| ![](/assets/new-scan-light.webp) | ![](/assets/new-scan-dark.webp) |
| ![](/assets/settings-light.webp) | ![](/assets/settings-dark.webp) |
| ![](/assets/users-light.webp) | ![](/assets/users-dark.webp) |
| Dark | Light |
| --------------------------------- | ---------------------------------- |
| ![](/assets/home-dark.webp) | ![](/assets/home-light.webp) |
| ![](/assets/account-dark.webp) | ![](/assets/account-light.webp) |
| ![](/assets/new-manual-dark.webp) | ![](/assets/new-manual-light.webp) |
| ![](/assets/new-scan-dark.webp) | ![](/assets/new-scan-light.webp) |
| ![](/assets/settings-dark.webp) | ![](/assets/settings-light.webp) |
| ![](/assets/users-dark.webp) | ![](/assets/users-light.webp) |
## 🐧 Install from the [AUR](https://aur.archlinux.org/packages/upsnap-bin)
```bash
yay -Sy upsnap-bin
```
## 🚀 Run the binary
@@ -78,8 +69,6 @@ You can use the [docker-compose](docker-compose.yml) example. See the comments i
### Non-root docker user:
You will lose the ability to add network devices via the scan page.
Create the mount point first:
```bash
@@ -93,14 +82,15 @@ Then add `user: 1000:1000` to the docker-compose file (or whatever your $UID:$GI
If you want to change the port from 8090 to something else, change the following (5000 in this case):
```yml
environment:
- UPSNAP_HTTP_LISTEN=0.0.0.0:5000
entrypoint: /bin/sh -c "./upsnap serve --http 0.0.0.0:5000"
healthcheck:
test: curl -fs "http://localhost:5000/api/health" || exit 1
```
### Install additional packages for shutdown cmd
```yml
entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090"
```
You can search for your needed package [here](https://pkgs.alpinelinux.org/packages).
@@ -115,46 +105,6 @@ upsnap.example.com {
}
```
### Run in sub path
You can run UpSnap on a different path than `/`, e.g. `/upsnap-sub-path/`. To do this in caddy, set the following:
```
http://localhost:8091 {
handle /upsnap-sub-path/* {
uri strip_prefix /upsnap-sub-path
reverse_proxy localhost:8090
}
}
```
Or nginx:
```
http {
server {
listen 8091;
server_name localhost;
location /upsnap-sub-path/ {
proxy_pass http://localhost:8090/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
```
Paths must end with a trailing `/`.
## 🐧 Install from the [AUR](https://aur.archlinux.org/packages/upsnap-bin)
```bash
yay -Sy upsnap-bin
```
## 🔒 User permissions
UpSnap offers unique access for each user, per device. While admins have all permissions, they can assign specific rights to users such as displaying/hiding a device, accessing device editing, deleting and powering devices on/off. See the last screenshot in the [📸 Screenshots section](#-screenshots).
@@ -171,25 +121,14 @@ Although UpSnap has user authorisation, it is **not recommended to expose it to
UpSnap is available in the following languages so far:
- 🇧🇬 **Bulgarian (Bulgaria)** (bg-BG)
- 🇨🇿 **Czech (Czech republic)** (cs-CZ)
- 🇩🇪 **German (Germany)** (de-DE)
- 🇺🇸 **English (United States)** (en-US)
- 🇪🇸 **Spanish (Spain)** (es-ES)
- 🇫🇷 **French (France)** (fr-FR)
- 🇮🇳 **Hindi (India)** (hi-IN)
- 🇮🇩 **Bahasa (Indonesia)** (id-ID)
- 🇮🇹 **Italian (Italy)** (it-IT)
- 🇯🇵 **Japanese (Japan)** (ja-JP)
- 🇳🇱 **Dutch (Netherlands)** (nl-NL)
- 🇳🇴 **Norwegian (Norway)** (nb-NO)
- 🇵🇱 **Polish (Poland)** (pl-PL)
- 🇵🇹 **Portuguese (Portugal)** (pt-PT)
- 🇷🇺 **Russian (Russia)** (ru-RU)
- 🇺🇦 **Ukrainian (Ukrain)** (uk-UA)
- 🇻🇳 **Vietnamese (Vietnam)** (vi-VN)
- 🇺🇸 **English** (en-US)
- 🇩🇪 **German** (de-DE)
- 🇮🇹 **Italian** (it-IT)
- 🇪🇸 **Spanish** (es-ES)
- 🇫🇷 **French** (fr-FR)
- 🇵🇹 **Portuguese** (pt-PT)
- 🇨🇳 **Chinese** (zh-CN)
- 🇹🇼 **Chinese (Taiwan)** (zh-TW)
- 🇨🇳 **Chinese (China)** (zh-CN)
**If you want to contribute and help translating, check the wiki: [How to add languages](https://github.com/seriousm4x/UpSnap/wiki/How-to-add-languages)**
Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 32 KiB

+23 -36
View File
@@ -1,16 +1,6 @@
version: 2
release:
draft: false
draft: true
prerelease: auto
header: |
> [!NOTE]
>
> #### UpSnap is, and always will be, free and open source software.
>
> If someone is asking you to pay money for access to UpSnap binaries, source code, or licenses, you are being scammed.
>
> The official and only trusted source for UpSnap is this repository (and its linked releases).
> Do not pay third parties for something that is provided here for free.
before:
hooks:
- go mod tidy
@@ -24,27 +14,24 @@ builds:
- linux
- windows
- darwin
- freebsd
goarch:
- amd64
- arm64
- arm
goarm:
- "6"
- "7"
- 6
- 7
ignore:
- goos: windows
goarch: arm
- goos: darwin
goarch: arm
- goos: freebsd
goarch: arm
archives:
- formats: ["zip"]
- format: zip
checksum:
name_template: "checksums.txt"
snapshot:
version_template: "{{ .Version }}"
name_template: "{{ .Version }}"
changelog:
use: github
sort: asc
@@ -68,21 +55,21 @@ changelog:
order: 2
git:
ignore_tags:
- "{{ if not .Prerelease}}*beta*{{ end }}"
# aurs:
# - name: upsnap-bin
# homepage: https://github.com/seriousm4x/UpSnap
# description: "A simple wake on lan web app written with SvelteKit, Go and PocketBase."
# maintainers:
# - "SeriousM4x <maxi at quoss dot org>"
# license: "MIT"
# private_key: "{{ .Env.AUR_KEY }}"
# git_url: "ssh://aur@aur.archlinux.org/upsnap-bin.git"
# package: |-
# install -Dm755 "./upsnap" "${pkgdir}/usr/bin/upsnap"
# skip_upload: auto
# optdepends:
# - "nmap: to scan for network devices"
# commit_author:
# name: goreleaserbot
# email: bot@goreleaser.com
- "{{ if not .Prerelease}}beta{{ end }}"
aurs:
- name: upsnap-bin
homepage: https://github.com/seriousm4x/UpSnap
description: "A simple wake on lan web app written with SvelteKit, Go and PocketBase."
maintainers:
- "SeriousM4x <maxi at quoss dot org>"
license: "MIT"
private_key: "{{ .Env.AUR_KEY }}"
git_url: "ssh://aur@aur.archlinux.org/upsnap-bin.git"
package: |-
install -Dm755 "./upsnap" "${pkgdir}/usr/bin/upsnap"
skip_upload: auto
optdepends:
- "nmap: to scan for network devices"
commit_author:
name: goreleaserbot
email: bot@goreleaser.com
+50 -68
View File
@@ -2,7 +2,7 @@ package cronjobs
import (
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
"github.com/robfig/cron/v3"
"github.com/seriousm4x/upsnap/logger"
"github.com/seriousm4x/upsnap/networking"
@@ -11,12 +11,8 @@ import (
var (
PingRunning = false
WakeShutdownRunning = false
CronPing = cron.New(cron.WithParser(cron.NewParser(
cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow,
)))
CronWakeShutdown = cron.New(cron.WithParser(cron.NewParser(
cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow,
)))
CronPing = cron.New()
CronWakeShutdown = cron.New()
)
func SetPingJobs(app *pocketbase.PocketBase) {
@@ -25,7 +21,7 @@ func SetPingJobs(app *pocketbase.PocketBase) {
CronPing.Remove(job.ID)
}
settingsPrivateRecords, err := app.FindAllRecords("settings_private")
settingsPrivateRecords, err := app.Dao().FindRecordsByExpr("settings_private")
if err != nil {
logger.Error.Println(err)
}
@@ -37,38 +33,34 @@ func SetPingJobs(app *pocketbase.PocketBase) {
return
}
devices, err := app.FindAllRecords("devices")
devices, err := app.Dao().FindRecordsByExpr("devices")
if err != nil {
logger.Error.Println(err)
return
}
// expand ports field
expandFetchFunc := func(c *core.Collection, ids []string) ([]*core.Record, error) {
return app.FindRecordsByIds(c.Id, ids, nil)
expandFetchFunc := func(c *models.Collection, ids []string) ([]*models.Record, error) {
return app.Dao().FindRecordsByIds(c.Id, ids, nil)
}
merr := app.ExpandRecords(devices, []string{"ports"}, expandFetchFunc)
merr := app.Dao().ExpandRecords(devices, []string{"ports"}, expandFetchFunc)
if len(merr) > 0 {
return
}
for _, device := range devices {
// ping device
go func(d *core.Record) {
go func(d *models.Record) {
status := d.GetString("status")
if status == "pending" {
return
}
isUp, err := networking.PingDevice(d)
if err != nil {
logger.Error.Println(err)
}
if isUp {
if networking.PingDevice(d) {
if status == "online" {
return
}
d.Set("status", "online")
if err := app.Save(d); err != nil {
if err := app.Dao().SaveRecord(d); err != nil {
logger.Error.Println("Failed to save record:", err)
}
} else {
@@ -76,26 +68,23 @@ func SetPingJobs(app *pocketbase.PocketBase) {
return
}
d.Set("status", "offline")
if err := app.Save(d); err != nil {
if err := app.Dao().SaveRecord(d); err != nil {
logger.Error.Println("Failed to save record:", err)
}
}
}(device)
// ping ports
go func(d *core.Record) {
ports, err := app.FindRecordsByIds("ports", d.GetStringSlice("ports"))
go func(d *models.Record) {
ports, err := app.Dao().FindRecordsByIds("ports", d.GetStringSlice("ports"))
if err != nil {
logger.Error.Println(err)
}
for _, port := range ports {
isUp, err := networking.CheckPort(d.GetString("ip"), port.GetString("number"))
if err != nil {
logger.Error.Println("Failed to check port:", err)
}
isUp := networking.CheckPort(d.GetString("ip"), port.GetString("number"))
if isUp != port.GetBool("status") {
port.Set("status", isUp)
if err := app.Save(port); err != nil {
if err := app.Dao().SaveRecord(port); err != nil {
logger.Error.Println("Failed to save record:", err)
}
}
@@ -111,7 +100,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
CronWakeShutdown.Remove(job.ID)
}
devices, err := app.FindAllRecords("devices")
devices, err := app.Dao().FindRecordsByExpr("devices")
if err != nil {
logger.Error.Println(err)
return
@@ -124,80 +113,71 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
if wake_cron_enabled && wake_cron != "" {
_, err := CronWakeShutdown.AddFunc(wake_cron, func() {
d, err := app.FindRecordById("devices", dev.Id)
logger.Debug.Printf("[CRON1 \"%s\"]: cron func started", dev.GetString("name"))
dev, err = app.Dao().FindRecordById("devices", dev.Id)
if err != nil {
logger.Error.Println(err)
return
}
if d.GetString("status") == "pending" {
logger.Debug.Printf("[CRON2 \"%s\"]: got record from db", dev.GetString("name"))
status := dev.GetString("status")
logger.Debug.Printf("[CRON3 \"%s\"]: status is %s", dev.GetString("name"), status)
if status == "pending" || status == "online" {
logger.Debug.Printf("[CRON3.5 \"%s\"]: skipping run because already pending", dev.GetString("name"))
return
}
isOnline, err := networking.PingDevice(dev)
if err != nil {
logger.Error.Println(err)
return
}
if isOnline {
return
}
d.Set("status", "pending")
if err := app.Save(d); err != nil {
dev.Set("status", "pending")
if err := app.Dao().SaveRecord(dev); err != nil {
logger.Error.Println("Failed to save record:", err)
return
}
if err := networking.WakeDevice(d); err != nil {
logger.Debug.Printf("[CRON4 \"%s\"]: saved status pending", dev.GetString("name"))
if err := networking.WakeDevice(dev); err != nil {
logger.Error.Println(err)
d.Set("status", "offline")
dev.Set("status", "offline")
} else {
d.Set("status", "online")
dev.Set("status", "online")
}
if err := app.Save(d); err != nil {
logger.Debug.Printf("[CRON5 \"%s\"]: wake device done", dev.GetString("name"))
if err := app.Dao().SaveRecord(dev); err != nil {
logger.Error.Println("Failed to save record:", err)
}
logger.Debug.Printf("[CRON6 \"%s\"]: saved device", dev.GetString("name"))
})
if err != nil {
logger.Error.Printf("device %s: %+v", dev.GetString("name"), err)
logger.Error.Println(err)
}
}
if shutdown_cron_enabled && shutdown_cron != "" {
_, err := CronWakeShutdown.AddFunc(shutdown_cron, func() {
d, err := app.FindRecordById("devices", dev.Id)
dev, err = app.Dao().FindRecordById("devices", dev.Id)
if err != nil {
logger.Error.Println(err)
return
}
if d.GetString("status") == "pending" {
status := dev.GetString("status")
if status == "pending" || status == "offline" {
return
}
isOnline, err := networking.PingDevice(dev)
if err != nil {
logger.Error.Println(err)
return
}
if !isOnline {
return
}
status := d.GetString("status")
if status != "online" {
return
}
d.Set("status", "pending")
if err := app.Save(d); err != nil {
dev.Set("status", "pending")
if err := app.Dao().SaveRecord(dev); err != nil {
logger.Error.Println("Failed to save record:", err)
}
if err := networking.ShutdownDevice(d); err != nil {
if err := networking.ShutdownDevice(dev); err != nil {
logger.Error.Println(err)
d.Set("status", "online")
dev.Set("status", "online")
} else {
d.Set("status", "offline")
dev.Set("status", "offline")
}
if err := app.Save(d); err != nil {
if err := app.Dao().SaveRecord(dev); err != nil {
logger.Error.Println("Failed to save record:", err)
}
})
if err != nil {
logger.Error.Printf("device %s: %+v", dev.GetString("name"), err)
logger.Error.Println(err)
}
}
}
@@ -212,7 +192,8 @@ func StartWakeShutdown() {
func StopWakeShutdown() {
if WakeShutdownRunning {
logger.Info.Println("Stopping wake/shutdown cronjob")
CronWakeShutdown.Stop()
ctx := CronWakeShutdown.Stop()
<-ctx.Done()
}
WakeShutdownRunning = false
}
@@ -225,7 +206,8 @@ func StartPing() {
func StopPing() {
if PingRunning {
logger.Info.Println("Stopping wake/shutdown cronjob")
CronPing.Stop()
ctx := CronPing.Stop()
<-ctx.Done()
}
PingRunning = false
}
+66 -28
View File
@@ -1,51 +1,89 @@
module github.com/seriousm4x/upsnap
go 1.25.0
go 1.22.5
require (
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a
github.com/pocketbase/dbx v1.12.0
github.com/pocketbase/pocketbase v0.36.2
github.com/prometheus-community/pro-bing v0.8.0
github.com/pocketbase/dbx v1.10.1
github.com/pocketbase/pocketbase v0.22.18
github.com/prometheus-community/pro-bing v0.4.1
github.com/robfig/cron/v3 v3.0.1
golang.org/x/sys v0.41.0
golang.org/x/sys v0.22.0
)
require (
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2 v1.30.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 // indirect
github.com/aws/aws-sdk-go-v2/config v1.27.27 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.27 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 // indirect
github.com/aws/smithy-go v1.20.3 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/domodwyer/mailyak/v3 v3.6.2 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
github.com/ganigeorgiev/fexpr v0.5.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/ganigeorgiev/fexpr v0.4.1 // indirect
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
github.com/go-sql-driver/mysql v1.9.3 // indirect
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
github.com/mdlayher/packet v1.1.2 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/cobra v1.10.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/stretchr/testify v1.11.1 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/exp v0.0.0-20260212183809-81e46e3db34a // indirect
golang.org/x/image v0.36.0 // indirect
golang.org/x/net v0.50.0 // indirect
golang.org/x/oauth2 v0.35.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/text v0.34.0 // indirect
modernc.org/libc v1.67.6 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.44.3 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.opencensus.io v0.24.0 // indirect
gocloud.dev v0.37.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
google.golang.org/api v0.189.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
modernc.org/gc/v3 v3.0.0-20240722195230-4a140ff9c08e // indirect
modernc.org/libc v1.55.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.31.1 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)
+305 -81
View File
@@ -1,9 +1,73 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14=
cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU=
cloud.google.com/go/auth v0.7.2 h1:uiha352VrCDMXg+yoBtaD0tUF4Kv9vrtrWPYXwutnDE=
cloud.google.com/go/auth v0.7.2/go.mod h1:VEc4p5NNxycWQTMQEDQF0bd6aTMb6VgYDXEwiJJQAbs=
cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI=
cloud.google.com/go/auth/oauth2adapt v0.2.3/go.mod h1:tMQXOfZzFuNuUxOypHlQEXgdfX5cuhwU+ffUuXRJE8I=
cloud.google.com/go/compute v1.25.0 h1:H1/4SqSUhjPFE7L5ddzHOfY2bCAvjwNRZPNl6Ni5oYU=
cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=
cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=
cloud.google.com/go/iam v1.1.6 h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc=
cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI=
cloud.google.com/go/storage v1.39.1 h1:MvraqHKhogCOTXTlct/9C3K3+Uy2jBmFYb3/Sp6dVtY=
cloud.google.com/go/storage v1.39.1/go.mod h1:xK6xZmxZmo+fyP7+DEF6FhNc24/JAe95OLyOHCXFH1o=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/aws/aws-sdk-go v1.51.11 h1:El5VypsMIz7sFwAAj/j06JX9UGs4KAbAIEaZ57bNY4s=
github.com/aws/aws-sdk-go v1.51.11/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
github.com/aws/aws-sdk-go-v2 v1.30.3/go.mod h1:nIQjQVp5sfpQcTc9mPSr1B0PaWK5ByX9MOoDadSN4lc=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 h1:tW1/Rkad38LA15X4UQtjXZXNKsCgkshC3EbmcUmghTg=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3/go.mod h1:UbnqO+zjqk3uIt9yCACHJ9IVNhyhOCnYk8yA19SAWrM=
github.com/aws/aws-sdk-go-v2/config v1.27.27 h1:HdqgGt1OAP0HkEDDShEl0oSYa9ZZBSOmKpdpsDMdO90=
github.com/aws/aws-sdk-go-v2/config v1.27.27/go.mod h1:MVYamCg76dFNINkZFu4n4RjDixhVr51HLj4ErWzrVwg=
github.com/aws/aws-sdk-go-v2/credentials v1.17.27 h1:2raNba6gr2IfA0eqqiP2XiQ0UVOpGPgDSi0I9iAP+UI=
github.com/aws/aws-sdk-go-v2/credentials v1.17.27/go.mod h1:gniiwbGahQByxan6YjQUMcW4Aov6bLC3m+evgcoN4r4=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 h1:KreluoV8FZDEtI6Co2xuNk/UqI9iwMrOx/87PBNIKqw=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11/go.mod h1:SeSUYBLsMYFoRvHE0Tjvn7kbxaUhl75CJi1sbfhMxkU=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.8 h1:u1KOU1S15ufyZqmH/rA3POkiRH6EcDANHj2xHRzq+zc=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.8/go.mod h1:WPv2FRnkIOoDv/8j2gSUsI4qDc7392w5anFB/I89GZ8=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 h1:SoNJ4RlFEQEbtDcCEt+QG56MY4fm4W8rYirAmq+/DdU=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15/go.mod h1:U9ke74k1n2bf+RIgoX1SXFed1HLs51OgUSs+Ph0KJP8=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 h1:C6WHdGnTDIYETAm5iErQUiVNsclNx9qbJVPIt03B6bI=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15/go.mod h1:ZQLZqhcu+JhSrA9/NXRm8SkDvsycE+JkV3WGY41e+IM=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 h1:hT8rVHwugYE2lEfdFE0QWVo81lF7jMrYJVDWI+f+VxU=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0/go.mod h1:8tu/lYfQfFe6IGnaOdrpVgEL2IrrDOf6/m9RQum4NkY=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.15 h1:Z5r7SycxmSllHYmaAZPpmN8GviDrSGhMS6bldqtXZPw=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.15/go.mod h1:CetW7bDE00QoGEmPUoZuRog07SGVAUVW6LFpNP0YfIg=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 h1:dT3MqvGhSoaIhRseqw2I0yH81l7wiR2vjs57O51EAm8=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3/go.mod h1:GlAeCkHwugxdHaueRr4nhPuY+WW+gR8UjlcqzPr1SPI=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17 h1:YPYe6ZmvUfDDDELqEKtAd6bo8zxhkm+XEFEzQisqUIE=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17/go.mod h1:oBtcnYua/CgzCWYN7NZ5j7PotFDaFSUjCYVTtfyn7vw=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 h1:HGErhhrxZlQ044RiM+WdoZxp0p+EGM62y3L6pwA4olE=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17/go.mod h1:RkZEx4l0EHYDJpWppMJ3nD9wZJAa8/0lq9aVC+r2UII=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15 h1:246A4lSTXWJw/rmlQI+TT2OcqeDMKBdyjEQrafMaQdA=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.15/go.mod h1:haVfg3761/WF7YPuJOER2MP0k4UAXyHaLclKXB6usDg=
github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2 h1:sZXIzO38GZOU+O0C+INqbH7C2yALwfMWpd64tONS/NE=
github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2/go.mod h1:Lcxzg5rojyVPU/0eFwLtcyTaek/6Mtic5B1gJo7e/zE=
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4 h1:BXx0ZIxvrJdSgSvKTZ+yRBeSqqgPM89VPlulEcl37tM=
github.com/aws/aws-sdk-go-v2/service/sso v1.22.4/go.mod h1:ooyCOXjvJEsUw7x+ZDHeISPMhtwI3ZCB7ggFMcFfWLU=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4 h1:yiwVzJW2ZxZTurVbYWA7QOrAaCYQR72t0wrSBfoesUE=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.26.4/go.mod h1:0oxfLkpz3rQ/CHlx5hB7H69YUpFiI1tql6Q6Ne+1bCw=
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3 h1:ZsDKRLXGWHk8WdtyYMoGNO7bTudrvuKpDKgMVRlepGE=
github.com/aws/aws-sdk-go-v2/service/sts v1.30.3/go.mod h1:zwySh8fpFyXp9yOr/KVzxOl8SRqgf/IDw5aUt9UKFcQ=
github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE=
github.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -13,46 +77,101 @@ github.com/domodwyer/mailyak/v3 v3.6.2 h1:x3tGMsyFhTCaxp6ycgR0FE/bu5QiNp+hetUuCO
github.com/domodwyer/mailyak/v3 v3.6.2/go.mod h1:lOm/u9CyCVWHeaAmHIdF4RiKVxKUT/H5XX10lIKAL6c=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/ganigeorgiev/fexpr v0.5.0 h1:XA9JxtTE/Xm+g/JFI6RfZEHSiQlk+1glLvRK1Lpv/Tk=
github.com/ganigeorgiev/fexpr v0.5.0/go.mod h1:RyGiGqmeXhEQ6+mlGdnUleLHgtzzu/VGO2WtJkF5drE=
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/ganigeorgiev/fexpr v0.4.1 h1:hpUgbUEEWIZhSDBtf4M9aUNfQQ0BZkGRaMePy7Gcx5k=
github.com/ganigeorgiev/fexpr v0.4.1/go.mod h1:RyGiGqmeXhEQ6+mlGdnUleLHgtzzu/VGO2WtJkF5drE=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es=
github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/go-sql-driver/mysql v1.8.0 h1:UtktXaU2Nb64z/pLiGIxY4431SJ4/dR5cjMmlVHgnT4=
github.com/go-sql-driver/mysql v1.8.0/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc=
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0 h1:e+8XbKB6IMn8A4OAyZccO4pYfB3s7bt6azNIPE7AnPg=
github.com/google/pprof v0.0.0-20240625030939-27f56978b8b0/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o=
github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI=
github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA=
github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s=
github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61 h1:FwuzbVh87iLiUQj1+uQUsuw9x5t9m5n5g7rG7o4svW4=
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61/go.mod h1:paQfF1YtHe+GrGg5fOgjsjoCX/UKDr9bc1DoWpZfns8=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mdlayher/ethernet v0.0.0-20190313224307-5b5fc417d966/go.mod h1:5s5p/sMJ6sNsFl6uCh85lkFGV8kLuIYJCRJLavVJwvg=
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 h1:2oDp6OOhLxQ9JBoUuysVz9UZ9uI6oLUbvAZu0x8o+vE=
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118/go.mod h1:ZFUnHIVchZ9lJoWoEGUg8Q3M4U8aNNWA3CVSUTkW4og=
@@ -65,16 +184,20 @@ github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a h1:fpQi42PM6HzbHwNg6a7OvLbh5l49Rgr7GCARozjHwio=
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a/go.mod h1:XX6nvyQpGc8E4KaQm62FyexOYd36ilpyfYf8wjgMDV8=
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pocketbase/dbx v1.12.0 h1:/oLErM+A0b4xI0PWTGPqSDVjzix48PqI/bng2l0PzoA=
github.com/pocketbase/dbx v1.12.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
github.com/pocketbase/pocketbase v0.36.2 h1:mzrxnvXKc3yxKlvZdbwoYXkH8kfIETteD0hWdgj0VI4=
github.com/pocketbase/pocketbase v0.36.2/go.mod h1:71vSF8whUDzC8mcLFE10+Qatf9JQdeOGIRWawOuLLKM=
github.com/prometheus-community/pro-bing v0.8.0 h1:CEY/g1/AgERRDjxw5P32ikcOgmrSuXs7xon7ovx6mNc=
github.com/prometheus-community/pro-bing v0.8.0/go.mod h1:Idyxz8raDO6TgkUN6ByiEGvWJNyQd40kN9ZUeho3lN0=
github.com/pocketbase/dbx v1.10.1 h1:cw+vsyfCJD8YObOVeqb93YErnlxwYMkNZ4rwN0G0AaA=
github.com/pocketbase/dbx v1.10.1/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
github.com/pocketbase/pocketbase v0.22.18 h1:yVckUhi5GDORqCb0BbtlvRB1CVxHY9HO9btEaeZHVJU=
github.com/pocketbase/pocketbase v0.22.18/go.mod h1:0QFvDOOW7ANId78ChZSagyHbmP6CgMxDQrQFXzeaDpA=
github.com/prometheus-community/pro-bing v0.4.1 h1:aMaJwyifHZO0y+h8+icUz0xbToHbia0wdmzdVZ+Kl3w=
github.com/prometheus-community/pro-bing v0.4.1/go.mod h1:aLsw+zqCaDoa2RLVVSX3+UiCkBBXTMtZC3c7EkfWnAE=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
@@ -82,83 +205,184 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
gocloud.dev v0.37.0 h1:XF1rN6R0qZI/9DYjN16Uy0durAmSlf58DHOcb28GPro=
gocloud.dev v0.37.0/go.mod h1:7/O4kqdInCNsc6LqgmuFnS0GRew4XNNYWpA44yQnwco=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/exp v0.0.0-20260212183809-81e46e3db34a h1:ovFr6Z0MNmU7nH8VaX5xqw+05ST2uO1exVfZPVqRC5o=
golang.org/x/exp v0.0.0-20260212183809-81e46e3db34a/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.36.0 h1:Iknbfm1afbgtwPTmHnS2gTM/6PPZfH+z2EFuOkSbqwc=
golang.org/x/image v0.36.0/go.mod h1:YsWD2TyyGKiIX1kZlu9QfKIsQ4nAAK9bdgdrIsE7xy4=
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ=
golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk=
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
google.golang.org/api v0.189.0 h1:equMo30LypAkdkLMBqfeIqtyAnlyig1JSZArl4XPwdI=
google.golang.org/api v0.189.0/go.mod h1:FLWGJKb0hb+pU2j+rJqwbnsF+ym+fQs73rbJ+KAUgy8=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20240722135656-d784300faade h1:lKFsS7wpngDgSCeFn7MoLy+wBDQZ1UQIJD4UNM1Qvkg=
google.golang.org/genproto v0.0.0-20240722135656-d784300faade/go.mod h1:FfBgJBJg9GcpPvKIuHSZ/aE1g2ecGL74upMzGZjiGEY=
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY=
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a h1:hqK4+jJZXCU4pW7jsAdGOVFIfLHQeV7LaizZKnZ84HI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240723171418-e6d459c13d2a/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis=
modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc=
modernc.org/ccgo/v4 v4.30.1/go.mod h1:bIOeI1JL54Utlxn+LwrFyjCx2n2RDiYEaJVSrgdrRfM=
modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA=
modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE=
modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI=
modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.44.3 h1:+39JvV/HWMcYslAwRxHb8067w+2zowvFOUrOWIy9PjY=
modernc.org/sqlite v1.44.3/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ=
modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
modernc.org/ccgo/v4 v4.19.2 h1:lwQZgvboKD0jBwdaeVCTouxhxAyN6iawF3STraAal8Y=
modernc.org/ccgo/v4 v4.19.2/go.mod h1:ysS3mxiMV38XGRTTcgo0DQTeTmAO4oCmJl1nX9VFI3s=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw=
modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
modernc.org/gc/v3 v3.0.0-20240722195230-4a140ff9c08e h1:WPC4v0rNIFb2PY+nBBEEKyugPPRHPzUgyN3xZPpGK58=
modernc.org/gc/v3 v3.0.0-20240722195230-4a140ff9c08e/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
modernc.org/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U=
modernc.org/libc v1.55.3/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
modernc.org/sqlite v1.31.1 h1:XVU0VyzxrYHlBhIs1DiEgSl0ZtdnPtbLVy8hSkzxGrs=
modernc.org/sqlite v1.31.1/go.mod h1:UqoylwmTb9F+IqXERT8bW9zzOWN8qwAIcLdzeBZs4hA=
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
+2 -2
View File
@@ -3,13 +3,13 @@ package main
import (
"embed"
"github.com/pocketbase/pocketbase/apis"
"github.com/labstack/echo/v5"
"github.com/seriousm4x/upsnap/pb"
)
//go:embed all:pb_public
var distDir embed.FS
var distDirFS = apis.MustSubFS(distDir, "pb_public")
var distDirFS = echo.MustSubFS(distDir, "pb_public")
func main() {
pb.StartPocketBase(distDirFS)
@@ -0,0 +1,207 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
jsonData := `{
"id": "z5lghx2r3tm45n1",
"created": "2023-01-28 19:10:29.223Z",
"updated": "2023-01-28 19:10:29.223Z",
"name": "devices",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "tiqcmnjo",
"name": "name",
"type": "text",
"required": true,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "1si6ajha",
"name": "ip",
"type": "text",
"required": true,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "fyqmpon6",
"name": "mac",
"type": "text",
"required": true,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "s8c5z7n0",
"name": "netmask",
"type": "text",
"required": true,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "qqvyfrex",
"name": "status",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "ilrwvlev",
"name": "ports",
"type": "relation",
"required": false,
"unique": false,
"options": {
"maxSelect": null,
"collectionId": "cti4l8f4mz8df3r",
"cascadeDelete": false
}
},
{
"system": false,
"id": "gdctb8hj",
"name": "link",
"type": "url",
"required": false,
"unique": false,
"options": {
"exceptDomains": null,
"onlyDomains": null
}
},
{
"system": false,
"id": "kzvdbbws",
"name": "wake_cron",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "dcd3vuc3",
"name": "wake_cron_enabled",
"type": "bool",
"required": false,
"unique": false,
"options": {}
},
{
"system": false,
"id": "91bs6clw",
"name": "shutdown_cron",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "vnlymcuw",
"name": "shutdown_cron_enabled",
"type": "bool",
"required": false,
"unique": false,
"options": {}
},
{
"system": false,
"id": "1a7yrwo9",
"name": "shutdown_cmd",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "iarksm3l",
"name": "password",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}
],
"listRule": "",
"viewRule": "",
"createRule": "",
"updateRule": "",
"deleteRule": "",
"options": {}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
})
}
@@ -0,0 +1,81 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
jsonData := `{
"id": "cti4l8f4mz8df3r",
"created": "2023-01-28 19:10:29.223Z",
"updated": "2023-01-28 19:10:29.223Z",
"name": "ports",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "8nwuncgg",
"name": "number",
"type": "number",
"required": true,
"unique": false,
"options": {
"min": null,
"max": 65535
}
},
{
"system": false,
"id": "o0he3pu6",
"name": "name",
"type": "text",
"required": true,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "w0bh39gv",
"name": "status",
"type": "bool",
"required": false,
"unique": false,
"options": {}
}
],
"listRule": "",
"viewRule": "",
"createRule": "",
"updateRule": "",
"deleteRule": "",
"options": {}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
})
}
@@ -0,0 +1,86 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
jsonData := `{
"id": "nmj3ko20gzkg8n3",
"created": "2023-01-28 19:10:29.223Z",
"updated": "2023-01-28 19:10:29.223Z",
"name": "settings",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "ph88gaa5",
"name": "interval",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "agw2fyd1",
"name": "scan_range",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "slrjkipw",
"name": "website_title",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}
],
"listRule": "",
"viewRule": "",
"createRule": "",
"updateRule": "",
"deleteRule": "",
"options": {}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
})
}
@@ -0,0 +1,90 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
}, func(db dbx.Builder) error {
jsonData := `{
"id": "_pb_users_auth_",
"created": "2023-01-28 19:10:12.835Z",
"updated": "2023-01-28 19:10:12.835Z",
"name": "users",
"type": "auth",
"system": false,
"schema": [
{
"system": false,
"id": "users_name",
"name": "name",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "users_avatar",
"name": "avatar",
"type": "file",
"required": false,
"unique": false,
"options": {
"maxSelect": 1,
"maxSize": 5242880,
"mimeTypes": [
"image/jpg",
"image/jpeg",
"image/png",
"image/svg+xml",
"image/gif",
"image/webp"
],
"thumbs": null
}
}
],
"listRule": "id = @request.auth.id",
"viewRule": "id = @request.auth.id",
"createRule": "",
"updateRule": "id = @request.auth.id",
"deleteRule": "id = @request.auth.id",
"options": {
"allowEmailAuth": true,
"allowOAuth2Auth": true,
"allowUsernameAuth": true,
"exceptEmailDomains": null,
"manageRule": null,
"minPasswordLength": 8,
"onlyEmailDomains": null,
"requireEmail": false
}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
})
}
@@ -0,0 +1,55 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
jsonData := `{
"id": "27do0wbcuyfmbmx",
"created": "2023-03-04 20:33:00.558Z",
"updated": "2023-03-04 20:33:00.558Z",
"name": "users",
"type": "auth",
"system": false,
"schema": [],
"listRule": null,
"viewRule": null,
"createRule": null,
"updateRule": null,
"deleteRule": null,
"options": {
"allowEmailAuth": true,
"allowOAuth2Auth": false,
"allowUsernameAuth": true,
"exceptEmailDomains": [],
"manageRule": null,
"minPasswordLength": 8,
"onlyEmailDomains": [],
"requireEmail": false
}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
})
}
@@ -0,0 +1,50 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
collection.CreateRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
collection.ListRule = nil
collection.ViewRule = nil
collection.CreateRule = types.Pointer("")
collection.UpdateRule = types.Pointer("")
collection.DeleteRule = types.Pointer("")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,50 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
if err != nil {
return err
}
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
collection.CreateRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
if err != nil {
return err
}
collection.ListRule = nil
collection.ViewRule = nil
collection.CreateRule = types.Pointer("")
collection.UpdateRule = types.Pointer("")
collection.DeleteRule = types.Pointer("")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,50 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
if err != nil {
return err
}
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
collection.CreateRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
if err != nil {
return err
}
collection.ListRule = nil
collection.ViewRule = nil
collection.CreateRule = types.Pointer("")
collection.UpdateRule = types.Pointer("")
collection.DeleteRule = types.Pointer("")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,80 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
jsonData := `{
"id": "t1rajoyzl6691g3",
"created": "2023-03-09 22:17:29.463Z",
"updated": "2023-03-09 22:17:29.463Z",
"name": "settings_public",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "s1grje98",
"name": "website_title",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
},
{
"system": false,
"id": "tlzz87pj",
"name": "favicon",
"type": "file",
"required": false,
"unique": false,
"options": {
"maxSelect": 1,
"maxSize": 5242880,
"mimeTypes": [
"image/x-icon",
"image/png",
"image/svg+xml",
"image/gif",
"image/jpeg"
],
"thumbs": []
}
}
],
"listRule": "",
"viewRule": "",
"createRule": null,
"updateRule": null,
"deleteRule": null,
"options": {}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("t1rajoyzl6691g3")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
})
}
@@ -0,0 +1,65 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
if err != nil {
return err
}
collection.Name = "settings_private"
collection.ListRule = nil
collection.ViewRule = nil
// remove
collection.Schema.RemoveField("slrjkipw")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
if err != nil {
return err
}
collection.Name = "settings"
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
// add
del_website_title := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "slrjkipw",
"name": "website_title",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}`), del_website_title)
collection.Schema.AddField(del_website_title)
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,48 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("t1rajoyzl6691g3")
if err != nil {
return err
}
// add
new_setup_completed := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "vrxqcsnv",
"name": "setup_completed",
"type": "bool",
"required": false,
"unique": false,
"options": {}
}`), new_setup_completed)
collection.Schema.AddField(new_setup_completed)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("t1rajoyzl6691g3")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("vrxqcsnv")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,61 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
jsonData := `{
"id": "djqp3uxrac2ores",
"created": "2023-06-29 10:39:59.291Z",
"updated": "2023-06-29 10:39:59.291Z",
"name": "groups",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "b3oaemnp",
"name": "name",
"type": "text",
"required": true,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}
],
"indexes": [],
"listRule": "@request.auth.id != \"\"",
"viewRule": "@request.auth.id != \"\"",
"createRule": null,
"updateRule": null,
"deleteRule": null,
"options": {}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
})
}
@@ -0,0 +1,54 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add
new_groups := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rk2vrn57",
"name": "groups",
"type": "relation",
"required": false,
"unique": false,
"options": {
"collectionId": "djqp3uxrac2ores",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": null,
"displayFields": []
}
}`), new_groups)
collection.Schema.AddField(new_groups)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("rk2vrn57")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,57 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
options := map[string]any{}
json.Unmarshal([]byte(`{
"allowEmailAuth": true,
"allowOAuth2Auth": true,
"allowUsernameAuth": true,
"exceptEmailDomains": [],
"manageRule": null,
"minPasswordLength": 8,
"onlyEmailDomains": [],
"requireEmail": false
}`), &options)
collection.SetOptions(options)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
options := map[string]any{}
json.Unmarshal([]byte(`{
"allowEmailAuth": true,
"allowOAuth2Auth": false,
"allowUsernameAuth": true,
"exceptEmailDomains": [],
"manageRule": null,
"minPasswordLength": 8,
"onlyEmailDomains": [],
"requireEmail": false
}`), &options)
collection.SetOptions(options)
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,34 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
collection.CreateRule = types.Pointer("@request.data.password:isset = false")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
collection.CreateRule = nil
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,57 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
options := map[string]any{}
json.Unmarshal([]byte(`{
"allowEmailAuth": true,
"allowOAuth2Auth": true,
"allowUsernameAuth": true,
"exceptEmailDomains": [],
"manageRule": null,
"minPasswordLength": 5,
"onlyEmailDomains": [],
"requireEmail": false
}`), &options)
collection.SetOptions(options)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
options := map[string]any{}
json.Unmarshal([]byte(`{
"allowEmailAuth": true,
"allowOAuth2Auth": true,
"allowUsernameAuth": true,
"exceptEmailDomains": [],
"manageRule": null,
"minPasswordLength": 8,
"onlyEmailDomains": [],
"requireEmail": false
}`), &options)
collection.SetOptions(options)
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,33 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
if err != nil {
return err
}
collection.Name = "device_groups"
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
if err != nil {
return err
}
collection.Name = "groups"
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,140 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models"
)
func init() {
m.Register(func(db dbx.Builder) error {
jsonData := `{
"id": "7emu7fnnwuim2ua",
"created": "2023-08-10 21:19:39.520Z",
"updated": "2023-08-10 21:19:39.520Z",
"name": "permissions",
"type": "base",
"system": false,
"schema": [
{
"system": false,
"id": "tzxtuykz",
"name": "user",
"type": "relation",
"required": false,
"unique": false,
"options": {
"collectionId": "27do0wbcuyfmbmx",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": []
}
},
{
"system": false,
"id": "nd1ekexz",
"name": "create",
"type": "bool",
"required": false,
"unique": false,
"options": {}
},
{
"system": false,
"id": "z79gcpy3",
"name": "read",
"type": "relation",
"required": false,
"unique": false,
"options": {
"collectionId": "z5lghx2r3tm45n1",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": null,
"displayFields": [
"name"
]
}
},
{
"system": false,
"id": "t7wwbk2c",
"name": "update",
"type": "relation",
"required": false,
"unique": false,
"options": {
"collectionId": "z5lghx2r3tm45n1",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": null,
"displayFields": [
"name"
]
}
},
{
"system": false,
"id": "b4u0gqa7",
"name": "delete",
"type": "relation",
"required": false,
"unique": false,
"options": {
"collectionId": "z5lghx2r3tm45n1",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": null,
"displayFields": [
"name"
]
}
},
{
"system": false,
"id": "nyeqt3fn",
"name": "power",
"type": "relation",
"required": false,
"unique": false,
"options": {
"collectionId": "z5lghx2r3tm45n1",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": null,
"displayFields": []
}
}
],
"indexes": [
"CREATE UNIQUE INDEX ` + "`" + `idx_2GIk1Fo` + "`" + ` ON ` + "`" + `permissions` + "`" + ` (` + "`" + `user` + "`" + `)"
],
"listRule": "@request.auth.id = user.id",
"viewRule": "@request.auth.id = user.id",
"createRule": null,
"updateRule": null,
"deleteRule": "@request.auth.id = user.id",
"options": {}
}`
collection := &models.Collection{}
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
return err
}
return daos.New(db).SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("7emu7fnnwuim2ua")
if err != nil {
return err
}
return dao.DeleteCollection(collection)
})
}
@@ -0,0 +1,77 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
collection.ListRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.read.id")
collection.ViewRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.read.id")
collection.CreateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
collection.UpdateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.update.id")
collection.DeleteRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.delete.id")
// add
new_created_by := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "naciykac",
"name": "created_by",
"type": "relation",
"required": false,
"unique": false,
"options": {
"collectionId": "27do0wbcuyfmbmx",
"cascadeDelete": false,
"minSelect": null,
"maxSelect": 1,
"displayFields": [
"username"
]
}
}`), new_created_by)
collection.Schema.AddField(new_created_by)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
collection.ListRule = nil
collection.ViewRule = nil
collection.CreateRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
// remove
collection.Schema.RemoveField("naciykac")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,42 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
if err != nil {
return err
}
collection.CreateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
collection.UpdateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
collection.DeleteRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
if err != nil {
return err
}
collection.CreateRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,75 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("qqvyfrex")
// add
new_status := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qmiatdwa",
"name": "status",
"type": "select",
"required": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"pending",
"online",
"offline"
]
}
}`), new_status)
collection.Schema.AddField(new_status)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add
del_status := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "qqvyfrex",
"name": "status",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}`), del_status)
collection.Schema.AddField(del_status)
// remove
collection.Schema.RemoveField("qmiatdwa")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,68 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
collection.ListRule = types.Pointer("@request.auth.id = id")
collection.ViewRule = types.Pointer("@request.auth.id = id")
collection.UpdateRule = types.Pointer("@request.auth.id = id")
collection.DeleteRule = types.Pointer("@request.auth.id = id")
// add
new_avatar := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "i1qnezoa",
"name": "avatar",
"type": "number",
"required": false,
"unique": false,
"options": {
"min": 0,
"max": 9
}
}`), new_avatar)
collection.Schema.AddField(new_avatar)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
collection.ListRule = nil
collection.ViewRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
// remove
collection.Schema.RemoveField("i1qnezoa")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,48 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
if err != nil {
return err
}
// add
new_lazy_ping := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "yjyq5pvg",
"name": "lazy_ping",
"type": "bool",
"required": false,
"unique": false,
"options": {}
}`), new_lazy_ping)
collection.Schema.AddField(new_lazy_ping)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("yjyq5pvg")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,42 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
if err != nil {
return err
}
collection.CreateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
collection.UpdateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
collection.DeleteRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
if err != nil {
return err
}
collection.CreateRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,50 @@
package migrations
import (
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/tools/types"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
collection.ListRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.read.id")
collection.ViewRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.read.id")
collection.CreateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
collection.UpdateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.update.id")
collection.DeleteRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.delete.id")
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
collection.ListRule = nil
collection.ViewRule = nil
collection.CreateRule = nil
collection.UpdateRule = nil
collection.DeleteRule = nil
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,123 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add
new_sol_enabled := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "ueieydw5",
"name": "sol_enabled",
"type": "bool",
"required": false,
"unique": false,
"options": {}
}`), new_sol_enabled)
collection.Schema.AddField(new_sol_enabled)
// add
new_sol_auth := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "yfszwhpw",
"name": "sol_auth",
"type": "bool",
"required": false,
"unique": false,
"options": {}
}`), new_sol_auth)
collection.Schema.AddField(new_sol_auth)
// add
new_sol_user := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "dbcmnrmp",
"name": "sol_user",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}`), new_sol_user)
collection.Schema.AddField(new_sol_user)
// add
new_sol_password := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "hvz8stfy",
"name": "sol_password",
"type": "text",
"required": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}`), new_sol_password)
collection.Schema.AddField(new_sol_password)
// add
new_sol_port := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "6kfqheid",
"name": "sol_port",
"type": "number",
"required": true,
"unique": false,
"options": {
"min": 1,
"max": 65535
}
}`), new_sol_port)
collection.Schema.AddField(new_sol_port)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("ueieydw5")
// remove
collection.Schema.RemoveField("yfszwhpw")
// remove
collection.Schema.RemoveField("dbcmnrmp")
// remove
collection.Schema.RemoveField("hvz8stfy")
// remove
collection.Schema.RemoveField("6kfqheid")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,64 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
if err != nil {
return err
}
// update
edit_number := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "8nwuncgg",
"name": "number",
"type": "number",
"required": true,
"unique": false,
"options": {
"min": 1,
"max": 65535
}
}`), edit_number)
collection.Schema.AddField(edit_number)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
if err != nil {
return err
}
// update
edit_number := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "8nwuncgg",
"name": "number",
"type": "number",
"required": true,
"unique": false,
"options": {
"min": null,
"max": 65535
}
}`), edit_number)
collection.Schema.AddField(edit_number)
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,64 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// update
edit_sol_port := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "6kfqheid",
"name": "sol_port",
"type": "number",
"required": false,
"unique": false,
"options": {
"min": 1,
"max": 65535
}
}`), edit_sol_port)
collection.Schema.AddField(edit_sol_port)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// update
edit_sol_port := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "6kfqheid",
"name": "sol_port",
"type": "number",
"required": true,
"unique": false,
"options": {
"min": 1,
"max": 65535
}
}`), edit_sol_port)
collection.Schema.AddField(edit_sol_port)
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,66 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add
new_wake_confirm := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "chtoblvl",
"name": "wake_confirm",
"type": "bool",
"required": false,
"presentable": false,
"unique": false,
"options": {}
}`), new_wake_confirm)
collection.Schema.AddField(new_wake_confirm)
// add
new_shutdown_confirm := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "muqy3axq",
"name": "shutdown_confirm",
"type": "bool",
"required": false,
"presentable": false,
"unique": false,
"options": {}
}`), new_shutdown_confirm)
collection.Schema.AddField(new_shutdown_confirm)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("chtoblvl")
// remove
collection.Schema.RemoveField("muqy3axq")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,74 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add
new_wake_cmd := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "murx1eum",
"name": "wake_cmd",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}`), new_wake_cmd)
collection.Schema.AddField(new_wake_cmd)
// add
new_ping_cmd := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "kefxqjbj",
"name": "ping_cmd",
"type": "text",
"required": false,
"presentable": false,
"unique": false,
"options": {
"min": null,
"max": null,
"pattern": ""
}
}`), new_ping_cmd)
collection.Schema.AddField(new_ping_cmd)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("murx1eum")
// remove
collection.Schema.RemoveField("kefxqjbj")
return dao.SaveCollection(collection)
})
}
@@ -0,0 +1,52 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
if err != nil {
return err
}
// add
new_link := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "i3uvw7ij",
"name": "link",
"type": "url",
"required": false,
"presentable": false,
"unique": false,
"options": {
"exceptDomains": null,
"onlyDomains": null
}
}`), new_link)
collection.Schema.AddField(new_link)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
if err != nil {
return err
}
// remove
collection.Schema.RemoveField("i3uvw7ij")
return dao.SaveCollection(collection)
})
}
File diff suppressed because it is too large Load Diff
@@ -1,43 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
if err != nil {
return err
}
// add field
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
"hidden": false,
"id": "number376926767",
"max": 9,
"min": 0,
"name": "avatar",
"onlyInt": false,
"presentable": false,
"required": false,
"system": false,
"type": "number"
}`)); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
if err != nil {
return err
}
// remove field
collection.Fields.RemoveById("number376926767")
return app.Save(collection)
})
}
@@ -1,56 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
if err != nil {
return err
}
// update field
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
"hidden": false,
"id": "number376926767",
"max": 9,
"min": 0,
"name": "avatar",
"onlyInt": true,
"presentable": false,
"required": false,
"system": false,
"type": "number"
}`)); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
if err != nil {
return err
}
// update field
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
"hidden": false,
"id": "number376926767",
"max": 9,
"min": 0,
"name": "avatar",
"onlyInt": false,
"presentable": false,
"required": false,
"system": false,
"type": "number"
}`)); err != nil {
return err
}
return app.Save(collection)
})
}
@@ -1,40 +0,0 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
// update collection data
if err := json.Unmarshal([]byte(`{
"createRule": ""
}`), &collection); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("27do0wbcuyfmbmx")
if err != nil {
return err
}
// update collection data
if err := json.Unmarshal([]byte(`{
"createRule": "@request.body.password:isset = false"
}`), &collection); err != nil {
return err
}
return app.Save(collection)
})
}
@@ -1,106 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
// Up migration: Change `url` field type from URL to string
collectionName := "devices"
return app.RunInTransaction(func(txApp core.App) error {
// Step 1: Fetch the collection
collection, err := txApp.FindCollectionByNameOrId(collectionName)
if err != nil {
return err
}
// Step 2: Add a new text field
newField := &core.TextField{
Name: "new_field",
Required: false,
}
collection.Fields.AddAt(6, newField)
if err := txApp.Save(collection); err != nil {
return err
}
// Step 3: Migrate data from `url` to `new_field`
records, err := txApp.FindAllRecords(collectionName)
if err != nil {
return err
}
for _, record := range records {
url := record.GetString("link")
record.Set("new_field", url)
if err := txApp.Save(record); err != nil {
return err
}
}
// Step 4: Remove the old `url` field
collection.Fields.RemoveByName("link")
if err := txApp.Save(collection); err != nil {
return err
}
// Step 5: Rename `new_field` to `url`
renamedField := collection.Fields.GetByName("new_field")
renamedField.SetName("link")
return txApp.Save(collection)
})
}, func(app core.App) error {
// Down migration: Restore the `url` field
collectionName := "devices"
return app.RunInTransaction(func(txApp core.App) error {
// Step 1: Fetch the collection
collection, err := txApp.FindCollectionByNameOrId(collectionName)
if err != nil {
return err
}
// Step 2: Add a new `url` field
newField := &core.URLField{
Name: "new_field",
Required: false,
}
collection.Fields.AddAt(6, newField)
if err := txApp.Save(collection); err != nil {
return err
}
// Step 3: Migrate data from `url` to `new_field`
records, err := txApp.FindAllRecords(collectionName)
if err != nil {
return err
}
for _, record := range records {
text := record.GetString("link")
record.Set("new_field", text)
if err := txApp.Save(record); err != nil {
return err
}
}
// Step 4: Remove the old `url` field
collection.Fields.RemoveByName("link")
if err := txApp.Save(collection); err != nil {
return err
}
// Step 5: Rename `new_field` to `url`
renamedField := collection.Fields.GetByName("new_field")
renamedField.SetName("link")
return txApp.Save(collection)
})
})
}
@@ -1,106 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
// Up migration: Change `url` field type from URL to string
collectionName := "ports"
return app.RunInTransaction(func(txApp core.App) error {
// Step 1: Fetch the collection
collection, err := txApp.FindCollectionByNameOrId(collectionName)
if err != nil {
return err
}
// Step 2: Add a new text field
newField := &core.TextField{
Name: "new_field",
Required: false,
}
collection.Fields.AddAt(5, newField)
if err := txApp.Save(collection); err != nil {
return err
}
// Step 3: Migrate data from `url` to `new_field`
records, err := txApp.FindAllRecords(collectionName)
if err != nil {
return err
}
for _, record := range records {
url := record.GetString("link")
record.Set("new_field", url)
if err := txApp.Save(record); err != nil {
return err
}
}
// Step 4: Remove the old `url` field
collection.Fields.RemoveByName("link")
if err := txApp.Save(collection); err != nil {
return err
}
// Step 5: Rename `new_field` to `url`
renamedField := collection.Fields.GetByName("new_field")
renamedField.SetName("link")
return txApp.Save(collection)
})
}, func(app core.App) error {
// Down migration: Restore the `url` field
collectionName := "ports"
return app.RunInTransaction(func(txApp core.App) error {
// Step 1: Fetch the collection
collection, err := txApp.FindCollectionByNameOrId(collectionName)
if err != nil {
return err
}
// Step 2: Add a new `url` field
newField := &core.URLField{
Name: "new_field",
Required: false,
}
collection.Fields.AddAt(5, newField)
if err := txApp.Save(collection); err != nil {
return err
}
// Step 3: Migrate data from `url` to `new_field`
records, err := txApp.FindAllRecords(collectionName)
if err != nil {
return err
}
for _, record := range records {
text := record.GetString("link")
record.Set("new_field", text)
if err := txApp.Save(record); err != nil {
return err
}
}
// Step 4: Remove the old `url` field
collection.Fields.RemoveByName("link")
if err := txApp.Save(collection); err != nil {
return err
}
// Step 5: Rename `new_field` to `url`
renamedField := collection.Fields.GetByName("new_field")
renamedField.SetName("link")
return txApp.Save(collection)
})
})
}
@@ -1,45 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add field
if err := collection.Fields.AddMarshaledJSONAt(5, []byte(`{
"autogeneratePattern": "",
"hidden": false,
"id": "text1843675174",
"max": 0,
"min": 0,
"name": "description",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}`)); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove field
collection.Fields.RemoveById("text1843675174")
return app.Save(collection)
})
}
@@ -1,45 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add field
if err := collection.Fields.AddMarshaledJSONAt(8, []byte(`{
"hidden": false,
"id": "select355930381",
"maxSelect": 1,
"name": "link_open",
"presentable": false,
"required": false,
"system": false,
"type": "select",
"values": [
"same_tab",
"new_tab"
]
}`)); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove field
collection.Fields.RemoveById("select355930381")
return app.Save(collection)
})
}
@@ -1,43 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add field
if err := collection.Fields.AddMarshaledJSONAt(11, []byte(`{
"hidden": false,
"id": "number361076486",
"max": null,
"min": 1,
"name": "wake_timeout",
"onlyInt": true,
"presentable": false,
"required": false,
"system": false,
"type": "number"
}`)); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove field
collection.Fields.RemoveById("number361076486")
return app.Save(collection)
})
}
@@ -1,43 +0,0 @@
package migrations
import (
"github.com/pocketbase/pocketbase/core"
m "github.com/pocketbase/pocketbase/migrations"
)
func init() {
m.Register(func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// add field
if err := collection.Fields.AddMarshaledJSONAt(15, []byte(`{
"hidden": false,
"id": "number2068100152",
"max": null,
"min": 1,
"name": "shutdown_timeout",
"onlyInt": true,
"presentable": false,
"required": false,
"system": false,
"type": "number"
}`)); err != nil {
return err
}
return app.Save(collection)
}, func(app core.App) error {
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
if err != nil {
return err
}
// remove field
collection.Fields.RemoveById("number2068100152")
return app.Save(collection)
})
}
+6 -24
View File
@@ -6,10 +6,10 @@ import (
"net"
"github.com/mdlayher/wol"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
)
func SendMagicPacket(device *core.Record) error {
func SendMagicPacket(device *models.Record) error {
ip := device.GetString("ip")
mac := device.GetString("mac")
netmask := device.GetString("netmask")
@@ -32,41 +32,23 @@ func SendMagicPacket(device *core.Record) error {
if err != nil {
return err
}
targetAddr := fmt.Sprintf("%s:%d", broadcastIp, 9)
// send wake via udp port 9
if err := wakeUDP(broadcastIp, parsedMac, bytePassword); err != nil {
if err := wakeUDP(targetAddr, parsedMac, bytePassword); err != nil {
return err
}
return nil
}
func wakeUDP(broadcastIp string, target net.HardwareAddr, password []byte) error {
func wakeUDP(addr string, target net.HardwareAddr, password []byte) error {
c, err := wol.NewClient()
if err != nil {
return err
}
defer c.Close()
// send 4 magic packets to different addresses to enhance change of waking up
destinations := []string{
// default user-calculated broadcast to port 9
fmt.Sprintf("%s:9", broadcastIp),
// user-calculated broadcast to port alternative port 7
fmt.Sprintf("%s:7", broadcastIp),
// broadcast to port 9
"255.255.255.255:9",
// broadcast to alternative port 7
"255.255.255.255:7",
}
for _, dest := range destinations {
if err := c.WakePassword(dest, target, password); err != nil {
return err
}
}
return nil
return c.WakePassword(addr, target, password)
}
func getBroadcastIp(ipStr, maskStr string) (string, error) {
+114 -181
View File
@@ -1,10 +1,11 @@
package networking
import (
"fmt"
"net"
"testing"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
)
type Device struct {
@@ -16,216 +17,148 @@ type Device struct {
}
func TestSendMagicPacket(t *testing.T) {
testCases := []struct {
name string
ip string
mac string
netmask string
password string
wantError bool
}{
// Valid case: all inputs correct
collection := &models.Collection{}
devices_success := []Device{
{
name: "Valid Case",
ip: "192.168.1.100",
mac: "00:11:22:33:44:55",
netmask: "255.255.255.0",
password: "secret",
wantError: false,
IP: "8.8.8.8",
MAC: "aa:aa:aa:aa:aa:aa",
Netmask: "255.0.0.0",
Password: "",
},
// Invalid MAC address
{
name: "Invalid MAC",
ip: "192.168.1.100",
mac: "invalid",
netmask: "255.255.255.0",
password: "secret",
wantError: true,
},
// Password too short
{
name: "Password Too Short",
ip: "192.168.1.100",
mac: "00:11:22:33:44:55",
netmask: "255.255.255.0",
password: "s", // length 1
wantError: true,
},
// Password too long
{
name: "Password Too Long",
ip: "192.168.1.100",
mac: "00:11:22:33:44:55",
netmask: "255.255.255.0",
password: "password", // length 9
wantError: true,
},
// Invalid IP address
{
name: "Invalid IP",
ip: "256.1.1.1", // invalid
mac: "00:11:22:33:44:55",
netmask: "255.255.255.0",
password: "secret",
wantError: true,
},
// Invalid netmask
{
name: "Invalid Netmask",
ip: "192.168.1.100",
mac: "00:11:22:33:44:55",
netmask: "300.255.255.0", // invalid
password: "secret",
wantError: true,
IP: "1.1.1.1",
MAC: "bb:bb:bb:bb:bb:bb",
Netmask: "255.255.0.0",
Password: "abcd",
},
}
collection := &core.Collection{}
devices_fail := []Device{
{
IP: "1.1.1.1",
MAC: "aa",
Netmask: "255.255.0.0",
Password: "abcd",
},
{
IP: "1.1.1.1",
MAC: "cc:cc:cc:cc:cc:cc",
Netmask: "255.255.0.0",
Password: "abcdefg",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
device := core.NewRecord(collection)
device.Set("ip", tc.ip)
device.Set("mac", tc.mac)
device.Set("netmask", tc.netmask)
device.Set("password", tc.password)
for _, v := range devices_success {
device := models.NewRecord(collection)
device.Set("ip", v.IP)
device.Set("mac", v.MAC)
device.Set("netmask", v.Netmask)
device.Set("password", v.Password)
err := SendMagicPacket(device)
if tc.wantError {
if err == nil {
t.Errorf("Expected error but got none")
}
} else {
if err != nil {
t.Errorf("Got unexpected error: %v", err)
}
}
})
if err := SendMagicPacket(device); err != nil {
t.Fatal(err)
}
}
for _, v := range devices_fail {
device := models.NewRecord(collection)
device.Set("ip", v.IP)
device.Set("mac", v.MAC)
device.Set("netmask", v.Netmask)
device.Set("password", v.Password)
if err := SendMagicPacket(device); err == nil {
t.Fatal("should have cause an error")
}
}
}
func TestWakeUDP(t *testing.T) {
testCases := []struct {
name string
broadcastIp string
targetMac string
password string
wantError bool
}{
// Valid case: all inputs correct
devices := []Device{
{
name: "Valid Case",
broadcastIp: "192.168.1.255",
targetMac: "00:11:22:33:44:55",
password: "secret",
wantError: false,
IP: "8.8.8.8",
MAC: "aa:aa:aa:aa:aa:aa",
Netmask: "255.0.0.0",
Password: "",
ExpectFailPassword: false,
},
// Invalid MAC address
{
name: "Invalid MAC",
broadcastIp: "192.168.1.255",
targetMac: "invalid",
password: "secret",
wantError: true,
IP: "1.1.1.1",
MAC: "bb:bb:bb:bb:bb:bb",
Netmask: "255.255.0.0",
Password: "abcd",
ExpectFailPassword: false,
},
// Password too short
{
name: "Password Too Short",
broadcastIp: "192.168.1.255",
targetMac: "00:11:22:33:44:55",
password: "s", // length 1
wantError: true,
IP: "10.10.10.1",
MAC: "cc:cc:cc:cc:cc:cc",
Netmask: "255.255.0.0",
Password: "abcd",
ExpectFailPassword: false,
},
// Password too long
{
name: "Password Too Long",
broadcastIp: "192.168.1.255",
targetMac: "00:11:22:33:44:55",
password: "password", // length 9
wantError: true,
IP: "1.1.1.1",
MAC: "dd:dd:dd:dd:dd:dd",
Netmask: "255.255.0.0",
Password: "abcdefg",
ExpectFailPassword: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
mac, err := net.ParseMAC(tc.targetMac)
if err != nil && !tc.wantError {
t.Errorf("Unexpected error parsing MAC: %v", err)
} else if err != nil {
return
}
for _, v := range devices {
parsedMac, err := net.ParseMAC(v.MAC)
if err != nil {
t.Fatalf(`%v (parsedMac "%v")`, err, parsedMac)
}
// Now test the wakeUDP function
err = wakeUDP(tc.broadcastIp, mac, []byte(tc.password))
if tc.wantError {
if err == nil {
t.Errorf("Expected error but got none")
}
}
})
var bytePassword []byte
if len(v.Password) == 0 || len(v.Password) == 4 || len(v.Password) == 6 {
bytePassword = []byte(v.Password)
} else if !v.ExpectFailPassword {
t.Fatal("password must be 0, 4 or 6 characters long")
}
broadcastIp, err := getBroadcastIp(v.IP, v.Netmask)
if err != nil {
t.Fatal(err)
}
targetAddr := fmt.Sprintf("%s:%d", broadcastIp, 9)
if err := wakeUDP(targetAddr, parsedMac, bytePassword); err != nil {
t.Fatalf(`%v (targetAddr "%v", parsedMac "%v", bytePassword "%v")`, err, targetAddr, parsedMac, bytePassword)
}
}
}
func TestGetBroadcastIp(t *testing.T) {
testCases := []struct {
name string
ip string
netmask string
wantIp string
wantError bool
}{
// Valid case: all inputs correct
type address struct {
IP string
Netmask string
BroadcastResult string
}
addresses := []address{
{
name: "Valid Case",
ip: "192.168.1.100",
netmask: "255.255.255.0",
wantIp: "192.168.1.255",
wantError: false,
},
// Invalid IP address
{
name: "Invalid IP",
ip: "256.1.1.1", // invalid
netmask: "255.255.255.0",
wantIp: "",
wantError: true,
},
// Invalid netmask
{
name: "Invalid Netmask",
ip: "192.168.1.100",
netmask: "300.255.255.0", // invalid
wantIp: "",
wantError: true,
IP: "192.168.0.1",
Netmask: "255.255.255.0",
BroadcastResult: "192.168.0.255",
}, {
IP: "10.1.1.1",
Netmask: "255.255.0.0",
BroadcastResult: "10.1.255.255",
}, {
IP: "10.2.3.4",
Netmask: "255.0.0.0",
BroadcastResult: "10.255.255.255",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
ip := net.ParseIP(tc.ip)
if ip == nil && !tc.wantError {
t.Errorf("Unexpected error parsing IP: %v", ip)
} else if ip == nil {
return
}
mask := net.ParseIP(tc.netmask)
if mask == nil && !tc.wantError {
t.Errorf("Unexpected error parsing netmask: %v", mask)
} else if mask == nil {
return
}
broadcast, err := getBroadcastIp(tc.ip, tc.netmask)
if tc.wantError {
if err == nil {
t.Errorf("Expected error but got none")
}
} else {
if broadcast != tc.wantIp {
t.Errorf("Broadcast IP mismatch: expected %s, got %s", tc.wantIp, broadcast)
}
}
})
for _, v := range addresses {
broadcast, err := getBroadcastIp(v.IP, v.Netmask)
if err != nil {
t.Fatal(err)
}
if broadcast != v.BroadcastResult {
t.Fatalf(`getBroadcastIp("%v, %v"), want %v, got %v`, v.IP, v.Netmask, v.BroadcastResult, broadcast)
}
}
}
+19 -44
View File
@@ -1,60 +1,44 @@
package networking
import (
"errors"
"net"
"os"
"os/exec"
"runtime"
"strconv"
"syscall"
"time"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
probing "github.com/prometheus-community/pro-bing"
"github.com/seriousm4x/upsnap/logger"
)
func isNoRouteOrDownError(err error) bool {
opErr, ok := err.(*net.OpError)
if !ok {
return false
}
syscallErr, ok := opErr.Err.(*os.SyscallError)
if !ok {
return false
}
return syscallErr.Err == syscall.EHOSTUNREACH || syscallErr.Err == syscall.EHOSTDOWN
}
func PingDevice(device *core.Record) (bool, error) {
func PingDevice(device *models.Record) bool {
ping_cmd := device.GetString("ping_cmd")
if ping_cmd == "" {
pinger, err := probing.NewPinger(device.GetString("ip"))
if err != nil {
return false, err
logger.Error.Println(err)
return false
}
pinger.Count = 1
pinger.Timeout = 500 * time.Millisecond
privileged := isRoot()
privilegedEnv := os.Getenv("UPSNAP_PING_PRIVILEGED")
if privilegedEnv != "" {
privileged, err = strconv.ParseBool(privilegedEnv)
if err != nil {
privileged = false
}
privileged, err := strconv.ParseBool(os.Getenv("UPSNAP_PING_PRIVILEGED"))
if err != nil {
privileged = true
}
pinger.SetPrivileged(privileged)
err = pinger.Run()
if err != nil {
if isNoRouteOrDownError(err) {
return false, nil
}
return false, err
logger.Error.Println(err)
return false
}
stats := pinger.Statistics()
return stats.PacketLoss == 0, nil
if stats.PacketLoss > 0 {
return false
} else {
return true
}
} else {
var shell string
var shell_arg string
@@ -69,25 +53,16 @@ func PingDevice(device *core.Record) (bool, error) {
cmd := exec.Command(shell, shell_arg, ping_cmd)
err := cmd.Run()
return err == nil, err
return err == nil
}
}
func CheckPort(host string, port string) (bool, error) {
func CheckPort(host string, port string) bool {
timeout := 500 * time.Millisecond
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), timeout)
if err != nil {
// treat "host unreachable", "connection refused" and "timeout" as no error
var netErr *net.OpError
if errors.As(err, &netErr) {
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) ||
errors.Is(netErr.Err, syscall.ECONNREFUSED) ||
netErr.Timeout() {
return false, nil
}
}
return false, err
return false
}
defer conn.Close()
return conn != nil, nil
return conn != nil
}
-90
View File
@@ -1,90 +0,0 @@
package networking
import (
"testing"
"github.com/pocketbase/pocketbase/core"
)
func TestPingDevice(t *testing.T) {
testCases := []struct {
name string
ip string
ping_cmd string
wantError bool
}{
// Valid case: all inputs correct
{
name: "Valid Case",
ip: "8.8.8.8",
ping_cmd: "exit 0",
wantError: false,
},
// Invalid ping command
{
name: "Invalid Ping Command",
ip: "8.8.8.8",
ping_cmd: "exit 1",
wantError: true,
},
}
collection := &core.Collection{}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
device := core.NewRecord(collection)
device.Set("ip", tc.ip)
device.Set("ping_cmd", tc.ping_cmd)
_, err := PingDevice(device)
if err == nil && tc.wantError {
t.Errorf("Expected error but got none")
} else if err != nil && !tc.wantError {
t.Errorf("Got unexpected error: %v", err)
}
})
}
}
func TestCheckPort(t *testing.T) {
testCases := []struct {
name string
host string
port string
wantError bool
}{
// Valid case: all inputs correct
{
name: "Valid Case",
host: "0.0.0.0",
port: "443",
wantError: false,
},
// Invalid IP address
{
name: "Invalid IP",
host: "256.1.1.1", // invalid
port: "443",
wantError: true,
},
// Invalid port number
{
name: "Invalid Port",
host: "0.0.0.0",
port: "70000", // invalid
wantError: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
_, err := CheckPort(tc.host, tc.port)
if err == nil && tc.wantError {
t.Errorf("Expected error but got none")
} else if err != nil && !tc.wantError {
t.Errorf("Got unexpected error: %v", err)
}
})
}
}
-9
View File
@@ -1,9 +0,0 @@
//go:build !windows
package networking
import "os"
func isRoot() bool {
return os.Geteuid() == 0
}
-16
View File
@@ -1,16 +0,0 @@
//go:build windows
package networking
import "golang.org/x/sys/windows"
func isRoot() bool {
var sid *windows.SID
sid, err := windows.CreateWellKnownSid(windows.WinBuiltinAdministratorsSid)
if err != nil {
return false
}
token := windows.GetCurrentProcessToken()
isAdmin, err := token.IsMember(sid)
return err == nil && isAdmin
}
+6 -19
View File
@@ -6,14 +6,13 @@ import (
"fmt"
"os/exec"
"runtime"
"strings"
"time"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
"github.com/seriousm4x/upsnap/logger"
)
func ShutdownDevice(device *core.Record) error {
func ShutdownDevice(device *models.Record) error {
logger.Info.Println("Shutdown triggered for", device.GetString("name"))
shutdown_cmd := device.GetString("shutdown_cmd")
if shutdown_cmd == "" {
@@ -30,9 +29,6 @@ func ShutdownDevice(device *core.Record) error {
shell_arg = "-c"
}
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_IP }}", device.GetString("ip"))
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_MAC }}", device.GetString("mac"))
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -52,27 +48,18 @@ func ShutdownDevice(device *core.Record) error {
done <- cmd.Wait()
}()
shutdownTimeout := device.GetInt("shutdown_timeout")
if shutdownTimeout <= 0 {
shutdownTimeout = 120
}
// check state every seconds for 2 min
start := time.Now()
for {
select {
case <-time.After(1 * time.Second):
if time.Since(start) >= time.Duration(shutdownTimeout)*time.Second {
if time.Since(start) >= 2*time.Minute {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
}
return fmt.Errorf("%s not offline after %d seconds", device.GetString("name"), shutdownTimeout)
}
isOnline, err := PingDevice(device)
if err != nil {
logger.Error.Println(err)
return err
return fmt.Errorf("%s not offline after 2 minutes", device.GetString("name"))
}
isOnline := PingDevice(device)
if !isOnline {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
+1 -1
View File
@@ -18,7 +18,7 @@ func SetProcessAttributes(cmd *exec.Cmd) {
// Kills child processes on Linux. Windows doesn't provide a direct way to kill child processes, so we kill just the main process.
func KillProcess(process *os.Process) error {
logger.Warning.Println("Your command didn't finish in time. It will be killed.")
logger.Warning.Println("Your shutdown cmd didn't finish in 2 minutes. It will be killed.")
pgid, err := unix.Getpgid(process.Pid)
if err != nil {
return err
+2 -2
View File
@@ -7,7 +7,7 @@ import (
"io"
"net/http"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
"github.com/seriousm4x/upsnap/logger"
)
@@ -15,7 +15,7 @@ type SolResponse struct {
Message string `json:"message"`
}
func SleepDevice(device *core.Record) (SolResponse, error) {
func SleepDevice(device *models.Record) (SolResponse, error) {
logger.Info.Println("Sleep triggered for", device.GetString("name"))
var solResp SolResponse
+10 -26
View File
@@ -6,21 +6,15 @@ import (
"fmt"
"os/exec"
"runtime"
"strings"
"time"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/models"
"github.com/seriousm4x/upsnap/logger"
)
func WakeDevice(device *core.Record) error {
func WakeDevice(device *models.Record) error {
logger.Info.Println("Wake triggered for", device.GetString("name"))
wakeTimeout := device.GetInt("wake_timeout")
if wakeTimeout <= 0 {
wakeTimeout = 120
}
wake_cmd := device.GetString("wake_cmd")
if wake_cmd != "" {
var shell string
@@ -33,9 +27,6 @@ func WakeDevice(device *core.Record) error {
shell_arg = "-c"
}
wake_cmd = strings.ReplaceAll(wake_cmd, "{{ DEVICE_IP }}", device.GetString("ip"))
wake_cmd = strings.ReplaceAll(wake_cmd, "{{ DEVICE_MAC }}", device.GetString("mac"))
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -55,22 +46,18 @@ func WakeDevice(device *core.Record) error {
done <- cmd.Wait()
}()
// check state every seconds for 2 min
start := time.Now()
for {
select {
case <-time.After(1 * time.Second):
if time.Since(start) >= time.Duration(wakeTimeout)*time.Second {
if time.Since(start) >= 2*time.Minute {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
}
return fmt.Errorf("%s not online after %d seconds", device.GetString("name"), wakeTimeout)
}
isOnline, err := PingDevice(device)
if err != nil {
logger.Error.Println(err)
return err
return fmt.Errorf("%s not online after 2 minutes", device.GetString("name"))
}
isOnline := PingDevice(device)
if isOnline {
if err := KillProcess(cmd.Process); err != nil {
logger.Error.Println(err)
@@ -92,21 +79,18 @@ func WakeDevice(device *core.Record) error {
return err
}
// check state every seconds for 2 min
start := time.Now()
for {
time.Sleep(1 * time.Second)
isOnline, err := PingDevice(device)
if err != nil {
logger.Error.Println(err)
return err
}
isOnline := PingDevice(device)
if isOnline {
return nil
}
if time.Since(start) >= time.Duration(wakeTimeout)*time.Second {
if time.Since(start) >= 2*time.Minute {
break
}
}
return fmt.Errorf("%s not online after %d seconds", device.GetString("name"), wakeTimeout)
return fmt.Errorf(device.GetString("name"), "not online after 2 min")
}
}
+77 -325
View File
@@ -1,9 +1,7 @@
package pb
import (
"encoding/json"
"encoding/xml"
"fmt"
"net"
"net/http"
"os"
@@ -12,198 +10,111 @@ import (
"strings"
"time"
"github.com/pocketbase/dbx"
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/router"
"github.com/robfig/cron/v3"
"github.com/pocketbase/pocketbase/models"
"github.com/seriousm4x/upsnap/logger"
"github.com/seriousm4x/upsnap/networking"
)
func HandlerWake(e *core.RequestEvent) error {
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
func HandlerWake(c echo.Context) error {
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
if err != nil {
return apis.NewNotFoundError("The device does not exist.", err)
}
record.Set("status", "pending")
if err := e.App.Save(record); err != nil {
if err := App.Dao().SaveRecord(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
if err := asyncCall(e, func() *router.ApiError {
if err := networking.WakeDevice(record); err != nil {
go func(r *models.Record) {
if err := networking.WakeDevice(r); err != nil {
logger.Error.Println(err)
record.Set("status", "offline")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return apis.NewBadRequestError(err.Error(), nil)
r.Set("status", "offline")
} else {
r.Set("status", "online")
}
if err := App.Dao().SaveRecord(r); err != nil {
logger.Error.Println("Failed to save record:", err)
}
}(record)
return c.JSON(http.StatusOK, record)
}
func HandlerSleep(c echo.Context) error {
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
if err != nil {
return apis.NewNotFoundError("The device does not exist.", err)
}
record.Set("status", "pending")
if err := App.Dao().SaveRecord(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
resp, err := networking.SleepDevice(record)
if err != nil {
logger.Error.Println(err)
record.Set("status", "online")
if err := e.App.Save(record); err != nil {
if err := App.Dao().SaveRecord(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return nil
}); err != nil {
return err
return apis.NewBadRequestError(resp.Message, nil)
}
return e.JSON(http.StatusOK, record)
record.Set("status", "offline")
if err := App.Dao().SaveRecord(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return c.JSON(http.StatusOK, nil)
}
func HandlerSleep(e *core.RequestEvent) error {
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
func HandlerReboot(c echo.Context) error {
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
if err != nil {
return apis.NewNotFoundError("The device does not exist.", err)
}
record.Set("status", "pending")
if err := e.App.Save(record); err != nil {
if err := App.Dao().SaveRecord(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
if err := asyncCall(e, func() *router.ApiError {
resp, err := networking.SleepDevice(record)
if err != nil {
go func(r *models.Record) {
if err := networking.ShutdownDevice(r); err != nil {
logger.Error.Println(err)
record.Set("status", "online")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return apis.NewBadRequestError(resp.Message, nil)
}
record.Set("status", "offline")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return nil
}); err != nil {
return err
}
return e.JSON(http.StatusOK, nil)
}
func HandlerReboot(e *core.RequestEvent) error {
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
if err != nil {
return apis.NewNotFoundError("The device does not exist.", err)
}
record.Set("status", "pending")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
if err := asyncCall(e, func() *router.ApiError {
if err := networking.ShutdownDevice(record); err != nil {
logger.Error.Println(err)
record.Set("status", "online")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return apis.NewBadRequestError(err.Error(), nil)
}
// if this code is reached, the device is shutting down and not responding to pings anymore.
// this does not mean it is ready to boot again, it might still be in the process of shutting down.
// so we wait a little to make sure the device has shut down completely and is ready to receive wake requests.
time.Sleep(15 * time.Second)
if err := networking.WakeDevice(record); err != nil {
logger.Error.Println(err)
record.Set("status", "offline")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return apis.NewBadRequestError(err.Error(), nil)
}
record.Set("status", "online")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return nil
}); err != nil {
return err
}
return e.JSON(http.StatusOK, record)
}
func HandlerShutdown(e *core.RequestEvent) error {
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
if err != nil {
return apis.NewNotFoundError("The device does not exist.", err)
}
record.Set("status", "pending")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
if err := asyncCall(e, func() *router.ApiError {
if err := networking.ShutdownDevice(record); err != nil {
logger.Error.Println(err)
record.Set("status", "online")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return apis.NewBadRequestError(err.Error(), nil)
}
record.Set("status", "offline")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return nil
}); err != nil {
return err
}
return e.JSON(http.StatusOK, record)
}
func HandlerWakeGroup(e *core.RequestEvent) error {
records, err := e.App.FindRecordsByFilter("devices", "groups.id = {:grpId} && status = 'offline'", "", 0, 0,
dbx.Params{"grpId": e.Request.PathValue("id")},
)
if err != nil {
return apis.NewNotFoundError("No devices in group", err)
}
for _, record := range records {
go func() {
record.Set("status", "pending")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
if err := networking.WakeDevice(record); err != nil {
r.Set("status", "online")
} else {
time.Sleep(15 * time.Second) // some devices might not respond to ping but are still shutting down
if err := networking.WakeDevice(r); err != nil {
logger.Error.Println(err)
record.Set("status", "offline")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
return
r.Set("status", "offline")
} else {
r.Set("status", "online")
}
}
if err := App.Dao().SaveRecord(r); err != nil {
logger.Error.Println("Failed to save record:", err)
}
}(record)
return c.JSON(http.StatusOK, record)
}
record.Set("status", "online")
if err := e.App.Save(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
}()
func HandlerShutdown(c echo.Context) error {
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
if err != nil {
return apis.NewNotFoundError("The device does not exist.", err)
}
return e.JSON(http.StatusOK, records)
record.Set("status", "pending")
if err := App.Dao().SaveRecord(record); err != nil {
logger.Error.Println("Failed to save record:", err)
}
go func(r *models.Record) {
if err := networking.ShutdownDevice(r); err != nil {
logger.Error.Println(err)
r.Set("status", "online")
} else {
r.Set("status", "offline")
}
if err := App.Dao().SaveRecord(r); err != nil {
logger.Error.Println("Failed to save record:", err)
}
}(record)
return c.JSON(http.StatusOK, record)
}
type Nmaprun struct {
@@ -216,7 +127,7 @@ type Nmaprun struct {
} `xml:"host"`
}
func HandlerScan(e *core.RequestEvent) error {
func HandlerScan(c echo.Context) error {
// check if nmap installed
nmap, err := exec.LookPath("nmap")
if err != nil {
@@ -224,7 +135,7 @@ func HandlerScan(e *core.RequestEvent) error {
}
// check if scan range is valid
allPrivateSettings, err := e.App.FindAllRecords("settings_private")
allPrivateSettings, err := App.Dao().FindRecordsByExpr("settings_private")
if err != nil {
return err
}
@@ -304,164 +215,5 @@ func HandlerScan(e *core.RequestEvent) error {
res.Devices = append(res.Devices, dev)
}
return e.JSON(http.StatusOK, res)
}
func HandlerInitSuperuser(e *core.RequestEvent) error {
superusersCollection, err := e.App.FindCollectionByNameOrId(core.CollectionNameSuperusers)
if err != nil {
return e.NotFoundError("Failed to retrieve superusers collection", err)
}
totalSuperusers, err := e.App.CountRecords(superusersCollection)
if err != nil {
return e.InternalServerError("Failed to retrieve superusers count", err)
}
if totalSuperusers > 0 {
return e.BadRequestError("An initial superuser already exists", nil)
}
data := struct {
Email string `json:"email" form:"email"`
Password string `json:"password" form:"password"`
PasswordConfirm string `json:"password_confirm" form:"password-confirm"`
}{}
err = e.BindBody(&data)
if err != nil {
return e.BadRequestError("Failed to read request data", err)
}
if data.Password != data.PasswordConfirm {
return e.BadRequestError("Password don't match", err)
}
record := core.NewRecord(superusersCollection)
record.SetEmail(data.Email)
record.SetPassword(data.Password)
err = e.App.Save(record)
if err != nil {
return e.BadRequestError("Failed to create initial superuser", err)
}
return apis.RecordAuthResponse(e, record, "", nil)
}
type ValidateCronRequest struct {
Cron string `json:"cron"`
}
func HandlerValidateCron(e *core.RequestEvent) error {
var body ValidateCronRequest
if err := e.BindBody(&body); err != nil {
logger.Error.Println(err)
return e.BadRequestError("invalid request", err)
}
p := cron.NewParser(cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow)
if _, err := p.Parse(body.Cron); err != nil {
return e.BadRequestError("failed to parse cron expression", err)
}
return e.JSON(200, "valid")
}
func asyncCall(e *core.RequestEvent, fn func() *router.ApiError) *router.ApiError {
isAsync, err := strconv.ParseBool(e.Request.URL.Query().Get("async"))
if err != nil {
isAsync = false
}
if !isAsync {
return fn()
}
go func() {
_ = fn()
}()
return nil
}
func HandlerWebsiteManifest(e *core.RequestEvent) error {
scheme := "http"
if e.Request.TLS != nil || e.Request.Header.Get("X-Forwarded-Proto") == "https" {
scheme = "https"
}
baseUrl := fmt.Sprintf("%s://%s", scheme, e.Request.Host)
manifest := map[string]any{
"name": "UpSnap",
"short_name": "UpSnap",
"description": "A simple wake on lan web app written with SvelteKit, Go and PocketBase.",
"theme_color": "#55BCD9",
"background_color": "#55BCD9",
"display": "standalone",
"scope": baseUrl,
"start_url": baseUrl,
"icons": []map[string]string{
{
"src": "/icon_192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any",
},
{
"src": "/icon_512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any",
},
{
"src": "/maskable_192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable",
},
{
"src": "/maskable_512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable",
},
{
"src": "/gopher.svg",
"sizes": "any",
"type": "image/svg+xml",
},
},
}
publicSettings, err := e.App.FindFirstRecordByFilter("settings_public", "")
if err != nil {
return writeManifest(e, manifest)
}
// override title if set
if title := publicSettings.GetString("website_title"); title != "" {
manifest["name"] = title
manifest["short_name"] = title
}
// override icons if set
if favicon := publicSettings.GetString("favicon"); favicon != "" {
manifest["icons"] = []map[string]string{
{
"src": fmt.Sprintf("%s/api/files/settings_public/%s/%s", baseUrl, publicSettings.Id, favicon),
"sizes": "any",
"purpose": "any",
},
}
}
return writeManifest(e, manifest)
}
func writeManifest(e *core.RequestEvent, manifest map[string]any) error {
e.Response.Header().Set("Content-Type", "application/manifest+json")
e.Response.Header().Set("Cache-Control", "no-cache, no-store")
enc := json.NewEncoder(e.Response)
return enc.Encode(manifest)
return c.JSON(http.StatusOK, res)
}
+17 -43
View File
@@ -1,62 +1,36 @@
package pb
import (
"github.com/pocketbase/dbx"
"fmt"
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/hook"
"github.com/pocketbase/pocketbase/models"
)
func RequireScanDevicesPermission() *hook.Handler[*core.RequestEvent] {
return &hook.Handler[*core.RequestEvent]{
Func: func(e *core.RequestEvent) error {
if e.HasSuperuserAuth() {
return e.Next()
func RequireUpSnapPermission() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
admin, _ := c.Get(apis.ContextAdminKey).(*models.Admin)
if admin != nil {
return next(c)
}
user := e.Auth
user, _ := c.Get(apis.ContextAuthRecordKey).(*models.Record)
if user == nil {
return apis.NewUnauthorizedError("The request requires superuser or record authorization token to be set.", nil)
return apis.NewUnauthorizedError("The request requires admin or record authorization token to be set.", nil)
}
res, err := e.App.FindFirstRecordByFilter(
"permissions",
"user.id = {:userId} && create = true",
dbx.Params{"userId": user.Id},
)
if res == nil || err != nil {
return apis.NewForbiddenError("You are not allowed to perform this request.", nil)
}
return e.Next()
},
}
}
func RequireUpSnapPermission() *hook.Handler[*core.RequestEvent] {
return &hook.Handler[*core.RequestEvent]{
Func: func(e *core.RequestEvent) error {
if e.HasSuperuserAuth() {
return e.Next()
}
user := e.Auth
if user == nil {
return apis.NewUnauthorizedError("The request requires superuser or record authorization token to be set.", nil)
}
deviceId := e.Request.PathValue("id")
deviceId := c.PathParam("id")
// find record where user has device with power permission
res, err := e.App.FindFirstRecordByFilter("permissions", "user.id = {:userId} && power.id ?= {:deviceId}", dbx.Params{
"userId": user.Id,
"deviceId": deviceId,
})
res, err := App.Dao().FindFirstRecordByFilter("permissions",
fmt.Sprintf("user.id = '%s' && power.id ?= '%s'", user.Id, deviceId))
if res == nil || err != nil {
return apis.NewForbiddenError("You are not allowed to perform this request.", nil)
}
return e.Next()
},
return next(c)
}
}
}
+106 -113
View File
@@ -1,23 +1,24 @@
package pb
import (
"errors"
"fmt"
"io/fs"
"net/http"
"os"
"path"
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/plugins/ghupdate"
"github.com/pocketbase/pocketbase/models"
"github.com/pocketbase/pocketbase/plugins/migratecmd"
"github.com/robfig/cron/v3"
"github.com/seriousm4x/upsnap/cronjobs"
"github.com/seriousm4x/upsnap/logger"
_ "github.com/seriousm4x/upsnap/migrations"
)
var App *pocketbase.PocketBase
var Version = "(untracked)"
func StartPocketBase(distDirFS fs.FS) {
@@ -48,62 +49,95 @@ func StartPocketBase(distDirFS fs.FS) {
}
// create app
app := pocketbase.NewWithConfig(pocketbase.Config{
App = pocketbase.NewWithConfig(pocketbase.Config{
DefaultDataDir: dataDir,
})
app.RootCmd.Short = "UpSnap CLI"
app.RootCmd.Version = Version
App.RootCmd.Short = "UpSnap CLI"
App.RootCmd.Version = Version
// auto migrate db
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
migratecmd.MustRegister(App, App.RootCmd, migratecmd.Config{
Automigrate: true,
})
// GitHub selfupdate
ghupdate.MustRegister(app, app.RootCmd, ghupdate.Config{
Owner: "seriousm4x",
Repo: "UpSnap",
ArchiveExecutable: "upsnap",
})
// event hooks
app.OnServe().BindFunc(func(se *core.ServeEvent) error {
se.Router.GET("/{path...}", apis.Static(distDirFS, true))
App.OnBeforeServe().Add(func(e *core.ServeEvent) error {
e.Router.GET("/*", apis.StaticDirectoryHandler(distDirFS, true))
se.Router.GET("/api/upsnap/wake/{id}", HandlerWake).Bind(RequireUpSnapPermission())
se.Router.GET("/api/upsnap/wakegroup/{id}", HandlerWakeGroup).Bind(RequireUpSnapPermission())
se.Router.GET("/api/upsnap/sleep/{id}", HandlerSleep).Bind(RequireUpSnapPermission())
se.Router.GET("/api/upsnap/reboot/{id}", HandlerReboot).Bind(RequireUpSnapPermission())
se.Router.GET("/api/upsnap/shutdown/{id}", HandlerShutdown).Bind(RequireUpSnapPermission())
se.Router.GET("/api/upsnap/scan", HandlerScan).Bind(RequireScanDevicesPermission())
se.Router.POST("/api/upsnap/init-superuser", HandlerInitSuperuser) // https://github.com/pocketbase/pocketbase/discussions/6198
se.Router.POST("/api/upsnap/validate-cron", HandlerValidateCron)
se.Router.GET("/api/upsnap/manifest.webmanifest", HandlerWebsiteManifest)
e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/api/upsnap/wake/:id",
Handler: HandlerWake,
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(App),
RequireUpSnapPermission(),
},
})
if err := importSettings(app); err != nil {
e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/api/upsnap/sleep/:id",
Handler: HandlerSleep,
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(App),
RequireUpSnapPermission(),
},
})
e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/api/upsnap/reboot/:id",
Handler: HandlerReboot,
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(App),
RequireUpSnapPermission(),
},
})
e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/api/upsnap/shutdown/:id",
Handler: HandlerShutdown,
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(App),
RequireUpSnapPermission(),
},
})
e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/api/upsnap/scan",
Handler: HandlerScan,
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(App),
apis.RequireAdminAuth(),
},
})
if err := importSettings(); err != nil {
return err
}
if err := resetDeviceStates(app); err != nil {
if err := resetDeviceStates(); err != nil {
return err
}
cronjobs.SetPingJobs(app)
cronjobs.SetPingJobs(App)
cronjobs.StartPing()
cronjobs.SetWakeShutdownJobs(app)
cronjobs.SetWakeShutdownJobs(App)
cronjobs.StartWakeShutdown()
// restart ping cronjobs or wake/shutdown cronjobs on model update
// add event hook before starting server.
// using this outside App.OnBeforeServe() would not work
app.OnModelAfterUpdateSuccess("settings_private", "devices").BindFunc(func(e *core.ModelEvent) error {
App.OnModelAfterUpdate("settings_private", "devices").Add(func(e *core.ModelEvent) error {
if e.Model.TableName() == "settings_private" {
cronjobs.SetPingJobs(app)
cronjobs.SetPingJobs(App)
} else if e.Model.TableName() == "devices" {
// only restart wake/shutdown cronjobs if new model's cron changed
record := e.Model.(*core.Record)
newRecord := record.Fresh()
oldRecord := record.Original()
record := e.Model.(*models.Record)
newRecord := record.CleanCopy()
oldRecord := record.OriginalCopy()
newWakeCron := newRecord.GetString("wake_cron")
newWakeCmd := newRecord.GetString("wake_cmd")
@@ -125,28 +159,28 @@ func StartPocketBase(distDirFS fs.FS) {
newShutdownCron != oldShutdownCron ||
newShutdownCronEnabled != oldShutdownCronEnabled ||
newShutdownCmd != oldShutdownCmd {
cronjobs.SetWakeShutdownJobs(app)
cronjobs.SetWakeShutdownJobs(App)
}
}
return e.Next()
return nil
})
return se.Next()
return nil
})
app.OnModelAfterCreateSuccess().BindFunc(func(e *core.ModelEvent) error {
if e.Model.TableName() == "_superusers" {
if err := setSetupCompleted(e.App); err != nil {
App.OnModelAfterCreate().Add(func(e *core.ModelEvent) error {
if e.Model.TableName() == "_admins" {
if err := setSetupCompleted(); err != nil {
logger.Error.Println(err)
return err
}
return e.Next()
return nil
} else if e.Model.TableName() == "devices" {
// when a device is created, give the user all rights to the device he just created
deviceRec := e.Model.(*core.Record)
deviceRec := e.Model.(*models.Record)
userId := deviceRec.GetString("created_by")
var permissionRec *core.Record
permissionRec, err := app.FindFirstRecordByFilter("permissions",
var permissionRec *models.Record
permissionRec, err := App.Dao().FindFirstRecordByFilter("permissions",
fmt.Sprintf("user.id = '%s'", userId))
if err != nil && err.Error() != "sql: no rows in result set" {
logger.Error.Println(err)
@@ -156,81 +190,57 @@ func StartPocketBase(distDirFS fs.FS) {
permissionRec.Set("update", append(permissionRec.GetStringSlice("update"), deviceRec.Id))
permissionRec.Set("delete", append(permissionRec.GetStringSlice("delete"), deviceRec.Id))
permissionRec.Set("power", append(permissionRec.GetStringSlice("power"), deviceRec.Id))
if err := app.Save(permissionRec); err != nil {
if err := App.Dao().SaveRecord(permissionRec); err != nil {
logger.Error.Println(err)
return err
}
}
}
return e.Next()
return nil
})
app.OnModelAfterDeleteSuccess().BindFunc(func(e *core.ModelEvent) error {
if e.Model.TableName() == "_superusers" {
if err := setSetupCompleted(e.App); err != nil {
App.OnModelAfterDelete().Add(func(e *core.ModelEvent) error {
if e.Model.TableName() == "_admins" {
if err := setSetupCompleted(); err != nil {
logger.Error.Println(err)
return err
}
}
return e.Next()
return nil
})
// prevent new superuser bahavior introduced in pocketbase 0.23
app.OnRecordCreate(core.CollectionNameSuperusers).BindFunc(func(e *core.RecordEvent) error {
if e.Record.Email() == core.DefaultInstallerEmail {
return errors.New("skip default PocketBase installer")
}
return e.Next()
})
app.OnTerminate().BindFunc(func(e *core.TerminateEvent) error {
App.OnTerminate().Add(func(e *core.TerminateEvent) error {
cronjobs.StopAll()
return e.Next()
return nil
})
// check for custom http listen address in env var, else use default
httpListen := os.Getenv("UPSNAP_HTTP_LISTEN")
if httpListen != "" {
if err := app.Bootstrap(); err != nil {
logger.Error.Fatalln(err)
}
if err := apis.Serve(app, apis.ServeConfig{
HttpAddr: httpListen,
ShowStartBanner: true,
}); err != nil {
logger.Error.Fatalln(err)
}
} else {
if err := app.Start(); err != nil {
logger.Error.Fatalln(err)
}
if err := App.Start(); err != nil {
logger.Error.Fatalln(err)
}
}
func importSettings(app *pocketbase.PocketBase) error {
settingsPrivateRecords, err := app.FindAllRecords("settings_private")
func importSettings() error {
settingsPrivateRecords, err := App.Dao().FindRecordsByExpr("settings_private")
if err != nil {
return err
}
settingsPrivateCollection, err := app.FindCollectionByNameOrId("settings_private")
settingsPrivateCollection, err := App.Dao().FindCollectionByNameOrId("settings_private")
if err != nil {
return err
}
settingsPrivate := core.NewRecord(settingsPrivateCollection)
settingsPrivate := models.NewRecord(settingsPrivateCollection)
if len(settingsPrivateRecords) > 0 {
settingsPrivate = settingsPrivateRecords[0]
}
settingsPublicRecords, err := app.FindAllRecords("settings_public")
settingsPublicRecords, err := App.Dao().FindRecordsByExpr("settings_public")
if err != nil {
return err
}
settingsPublicCollection, err := app.FindCollectionByNameOrId("settings_public")
settingsPublicCollection, err := App.Dao().FindCollectionByNameOrId("settings_public")
if err != nil {
return err
}
settingsPublic := core.NewRecord(settingsPublicCollection)
settingsPublic := models.NewRecord(settingsPublicCollection)
if len(settingsPublicRecords) > 0 {
settingsPublic = settingsPublicRecords[0]
}
@@ -239,8 +249,7 @@ func importSettings(app *pocketbase.PocketBase) error {
// 1st: env var
// 2nd: database entry
// 3rd: default values
defaultInterval := "*/3 * * * * *"
interval := defaultInterval
interval := "@every 3s"
if settingsPrivate.GetString("interval") != "" {
interval = settingsPrivate.GetString("interval")
}
@@ -248,22 +257,6 @@ func importSettings(app *pocketbase.PocketBase) error {
interval = os.Getenv("UPSNAP_INTERVAL")
}
// validate interval before saving
p := cron.NewParser(cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow)
if _, err := p.Parse(interval); err != nil {
if interval == "*/3 * * * *" || interval == "@every 3s" {
settingsPrivate.Set("interval", defaultInterval)
if e := app.Save(settingsPrivate); e != nil {
logger.Error.Println(e)
}
} else {
logger.Error.Printf("'%s' ping interval is not valid.\n", interval)
logger.Error.Println("Please go to '/settings/' and change your ping interval.")
logger.Error.Println("Falling back to default interval: " + defaultInterval)
}
interval = defaultInterval
}
settingsPrivate.Set("interval", interval)
if scanRange := os.Getenv("UPSNAP_SCAN_RANGE"); scanRange != "" {
settingsPrivate.Set("scan_range", scanRange)
@@ -273,13 +266,13 @@ func importSettings(app *pocketbase.PocketBase) error {
settingsPublic.Set("website_title", websiteTitle)
}
if err := app.Save(settingsPrivate); err != nil {
if err := App.Dao().SaveRecord(settingsPrivate); err != nil {
return err
}
if err := app.Save(settingsPublic); err != nil {
if err := App.Dao().SaveRecord(settingsPublic); err != nil {
return err
}
if err := setSetupCompleted(app); err != nil {
if err := setSetupCompleted(); err != nil {
logger.Error.Println(err)
return err
}
@@ -288,26 +281,26 @@ func importSettings(app *pocketbase.PocketBase) error {
return nil
}
func resetDeviceStates(app *pocketbase.PocketBase) error {
devices, err := app.FindAllRecords("devices")
func resetDeviceStates() error {
devices, err := App.Dao().FindRecordsByExpr("devices")
if err != nil {
return err
}
for _, device := range devices {
device.Set("status", "offline")
if err := app.Save(device); err != nil {
if err := App.Dao().SaveRecord(device); err != nil {
return err
}
}
return nil
}
func setSetupCompleted(app core.App) error {
totalAdmins, err := app.CountRecords(core.CollectionNameSuperusers)
func setSetupCompleted() error {
totalAdmins, err := App.Dao().TotalAdmins()
if err != nil {
return err
}
settingsPublicRecords, err := app.FindAllRecords("settings_public")
settingsPublicRecords, err := App.Dao().FindRecordsByExpr("settings_public")
if err != nil {
return err
}
@@ -316,7 +309,7 @@ func setSetupCompleted(app core.App) error {
} else {
settingsPublicRecords[0].Set("setup_completed", false)
}
if err := app.Save(settingsPublicRecords[0]); err != nil {
if err := App.Dao().SaveRecord(settingsPublicRecords[0]); err != nil {
return err
}
return nil
+3 -3
View File
@@ -1,3 +1,4 @@
version: "3"
services:
upsnap:
container_name: upsnap
@@ -12,8 +13,7 @@ services:
# user: 1000:1000
# environment:
# - TZ=Europe/Berlin # Set container timezone for cron schedules
# - UPSNAP_HTTP_LISTEN=127.0.0.1:8090
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
# # dns is used for name resolution during network scan
@@ -26,4 +26,4 @@ services:
# test: curl -fs "http://localhost:5000/api/health" || exit 1
# interval: 10s
# # or install custom packages for shutdown
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090"
+10 -5
View File
@@ -1,7 +1,8 @@
version: "3"
services:
upsnap:
container_name: upsnap
image: ghcr.io/seriousm4x/upsnap:5 # images are also available on docker hub: seriousm4x/upsnap:5
image: ghcr.io/seriousm4x/upsnap:4
network_mode: host
restart: unless-stopped
volumes:
@@ -10,15 +11,19 @@ services:
# user: 1000:1000
# environment:
# - TZ=Europe/Berlin # Set container timezone for cron schedules
# - UPSNAP_HTTP_LISTEN=127.0.0.1:8090
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
# - UPSNAP_SCAN_TIMEOUT=500ms # Scan timeout is nmap's --host-timeout value to wait for devices (https://nmap.org/book/man-performance.html)
# - UPSNAP_PING_PRIVILEGED=true # Set to false if non-root user and no NET_RAW capability *requires host setting net.ipv4.ping_group_range="0 2147483647"
# - UPSNAP_PING_PRIVILEGED=true # Set to false if you don't have root user permissions
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
# # dns is used for name resolution during network scan
# dns:
# - 192.18.0.1
# - 192.18.0.2
# # you can change the listen ip:port inside the container like this:
# entrypoint: /bin/sh -c "./upsnap serve --http 0.0.0.0:5000"
# healthcheck:
# test: curl -fs "http://localhost:5000/api/health" || exit 1
# interval: 10s
# # or install custom packages for shutdown
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve"
# entrypoint: /bin/sh -c "apk update && apk add --no-cache <YOUR_PACKAGE> && rm -rf /var/cache/apk/* && ./upsnap serve --http 0.0.0.0:8090"
+13
View File
@@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
+30
View File
@@ -0,0 +1,30 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};
+3
View File
@@ -1 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
cd frontend && npx lint-staged
+5
View File
@@ -0,0 +1,5 @@
{
"adapter": "svelte",
"$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json",
"outputPath": "./src/lib/i18n/"
}
-41
View File
@@ -1,41 +0,0 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';
import { includeIgnoreFile } from '@eslint/compat';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, '.gitignore');
/** @type {import('eslint').Linter.Config[]} */
export default [
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
];
+36 -44
View File
@@ -3,63 +3,55 @@
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"dev": "npm-run-all --parallel vite typesafe-i18n",
"vite": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "eslint --fix --cache .",
"lint": "eslint --fix --cache --ignore-path ../.gitignore .",
"format": "prettier --write --cache --cache-strategy content --ignore-path ../.gitignore .",
"prepare": "svelte-kit sync && cd .. && husky frontend/.husky",
"machine-translate": "inlang machine translate --project project.inlang"
"prepare": "cd .. && husky frontend/.husky",
"typesafe-i18n": "typesafe-i18n"
},
"devDependencies": {
"@eslint/compat": "^1.4.1",
"@eslint/js": "^9.39.2",
"@inlang/cli": "^3.1.6",
"@inlang/paraglide-js": "2.11.0",
"@sveltejs/adapter-static": "^3.0.10",
"@sveltejs/kit": "^2.51.0",
"@sveltejs/vite-plugin-svelte": "^5.1.1",
"daisyui": "^5.5.18",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-svelte": "^3.15.0",
"globals": "^16.5.0",
"husky": "^9.1.7",
"prettier": "^3.8.1",
"prettier-plugin-svelte": "^3.4.1",
"prettier-plugin-tailwindcss": "^0.7.2",
"svelte": "^5.50.3",
"svelte-check": "^4.3.6",
"tailwindcss": "^4.1.18",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.55.0",
"vite": "^6.4.1"
"@eslint/js": "^9.8.0",
"@sveltejs/adapter-static": "^3.0.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"autoprefixer": "^10.4.19",
"daisyui": "^4.12.10",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.43.0",
"husky": "^9.1.4",
"postcss": "^8.4.40",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"prettier-plugin-tailwindcss": "^0.6.5",
"svelte": "^4.2.18",
"svelte-check": "^3.8.5",
"tailwindcss": "^3.4.7",
"tslib": "^2.6.3",
"typescript": "^5.5.4",
"typescript-eslint": "^7.18.0",
"vite": "^5.3.5"
},
"type": "module",
"lint-staged": {
"*.{js,svelte}": "eslint --fix --cache .",
"*.{js,svelte}": "eslint --fix --cache --ignore-path ../.gitignore .",
"*.{js,css,md,svelte,scss}": "prettier --write --cache --cache-strategy content --ignore-path ../.gitignore ."
},
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@tailwindcss/postcss": "^4.1.18",
"cron-parser": "^5.5.0",
"date-fns": "^4.1.0",
"pocketbase": "^0.26.8",
"postcss": "^8.5.6",
"svelte-fa": "^4.0.4",
"svelte-french-toast": "github:seriousm4x/svelte-french-toast#fix-72-build",
"theme-change": "^2.5.0"
},
"pnpm": {
"onlyBuiltDependencies": [
"@tailwindcss/oxide",
"esbuild",
"svelte-french-toast@2.0.0-alpha.0"
]
"@fortawesome/free-solid-svg-icons": "^6.6.0",
"date-fns": "^3.6.0",
"npm-run-all": "^4.1.5",
"pocketbase": "^0.21.4",
"svelte-fa": "^4.0.2",
"svelte-french-toast": "^1.2.0",
"theme-change": "^2.5.0",
"typesafe-i18n": "^5.26.2"
}
}
+2772 -1650
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};
-5
View File
@@ -1,5 +0,0 @@
export default {
plugins: {
'@tailwindcss/postcss': {}
}
};
-19
View File
@@ -1,19 +0,0 @@
# IF GIT SHOWED THAT THIS FILE CHANGED
#
# 1. RUN THE FOLLOWING COMMAND
#
# ---
# git rm --cached '**/*.inlang/.gitignore'
# ---
#
# 2. COMMIT THE CHANGE
#
# ---
# git commit -m "fix: remove tracked .gitignore from inlang project"
# ---
#
# Inlang handles the gitignore itself starting with version ^2.5.
#
# everything is ignored except settings.json
*
!settings.json
-1
View File
@@ -1 +0,0 @@
StfXY3tZWvr4FQntlM
-35
View File
@@ -1,35 +0,0 @@
{
"$schema": "https://inlang.com/schema/project-settings",
"baseLocale": "en-US",
"locales": [
"ar-SA",
"bg-BG",
"cs-CZ",
"de-DE",
"en-US",
"es-ES",
"fr-FR",
"hi-IN",
"id-ID",
"it-IT",
"ja-JP",
"ko-KR",
"nl-NL",
"nb-NO",
"pl-PL",
"pt-PT",
"ru-RU",
"uk-UA",
"vi-VN",
"zh-TW",
"zh-CN"
],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"
],
"plugin.inlang.messageFormat": {
"pathPattern": "./translations/{locale}.json"
},
"telemetry": "off"
}
+3 -5
View File
@@ -1,5 +1,3 @@
@import 'tailwindcss';
@plugin 'daisyui' {
themes: all;
}
@tailwind base;
@tailwind components;
@tailwind utilities;
+4 -5
View File
@@ -1,12 +1,12 @@
<!doctype html>
<html lang="%lang%">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
<script>
const darkTheme = 'dim';
const lightTheme = 'silk';
const darkTheme = 'dark';
const lightTheme = 'cupcake';
const preferesDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = localStorage.getItem('theme')
? localStorage.getItem('theme')
@@ -24,7 +24,6 @@
});
</script>
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
-14
View File
@@ -1,14 +0,0 @@
import { paraglideMiddleware } from '$lib/paraglide/server';
import { localeStore } from '$lib/stores/locale';
import type { Handle } from '@sveltejs/kit';
// creating a handle to use the paraglide middleware
const paraglideHandle: Handle = ({ event, resolve }) =>
paraglideMiddleware(event.request, ({ locale }) => {
localeStore.set(locale);
return resolve(event, {
transformPageChunk: ({ html }) => html.replace('%lang%', locale)
});
});
export const handle: Handle = paraglideHandle;
-6
View File
@@ -1,6 +0,0 @@
import { deLocalizeUrl } from '$lib/paraglide/runtime';
import type { Reroute } from '@sveltejs/kit';
export const reroute: Reroute = (request) => {
return deLocalizeUrl(request.url).pathname;
};
+116 -83
View File
@@ -1,11 +1,8 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { resolve } from '$app/paths';
import { nextCronDate } from '$lib/helpers/cron';
import { m } from '$lib/paraglide/messages';
import { dateFnsLocale } from '$lib/stores/locale';
import LL, { locale } from '$lib/i18n/i18n-svelte';
import { backendUrl, permission, pocketbase } from '$lib/stores/pocketbase';
import { type Device } from '$lib/types/device';
import type { Device } from '$lib/types/device';
import {
faBed,
faCircleArrowDown,
@@ -14,50 +11,103 @@
faPen,
faRotateLeft
} from '@fortawesome/free-solid-svg-icons';
import type { Locale } from 'date-fns';
import { formatDistance, parseISO } from 'date-fns';
import { de } from 'date-fns/locale/de';
import { enUS } from 'date-fns/locale/en-US';
import { es } from 'date-fns/locale/es';
import { fr } from 'date-fns/locale/fr';
import { it } from 'date-fns/locale/it';
import { pt } from 'date-fns/locale/pt';
import { zhCN } from 'date-fns/locale/zh-CN';
import { zhTW } from 'date-fns/locale/zh-TW';
import Fa from 'svelte-fa';
import toast from 'svelte-french-toast';
import { scale } from 'svelte/transition';
import DeviceCardNic from './DeviceCardNic.svelte';
let { device = $bindable() }: { device: Device } = $props();
let modalReboot: HTMLDialogElement;
let moreButtons = $derived([
export let device: Device;
let moreButtons = [
{
text: m.device_card_btn_more_sleep(),
text: $LL.device.card_btn_more_edit(),
icon: faPen,
onClick: () => goto(`/device/${device.id}`),
requires: $pocketbase.authStore.isAdmin || $permission.update?.includes(device.id)
},
{
text: $LL.device.card_btn_more_sleep(),
icon: faBed,
onClick: () => sleep(),
requires:
($pocketbase.authStore.isSuperuser || $permission.power?.includes(device.id)) &&
($pocketbase.authStore.isAdmin || $permission.power?.includes(device.id)) &&
device.status === 'online' &&
device.sol_enabled
},
{
text: m.device_card_btn_more_reboot(),
text: $LL.device.card_btn_more_reboot(),
icon: faRotateLeft,
onClick: () => askRebootConfirmation(),
onClick: () => reboot(),
requires:
($pocketbase.authStore.isSuperuser || $permission.power?.includes(device.id)) &&
($pocketbase.authStore.isAdmin || $permission.power?.includes(device.id)) &&
device.status === 'online' &&
device.shutdown_cmd !== ''
},
{
text: m.device_card_btn_more_edit(),
icon: faPen,
onClick: () => goto(resolve(`/device/${device.id}`)),
requires: $pocketbase.authStore.isSuperuser || $permission.update?.includes(device.id)
}
]);
];
// update device status change
let now = $state(Date.now());
let now = Date.now();
let interval: number;
$effect(() => {
$: {
clearInterval(interval);
interval = setInterval(() => {
now = Date.now();
}, 1000);
});
}
// dynamically import locales
// it's ugly but the only working solution i found in ~ 3 hours
var dateFnsLocale: Locale;
$: if ($locale !== undefined) {
(async () => {
switch ($locale) {
case 'de':
case 'de-DE':
dateFnsLocale = de;
break;
case 'en':
case 'en-US':
dateFnsLocale = enUS;
break;
case 'fr':
case 'fr-FR':
dateFnsLocale = fr;
break;
case 'it':
case 'it-IT':
dateFnsLocale = it;
break;
case 'es':
case 'es-ES':
dateFnsLocale = es;
break;
case 'pt':
case 'pt-PT':
dateFnsLocale = pt;
break;
case 'zh':
case 'zh-CN':
dateFnsLocale = zhCN;
break;
case 'zh-TW':
dateFnsLocale = zhTW;
break;
default:
dateFnsLocale = enUS;
break;
}
})();
}
function sleep() {
fetch(`${backendUrl}api/upsnap/sleep/${device.id}`, {
@@ -78,53 +128,40 @@
toast.error(err.message);
});
}
function askRebootConfirmation() {
if (device.shutdown_confirm) {
modalReboot.showModal();
} else {
reboot();
}
}
</script>
<div class="card bg-base-200 shadow-sm" transition:scale={{ delay: 0, duration: 200 }}>
<div class="card rounded-3xl bg-base-300 shadow-md" transition:scale={{ delay: 0, duration: 200 }}>
<div class="card-body p-6">
{#if device.link !== ''}
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
<a href={device.link} target="_blank">
{#if device.link.toString() !== ''}
<a href={device.link.toString()} target="_blank">
<h1 class="link card-title">{device.name}</h1>
</a>
{:else}
<h1 class="card-title">{device.name}</h1>
{/if}
{#if device.description}
<p class="grow-0">{device.description}</p>
{/if}
<div class="card rounded-box w-full">
<DeviceCardNic bind:device />
</div>
<ul class="menu rounded-box bg-base-200">
<!-- TODO: change to nic array once backend supports it -->
<DeviceCardNic {device} />
</ul>
{#if device.wake_cron_enabled || device.shutdown_cron_enabled || device.password}
<div class="mt-1 flex flex-row flex-wrap gap-2">
<div class="flex flex-row flex-wrap gap-2">
{#if device.wake_cron_enabled}
<div class="tooltip" data-tip={m.device_card_tooltip_wake_cron()}>
<div class="tooltip" data-tip={$LL.device.card_tooltip_wake_cron()}>
<span class="badge badge-success gap-1 p-3"
><Fa icon={faCircleArrowUp} />
{nextCronDate(device.wake_cron)}
</span>
><Fa icon={faCircleArrowUp} />{device.wake_cron}</span
>
</div>
{/if}
{#if device.shutdown_cron_enabled}
<div class="tooltip" data-tip={m.device_card_tooltip_shutdown_cron()}>
<div class="tooltip" data-tip={$LL.device.card_tooltip_shutdown_cron()}>
<span class="badge badge-error gap-1 p-3"
><Fa icon={faCircleArrowDown} />
{nextCronDate(device.shutdown_cron)}
</span>
><Fa icon={faCircleArrowDown} />{device.shutdown_cron}</span
>
</div>
{/if}
{#if device.password}
<div class="tooltip" data-tip={m.device_card_tooltip_wake_password()}>
<span class="badge gap-1 p-3"><Fa icon={faLock} />{m.device_card_password()}</span>
<div class="tooltip" data-tip={$LL.device.card_tooltip_wake_password()}>
<span class="badge gap-1 p-3"><Fa icon={faLock} />{$LL.device.card_password()}</span>
</div>
{/if}
</div>
@@ -132,42 +169,38 @@
<div class="card-actions mt-auto items-center">
<span
class="tooltip"
data-tip="{m.device_card_tooltip_last_status_change()}: {device.updated}"
data-tip="{$LL.device.card_tooltip_last_status_change()}: {device.updated}"
>
{formatDistance(parseISO(device.updated), now, {
includeSeconds: true,
addSuffix: true,
locale: $dateFnsLocale
})}
{#if dateFnsLocale !== undefined}
{formatDistance(parseISO(device.updated), now, {
includeSeconds: true,
addSuffix: true,
locale: dateFnsLocale
})}
{/if}
</span>
{#if moreButtons.filter((btn) => btn.requires).length > 0}
<div class="ms-auto flex flex-row flex-wrap gap-1">
{#each moreButtons as btn, i (i)}
{#if btn.requires}
<div class="tooltip" data-tip={btn.text}>
<button class="btn btn-sm btn-circle" onclick={btn.onClick}>
<Fa icon={btn.icon} />
</button>
</div>
{/if}
{/each}
<div class="dropdown dropdown-end dropdown-top ms-auto bg-base-300">
<label tabindex="-1" class="btn btn-sm m-1" for="more-{device.id}"
>{$LL.device.card_btn_more()}</label
>
<ul
id="more-{device.id}"
tabindex="-1"
class="menu dropdown-content z-[1] w-fit rounded-box bg-base-100 p-2 shadow"
>
{#each moreButtons as btn}
{#if btn.requires}
<li>
<button on:click={btn.onClick}>
<Fa icon={btn.icon} />{btn.text}
</button>
</li>
{/if}
{/each}
</ul>
</div>
{/if}
</div>
</div>
</div>
<dialog class="modal" bind:this={modalReboot}>
<div class="modal-box">
<h3 class="text-lg font-bold">
{m.device_modal_confirm_shutdown_title({ device: device.name })}
</h3>
<p class="py-4">{m.device_modal_confirm_shutdown_desc({ device: device.name })}</p>
<div class="modal-action">
<form method="dialog">
<button class="btn">{m.buttons_cancel()}</button>
<button class="btn btn-success" onclick={reboot}>{m.buttons_confirm()}</button>
</form>
</div>
</div>
</dialog>
+113 -159
View File
@@ -1,75 +1,59 @@
<script lang="ts">
import { m } from '$lib/paraglide/messages';
import LL from '$lib/i18n/i18n-svelte';
import { backendUrl, permission, pocketbase } from '$lib/stores/pocketbase';
import type { Device } from '$lib/types/device';
import { faPowerOff } from '@fortawesome/free-solid-svg-icons';
import { faCircle, faPowerOff } from '@fortawesome/free-solid-svg-icons';
import Fa from 'svelte-fa';
import toast from 'svelte-french-toast';
let { device = $bindable() }: { device: Device } = $props();
let hoverText = $state('');
let disabled = $state(false);
let timeout = $state(120);
let interval: number;
export let device: Device;
let hoverText = '';
let disabled = false;
let timeout = 120;
var interval: number;
let modalWake: HTMLDialogElement;
let modalShutdown: HTMLDialogElement;
let seconds = $derived(timeout % 60);
let minutes = $derived(Math.floor(timeout / 60));
$effect(() => {
if (device.status === 'pending' && !interval) {
countdown(Date.parse(device.updated), 'wake');
}
});
$effect(() => {
if (device.status === 'pending' || device.status === '') {
$: if (device.status === 'pending' && !interval) {
countdown(Date.parse(device.updated));
}
$: minutes = Math.floor(timeout / 60);
$: seconds = timeout % 60;
$: if (device.status === 'pending' || device.status === '') {
disabled = true;
hoverText = $LL.device.card_nic_tooltip_pending();
} else if (device.status === 'online') {
if (device.shutdown_cmd === '') {
disabled = true;
hoverText = m.device_card_nic_tooltip_pending();
} else if (device.status === 'online') {
if (device.shutdown_cmd === '') {
disabled = true;
hoverText = m.device_card_nic_tooltip_shutdown_no_cmd();
} else if (!$pocketbase.authStore.isSuperuser && !$permission.power?.includes(device.id)) {
disabled = true;
hoverText = m.device_card_nic_tooltip_shutdown_no_permission();
} else {
disabled = false;
hoverText = m.device_card_nic_tooltip_shutdown();
}
} else if (device.status === 'offline') {
if (!$pocketbase.authStore.isSuperuser && !$permission.power?.includes(device.id)) {
disabled = true;
hoverText = m.device_card_nic_tooltip_power_no_permission();
} else {
disabled = false;
hoverText = m.device_card_nic_tooltip_power();
}
hoverText = $LL.device.card_nic_tooltip_shutdown_no_cmd();
} else if (!$pocketbase.authStore.isAdmin && !$permission.power?.includes(device.id)) {
disabled = true;
hoverText = $LL.device.card_nic_tooltip_shutdown_no_permission();
} else {
disabled = false;
hoverText = $LL.device.card_nic_tooltip_shutdown();
}
});
} else if (device.status === 'offline') {
if (!$pocketbase.authStore.isAdmin && !$permission.power?.includes(device.id)) {
disabled = true;
hoverText = $LL.device.card_nic_tooltip_power_no_permission();
} else {
disabled = false;
hoverText = $LL.device.card_nic_tooltip_power();
}
}
// TODO: change wake and shutdown to nic based routes, not device based
function wake() {
countdown(Date.now(), 'wake');
device.status = 'pending';
fetch(`${backendUrl}api/upsnap/wake/${device.id}`, {
headers: {
Authorization: $pocketbase.authStore.token
}
})
.then((resp) => resp.json())
.then(async (data) => {
if (data.status !== 200) {
device.status = 'offline';
return;
}
device = data as Device;
if (device.status === 'online' && device.link && device.link_open !== '') {
if (device.link_open === 'new_tab') {
window.open(device.link, '_blank');
} else {
window.open(device.link, '_self');
}
}
const dev = (await data.json()) as Device;
countdown(Date.parse(dev.updated));
})
.catch((err) => {
toast.error(err.message);
@@ -77,46 +61,27 @@
}
function shutdown() {
countdown(Date.now(), 'shutdown');
device.status = 'pending';
fetch(`${backendUrl}api/upsnap/shutdown/${device.id}`, {
headers: {
Authorization: $pocketbase.authStore.token
}
})
.then((resp) => resp.json())
.then(async (data) => {
if (data.status !== 200) {
device.status = 'online';
return;
}
device = data as Device;
const dev = (await data.json()) as Device;
countdown(Date.parse(dev.updated));
})
.catch((err) => {
toast.error(err.message);
});
}
function countdown(updated: number, action: 'wake' | 'shutdown') {
timeout = action === 'wake' ? device.wake_timeout : device.shutdown_timeout;
if (timeout <= 0) {
timeout = 120;
}
const end = updated + timeout * 1000;
if (interval) {
clearInterval(interval);
interval = 0;
}
function countdown(updated: number) {
timeout = 120;
const end = updated + 2 * 60 * 1000;
interval = setInterval(() => {
timeout = Math.round((end - Date.now()) / 1000);
if (timeout <= 0 || device.status !== 'pending') {
clearInterval(interval);
interval = 0;
}
}, 1000);
@@ -124,17 +89,9 @@
function handleClick() {
if (device.status === 'offline') {
if (device.wake_confirm) {
askConfirmation('wake');
} else {
wake();
}
device.wake_confirm ? askConfirmation('wake') : wake();
} else if (device.status === 'online') {
if (device.shutdown_confirm) {
askConfirmation('shutdown');
} else {
shutdown();
}
device.shutdown_confirm ? askConfirmation('shutdown') : shutdown();
}
}
@@ -147,81 +104,72 @@
}
</script>
<div
class={`tooltip ${disabled ? 'cursor-not-allowed' : 'hover:bg-base-300 cursor-pointer'} bg-base-100 rounded-box flex items-start gap-4 p-2`}
data-tip={hoverText}
onclick={disabled ? null : handleClick}
onkeydown={disabled ? null : handleClick}
role="none"
>
{#if device.status === 'offline'}
<button class="btn btn-error btn-circle size-12"><Fa icon={faPowerOff} /></button>
{:else if device.status === 'online'}
<button
class="btn btn-success btn-circle size-12"
class:cursor-not-allowed={device.shutdown_cmd === ''}><Fa icon={faPowerOff} /></button
>
{:else if device.status === 'pending'}
<button class="btn btn-warning">
<span class="countdown font-mono">
<span style="--value:{minutes};"></span>:
<span style="--value:{seconds};"></span>
</span>
</button>
{:else}
<div class="btn btn-warning btn-circle size-12">
<span class="loading loading-ring loading-sm"></span>
</div>
{/if}
<div class="grow">
<div class="text-lg leading-4 font-bold">{device.ip}</div>
<div>{device.mac}</div>
<div class="flex flex-wrap gap-x-4">
{#if device?.expand?.ports}
{#each $state
.snapshot(device)
.expand?.ports.sort((a, b) => a.number - b.number) as port (port.id)}
<span class="flex items-center gap-1 break-all">
{#if port.status}
<div class="inline-grid *:[grid-area:1/1]">
<div class="status status-success h-3 w-3 animate-ping"></div>
<div class="status status-success h-3 w-3"></div>
</div>
{:else}
<div class="inline-grid *:[grid-area:1/1]">
<div class="status status-error h-3 w-3 animate-ping"></div>
<div class="status status-error h-3 w-3"></div>
</div>
{/if}
{#if port.link}
<!-- eslint-disable svelte/no-navigation-without-resolve -->
<a
href={port.link}
target="_blank"
class="underline"
onclick={(e) => e.stopPropagation()}>{port.name} ({port.number})</a
>
<!-- eslint-enable svelte/no-navigation-without-resolve -->
{:else}
{port.name} ({port.number})
{/if}
</span>
{/each}
{/if}
<li class="tooltip" class:disabled data-tip={hoverText}>
<div
class="flex items-start gap-4 p-2"
on:click={disabled ? null : handleClick}
on:keydown={disabled ? null : handleClick}
role="none"
>
{#if device.status === 'offline'}
<button class="btn btn-error flex-shrink"><Fa icon={faPowerOff} /></button>
{:else if device.status === 'online'}
<button
class="btn btn-success flex-shrink"
class:cursor-not-allowed={device.shutdown_cmd === ''}><Fa icon={faPowerOff} /></button
>
{:else if device.status === 'pending'}
<button class="btn btn-warning flex-shrink">
<span class="countdown font-mono">
<span style="--value:{minutes};" />:
<span style="--value:{seconds};" />
</span>
</button>
{:else}
<button class="btn btn-warning flex-shrink">
<span class="loading loading-ring loading-sm" />
</button>
{/if}
<div class="grow">
<div class="text-lg font-bold leading-4">{device.ip}</div>
<div>{device.mac}</div>
<div class="flex flex-wrap gap-x-4">
{#if device?.expand?.ports}
{#each device?.expand?.ports.sort((a, b) => a.number - b.number) as port}
<span class="flex items-center gap-1 break-all">
{#if port.status}
<Fa icon={faCircle} class="text-success" />
{:else}
<Fa icon={faCircle} class="text-error" />
{/if}
{#if port.link}
<a
href={port.link}
target="_blank"
class="underline"
on:click={(e) => e.stopPropagation()}>{port.name} ({port.number})</a
>
{:else}
{port.name} ({port.number})
{/if}
</span>
{/each}
{/if}
</div>
</div>
</div>
</div>
</li>
<dialog class="modal" bind:this={modalWake}>
<div class="modal-box">
<h3 class="text-lg font-bold">
{m.device_modal_confirm_wake_title({ device: device.name })}
{$LL.device.modal_confirm_wake_title({ device: device.name })}
</h3>
<p class="py-4">{m.device_modal_confirm_wake_desc({ device: device.name })}</p>
<p class="py-4">{$LL.device.modal_confirm_wake_desc({ device: device.name })}</p>
<div class="modal-action">
<form method="dialog">
<button class="btn">{m.buttons_cancel()}</button>
<button class="btn btn-success" onclick={wake}>{m.buttons_confirm()}</button>
<form method="dialog" class="flex flex-row flex-wrap gap-2">
<button class="btn btn-neutral">{$LL.buttons.cancel()}</button>
<button class="btn btn-success" on:click={wake}>{$LL.buttons.confirm()}</button>
</form>
</div>
</div>
@@ -230,14 +178,20 @@
<dialog class="modal" bind:this={modalShutdown}>
<div class="modal-box">
<h3 class="text-lg font-bold">
{m.device_modal_confirm_shutdown_title({ device: device.name })}
{$LL.device.modal_confirm_shutdown_title({ device: device.name })}
</h3>
<p class="py-4">{m.device_modal_confirm_shutdown_desc({ device: device.name })}</p>
<p class="py-4">{$LL.device.modal_confirm_shutdown_desc({ device: device.name })}</p>
<div class="modal-action">
<form method="dialog">
<button class="btn">{m.buttons_cancel()}</button>
<button class="btn btn-success" onclick={shutdown}>{m.buttons_confirm()}</button>
<form method="dialog" class="flex flex-row flex-wrap gap-2">
<button class="btn btn-neutral">{$LL.buttons.cancel()}</button>
<button class="btn btn-success" on:click={shutdown}>{$LL.buttons.confirm()}</button>
</form>
</div>
</div>
</dialog>
<style>
:global(.menu li.disabled) {
color: inherit;
}
</style>
+362 -449
View File
@@ -1,9 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { resolve } from '$app/paths';
import DeviceFormPort from '$lib/components/DeviceFormPort.svelte';
import { nextCronDate, parseCron as validateCron } from '$lib/helpers/cron';
import { m } from '$lib/paraglide/messages';
import LL from '$lib/i18n/i18n-svelte';
import { permission, pocketbase } from '$lib/stores/pocketbase';
import type { Device, Group, Port } from '$lib/types/device';
import { faSave, faTrash, faX } from '@fortawesome/free-solid-svg-icons';
@@ -22,16 +20,6 @@
});
async function save() {
// validate crons
if (device.wake_cron_enabled && !(await validateCron(device.wake_cron))) {
toast.error(m.settings_invalid_cron());
throw new Error('wake_cron not valid');
}
if (device.shutdown_cron_enabled && !(await validateCron(device.shutdown_cron))) {
toast.error(m.settings_invalid_cron());
throw new Error('shutdown_cron not valid');
}
// create/update all ports
let portIds: string[] = [];
await Promise.all(
@@ -50,17 +38,8 @@
device.ip = device.ip.replaceAll(' ', '');
device.mac = device.mac.replaceAll(' ', '');
device.netmask = device.netmask.replaceAll(' ', '');
device.wake_cmd = device.wake_cmd.trim();
device.shutdown_cmd = device.shutdown_cmd.trim();
device.wake_cron = device.wake_cron.trim();
device.shutdown_cron = device.shutdown_cron.trim();
device.ping_cmd = device.ping_cmd.trim();
device.ports = portIds;
if (device.id) {
updateDevice(device);
} else {
createDevice(device);
}
device.id ? updateDevice(device) : createDevice(device);
}
async function updateDevice(device: Device) {
@@ -68,8 +47,8 @@
.collection('devices')
.update(device.id, device)
.then(() => {
toast.success(m.toasts_device_updated({ device: device.name }));
goto(resolve('/'));
toast.success($LL.toasts.device_updated({ device: device.name }));
goto('/');
})
.catch((err) => {
toast.error(err.message);
@@ -77,15 +56,15 @@
}
async function createDevice(device: Device) {
device.created_by = $pocketbase.authStore.isSuperuser
device.created_by = $pocketbase.authStore.isAdmin
? ''
: ($pocketbase.authStore.record?.id ?? '');
: ($pocketbase.authStore.model?.id ?? '');
$pocketbase
.collection('devices')
.create(device)
.then(() => {
toast.success(m.toasts_device_created({ device: device.name }));
goto(resolve('/'));
toast.success($LL.toasts.device_created({ device: device.name }));
goto('/');
})
.catch((err) => {
toast.error(err.message);
@@ -127,8 +106,8 @@
.collection('devices')
.delete(device.id)
.then(() => {
toast.success(m.toasts_device_deleted({ device: device.name }));
goto(resolve('/'));
toast.success($LL.toasts.device_deleted({ device: device.name }));
goto('/');
})
.catch((err) => {
toast.error(err.message);
@@ -158,8 +137,7 @@
})
.then((res) => {
deviceGroups = [...deviceGroups, res as Group];
toast.success(m.toasts_group_created({ group: newGroup }));
newGroup = '';
toast.success($LL.toasts.group_created({ group: newGroup }));
})
.catch((err) => {
toast.error(err.message);
@@ -177,7 +155,7 @@
.delete(group.id)
.then(async () => {
await getGroups();
toast.success(m.toasts_group_deleted({ group: group.name }));
toast.success($LL.toasts.group_deleted({ group: group.name }));
})
.catch((err) => {
toast.error(err.message);
@@ -195,495 +173,436 @@
}
</script>
<form
onsubmit={(e) => {
e.preventDefault();
save();
}}
class="flex w-full flex-col"
>
<div class="card bg-base-200 w-full shadow-sm">
<form on:submit|preventDefault={save}>
<div class="card w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{m.device_general()}</h2>
<h2 class="card-title">{$LL.device.general()}</h2>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4">
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_general_name()} <span class="text-error">*</span></span>
<input
type="text"
placeholder={m.device_general_name()}
class="input"
bind:value={device.name}
required
/>
<div class="form-control w-full max-w-xs">
<label class="label" for="device-name">
<div class="label-text">
<span>{$LL.device.general_name()}</span>
<span class="text-error">*</span>
</div>
</label>
</fieldset>
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_general_ip()} <span class="text-error">*</span></span>
<input
type="text"
placeholder={m.device_general_ip()}
class="input"
bind:value={device.ip}
required
/>
<input
id="device-name"
type="text"
placeholder={$LL.device.general_name_placeholder()}
class="input w-full max-w-xs"
bind:value={device.name}
required
/>
</div>
<div class="form-control w-full max-w-xs">
<label class="label" for="device-ip">
<div class="label-text">
<span>{$LL.device.general_ip()}</span>
<span class="text-error">*</span>
</div>
</label>
</fieldset>
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_general_mac()} <span class="text-error">*</span></span>
<input
type="text"
placeholder={m.device_general_mac()}
class="input"
bind:value={device.mac}
required
/>
<input
id="device-ip"
type="text"
placeholder="192.168.0.5"
class="input w-full max-w-xs"
bind:value={device.ip}
required
/>
</div>
<div class="form-control w-full max-w-xs">
<label class="label" for="device-mac">
<div class="label-text">
<span>{$LL.device.general_mac()}</span>
<span class="text-error">*</span>
</div>
</label>
</fieldset>
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_general_netmask()} <span class="text-error">*</span></span>
<input
type="text"
placeholder={m.device_general_netmask()}
class="input"
bind:value={device.netmask}
required
/>
<input
id="device-mac"
type="text"
placeholder="aa:bb:cc:dd:ee:ff"
class="input w-full max-w-xs"
bind:value={device.mac}
required
/>
</div>
<div class="form-control w-full max-w-xs">
<label class="label" for="device-netmask">
<div class="label-text">
<span>{$LL.device.general_netmask()}</span>
<span class="text-error">*</span>
</div>
</label>
</fieldset>
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_general_description()}</span>
<input
type="text"
placeholder={m.device_general_description()}
class="input"
bind:value={device.description}
/>
</label>
</fieldset>
<span class="badge text-error self-center">* {m.device_general_required_field()}</span>
<input
id="device-netmask"
type="text"
placeholder="255.255.255.0"
class="input w-full max-w-xs"
bind:value={device.netmask}
required
/>
</div>
<span class="badge self-center text-error">* {$LL.device.general_required_field()}</span>
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{m.device_ports()}</h2>
<p>{m.device_ports_desc()}</p>
<div class="w-full">
<h2 class="card-title">{$LL.device.ports()}</h2>
<p class="my-2">{$LL.device.ports_desc()}</p>
<div class="form-control w-full">
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
<!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
{#each device.expand.ports as _, index (index)}
{#each device.expand.ports as _, index}
<DeviceFormPort bind:device {index} />
{/each}
</div>
<button
class="btn max-w-xs {device.expand.ports.length > 0 ? 'mt-4' : ''}"
onclick={() => createEmptyPort()}
type="button">{m.device_ports_add_new()}</button
class="btn btn-primary mt-4 max-w-xs"
on:click={() => createEmptyPort()}
type="button">{$LL.device.ports_add_new()}</button
>
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{m.device_link()}</h2>
<p>
{m.device_link_desc()}
<h2 class="card-title">{$LL.device.link()}</h2>
<p class="my-2">
{$LL.device.link_desc()}
</p>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_link()}</span>
<input
type="url"
placeholder={m.device_link()}
class="input"
bind:value={device.link}
/>
</label>
</fieldset>
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_link_open()}</span>
<select class="select" bind:value={device.link_open}>
<option value="">{m.device_link_open_no()}</option>
<option value="same_tab">{m.device_link_open_same_tab()}</option>
<option value="new_tab">{m.device_link_open_new_tab()}</option>
</select>
</label>
</fieldset>
<div class="form-control w-full">
<input
type="url"
placeholder="https:// ..."
class="input w-full max-w-xs"
bind:value={device.link}
/>
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{m.device_ping()}</h2>
<p>
<h2 class="card-title">{$LL.device.ping()}</h2>
<p class="my-2">
<!-- eslint-disable svelte/no-at-html-tags -->
{@html m.device_ping_desc()}
{@html $LL.device.ping_desc()}
</p>
<fieldset class="fieldset">
<label class="input mt-2 w-full">
<span>$:</span>
<input
type="text"
placeholder={m.device_ping_cmd()}
class="grow"
bind:value={device.ping_cmd}
/>
<div class="form-control w-full">
<label class="label cursor-pointer" for="ping-cmd">
<span class="label-text">{$LL.device.ping_cmd()}</span>
</label>
</fieldset>
<input
id="ping-cmd"
type="text"
placeholder="$:"
class="input mb-2 w-full max-w-xs"
bind:value={device.ping_cmd}
/>
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{m.device_wake()}</h2>
<p>
{m.device_wake_desc()}
<h2 class="card-title">{$LL.device.wake()}</h2>
<p class="my-2">
{$LL.device.wake_desc()}
<!-- eslint-disable svelte/no-at-html-tags -->
{@html m.settings_ping_interval_desc2()}
{@html $LL.settings.ping_interval_desc2()}
</p>
<div class="flex flex-row flex-wrap gap-4">
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_wake_timeout()}</span>
<input
type="number"
min="0"
placeholder={m.device_wake_timeout()}
class="input"
bind:value={device.wake_timeout}
/>
</label>
</fieldset>
<fieldset class="fieldset grow">
<label class="input mt-2 w-full">
<span>$:</span>
<input
type="text"
placeholder={m.device_wake_cmd()}
class="grow"
bind:value={device.wake_cmd}
/>
</label>
</fieldset>
<div class="form-control w-full">
<label class="label cursor-pointer" for="wake-cmd">
<span class="label-text">{$LL.device.wake_cmd()}</span>
</label>
<input
id="wake-cmd"
type="text"
placeholder="$:"
class="input mb-2 w-full max-w-xs"
bind:value={device.wake_cmd}
/>
</div>
<div class="flex flex-row flex-wrap gap-4">
<fieldset
class="fieldset bg-base-100 border-base-300 rounded-box w-fit min-w-64 border p-4"
>
<legend class="fieldset-legend">{m.device_wake_cron_enable()}</legend>
<label class="fieldset-label">
<input
type="checkbox"
bind:checked={device.wake_cron_enabled}
class="toggle toggle-success"
/>
{m.device_wake_cron_enable()}
<div class="form-control flex flex-row flex-wrap gap-4">
<div class="flex flex-row items-center gap-2">
<input
id="wake-confirm"
type="checkbox"
class="toggle toggle-success"
bind:checked={device.wake_confirm}
/>
<label class="label cursor-pointer" for="wake-confirm">
<span class="label-text">{$LL.device.require_confirmation()}</span>
</label>
<label class="floating-label mt-2">
<span
>{m.device_wake_cron()}
</div>
</div>
<div class="form-control flex flex-row flex-wrap gap-4">
<div class="w-full max-w-xs">
<label class="label" for="wake-cron">
<span class="label-text"
>{$LL.device.wake_cron()}
{#if device.wake_cron_enabled}
<span class="text-error">*</span>
{/if}
</span>
<input
type="text"
placeholder={m.device_wake_cron()}
class="input"
bind:value={device.wake_cron}
disabled={!device.wake_cron_enabled}
required={device.wake_cron_enabled}
/>
{#if device.wake_cron_enabled}
<p class="fieldset-label">
{#await validateCron(device.wake_cron)}
<span class="loading loading-spinner loading-xs"></span>
{:then valid}
{valid ? '✅ ' + nextCronDate(device.wake_cron) : m.settings_invalid_cron()}
{/await}
</p>
{/if}
</label>
{#if device.wake_cron_enabled}
<pre class="bg-base-100 text-base-content/80 w-fit rounded p-2"><code
>* * * * * *
| | | | | |
| | | | | day of the week (0–6)
| | | | month (1–12)
| | | day of the month (1–31)
| | hour (0–23)
| minute (0–59)
second (0–59, optional)
</code></pre>
{/if}
</fieldset>
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
<legend class="fieldset-legend">{m.device_require_confirmation()}</legend>
<label class="fieldset-label">
<input
type="checkbox"
bind:checked={device.wake_confirm}
class="toggle toggle-success"
/>
{m.device_require_confirmation()}
<input
id="wake-cron"
type="text"
placeholder="M H DoM M DoW"
class="input w-full max-w-xs"
bind:value={device.wake_cron}
disabled={!device.wake_cron_enabled}
required={device.wake_cron_enabled}
/>
</div>
<div class="flex flex-col">
<label class="label cursor-pointer" for="wake-cron-enable">
<span class="label-text">{$LL.device.wake_cron_enable()}</span>
</label>
</fieldset>
<input
id="wake-cron-enable"
type="checkbox"
class="toggle toggle-success"
bind:checked={device.wake_cron_enabled}
/>
</div>
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card-body">
<h2 class="card-title">{m.device_shutdown()}</h2>
<p>
<!-- eslint-disable svelte/no-at-html-tags -->
{@html m.device_shutdown_desc()}
</p>
<div class="flex flex-row flex-wrap gap-4">
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_shutdown_timeout()}</span>
<input
type="number"
min="0"
placeholder={m.device_shutdown_timeout()}
class="input"
bind:value={device.shutdown_timeout}
/>
</label>
</fieldset>
<fieldset class="fieldset grow">
<label class="input mt-2 w-full">
<span>$:</span>
<input
type="text"
placeholder={m.device_shutdown_cmd()}
class="grow"
bind:value={device.shutdown_cmd}
/>
</label>
</fieldset>
</div>
<p class="font-bold">{m.device_shutdown_examples()}</p>
<div class="mockup-code max-w-fit min-w-0 text-sm">
<pre data-prefix="#" class="italic"><code>{m.device_shutdown_examples_windows()}</code
></pre>
<pre data-prefix="$" class="text-warning"><code
>net rpc shutdown -I 192.168.1.13 -U "user%password"</code
></pre>
</div>
<div class="mockup-code max-w-fit min-w-0 text-sm">
<pre data-prefix="#" class="italic"><code>{m.device_shutdown_examples_linux()}</code></pre>
<pre data-prefix="$" class="text-warning"><code
>sshpass -p password ssh -o "StrictHostKeyChecking=no" user@192.168.1.13 "sudo poweroff"</code
></pre>
</div>
<p>
{m.device_shutdown_cron_desc()}
</p>
<div class="flex flex-row flex-wrap gap-4">
<fieldset
class="fieldset bg-base-100 border-base-300 rounded-box w-fit min-w-64 border p-4"
>
<legend class="fieldset-legend">{m.device_shutdown_cron_enable()}</legend>
<label class="fieldset-label">
<input
type="checkbox"
bind:checked={device.shutdown_cron_enabled}
class="toggle toggle-success"
/>
{m.device_shutdown_cron_enable()}
</label>
<label class="floating-label mt-2">
<span
>{m.device_shutdown_cron()}
{#if device.shutdown_cron_enabled}
<span class="text-error">*</span>
{/if}
</span>
<input
type="text"
placeholder={m.device_shutdown_cron()}
class="input validator"
bind:value={device.shutdown_cron}
disabled={!device.shutdown_cron_enabled}
required={device.shutdown_cron_enabled}
/>
{#if device.shutdown_cron_enabled}
<p class="fieldset-label">
{#await validateCron(device.shutdown_cron)}
<span class="loading loading-spinner loading-xs"></span>
{:then valid}
{valid ? '✅ ' + nextCronDate(device.shutdown_cron) : m.settings_invalid_cron()}
{/await}
</p>
{/if}
</label>
{#if device.shutdown_cron_enabled}
<pre class="bg-base-100 text-base-content/80 w-fit rounded p-2"><code
>* * * * * *
| | | | | |
| | | | | day of the week (0–6)
| | | | month (1–12)
| | | day of the month (1–31)
| | hour (0–23)
| minute (0–59)
second (0–59, optional)
</code></pre>
{/if}
</fieldset>
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
<legend class="fieldset-legend">{m.device_require_confirmation()}</legend>
<label class="fieldset-label">
<input
type="checkbox"
bind:checked={device.shutdown_confirm}
class="toggle toggle-success"
/>
{m.device_require_confirmation()}
</label>
</fieldset>
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">Sleep-On-LAN</h2>
<p>
<p class="mt-2">
<!-- eslint-disable svelte/no-at-html-tags -->
{@html m.device_sol_desc1()}
{@html $LL.device.sol_desc1()}
</p>
<p>
{m.device_sol_desc2()}
{$LL.device.sol_desc2()}
</p>
<p class="font-bold">
<!-- eslint-disable svelte/no-at-html-tags -->
{@html m.device_sol_desc3()}
{@html $LL.device.sol_desc3()}
</p>
<div class="flex flex-row flex-wrap gap-4">
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
<legend class="fieldset-legend">{m.device_sol_enable()}</legend>
<label class="fieldset-label">
<div class="mt-4 flex flex-row flex-wrap items-end gap-4">
<div>
<div class="form-control flex flex-row flex-wrap gap-4">
<div class="flex flex-row items-center gap-2">
<input
id="sol-enable"
type="checkbox"
class="toggle toggle-success"
bind:checked={device.sol_enabled}
/>
<label class="label cursor-pointer" for="sol-enable">
<span class="label-text">{$LL.device.sol_enable()}</span>
</label>
</div>
</div>
<div class="form-control flex flex-col">
<label class="label" for="sol-port">
<span class="label-text"
>{$LL.device.sol_port()}
{#if device.sol_enabled}
<span class="text-error">*</span>
{/if}
</span>
</label>
<input
type="checkbox"
bind:checked={device.sol_enabled}
class="toggle toggle-success"
/>
{m.device_sol_enable()}
</label>
<label class="floating-label mt-2">
<span
>{m.device_sol_port()}
{#if device.sol_enabled}
<span class="text-error">*</span>
{/if}
</span>
<input
class="input"
id="sol-port"
type="number"
min="1"
max="65535"
placeholder={m.device_sol_port()}
class="input"
bind:value={device.sol_port}
disabled={!device.sol_enabled}
required={device.sol_enabled}
/>
</label>
</fieldset>
</div>
</div>
{#if device.sol_enabled}
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
<legend class="fieldset-legend">{m.device_sol_authorization()}</legend>
<label class="fieldset-label">
<input type="checkbox" bind:checked={device.sol_auth} class="toggle toggle-success" />
{m.device_sol_authorization()}
</label>
<label class="floating-label mt-2">
<span
>{m.device_sol_user()}
{#if device.sol_auth}
<span class="text-error">*</span>
{/if}
</span>
<div>
<div class="form-control flex flex-row flex-wrap gap-4">
<div class="flex flex-row items-center gap-2">
<input
id="sol-auth"
type="checkbox"
class="toggle toggle-success"
bind:checked={device.sol_auth}
/>
<label class="label cursor-pointer" for="sol-auth">
<span class="label-text">{$LL.device.sol_authorization()}</span>
</label>
</div>
</div>
<div class="form-control flex flex-col">
<label class="label" for="sol-user">
<span class="label-text"
>{$LL.device.sol_user()}
{#if device.sol_auth}
<span class="text-error">*</span>
{/if}
</span>
</label>
<input
id="sol-user"
type="text"
placeholder={m.device_sol_user()}
placeholder={$LL.device.sol_user()}
class="input"
bind:value={device.sol_user}
disabled={!device.sol_auth}
required={device.sol_auth}
/>
</label>
<label class="floating-label mt-2">
<span
>{m.device_sol_password()}
</div>
</div>
<div class="form-control flex flex-col">
<label class="label" for="sol-password">
<span class="label-text"
>{$LL.device.sol_password()}
{#if device.sol_auth}
<span class="text-error">*</span>
{/if}
</span>
<input
type="password"
placeholder={m.device_sol_password()}
class="input"
bind:value={device.sol_password}
disabled={!device.sol_auth}
required={device.sol_auth}
/>
</label>
</fieldset>
<input
id="sol-password"
type="password"
placeholder={$LL.device.sol_password()}
class="input"
bind:value={device.sol_password}
disabled={!device.sol_auth}
required={device.sol_auth}
/>
</div>
{/if}
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{m.device_password()}</h2>
<p>
<h2 class="card-title">{$LL.device.shutdown()}</h2>
<p class="my-2">
<!-- eslint-disable svelte/no-at-html-tags -->
{@html m.device_password_desc()}
{@html $LL.device.shutdown_desc()}
</p>
<fieldset class="fieldset">
<label class="floating-label mt-2">
<span>{m.device_password()}</span>
<input
type="text"
placeholder={m.device_password()}
class="input"
maxlength="6"
bind:value={device.password}
/>
<p class="my-2 font-bold">{$LL.device.shutdown_examples()}</p>
<div class="mockup-code min-w-0 max-w-fit text-sm">
<pre data-prefix="#"><code>{$LL.device.shutdown_examples_windows()}</code></pre>
<pre data-prefix="$" class="text-warning"><code
>net rpc shutdown -I 192.168.1.13 -U "user%password"</code
></pre>
</div>
<div class="mockup-code min-w-0 max-w-fit text-sm">
<pre data-prefix="#"><code>{$LL.device.shutdown_examples_linux()}</code></pre>
<pre data-prefix="$" class="text-warning"><code
>sshpass -p password ssh -o "StrictHostKeyChecking=no" user@192.168.1.13 "sudo poweroff"</code
></pre>
</div>
<div class="form-control w-full">
<label class="label cursor-pointer" for="shutdown-cmd">
<span class="label-text">{$LL.device.shutdown_cmd()}</span>
</label>
</fieldset>
<input
id="shutdown-cmd"
type="text"
placeholder="$:"
class="input mb-2 w-full max-w-xs"
bind:value={device.shutdown_cmd}
/>
</div>
<div class="form-control flex flex-row flex-wrap gap-4">
<div class="flex flex-row items-center gap-2">
<input
id="shutdown-confirm"
type="checkbox"
class="toggle toggle-success"
bind:checked={device.shutdown_confirm}
/>
<label class="label cursor-pointer" for="shutdown-confirm">
<span class="label-text">{$LL.device.require_confirmation()}</span>
</label>
</div>
</div>
<p class="my-2">
{$LL.device.shutdown_cron_desc()}
</p>
<div class="form-control flex flex-row flex-wrap gap-4">
<div class="w-full max-w-xs">
<label class="label" for="shutdown-cron">
<span class="label-text"
>{$LL.device.shutdown_cron()}
{#if device.shutdown_cron_enabled}
<span class="text-error">*</span>
{/if}
</span>
</label>
<input
id="shutdown-cron"
type="text"
placeholder="M H DoM M DoW"
class="input w-full max-w-xs"
bind:value={device.shutdown_cron}
disabled={!device.shutdown_cron_enabled}
required={device.shutdown_cron_enabled}
/>
</div>
<div class="flex flex-col">
<label class="label cursor-pointer" for="shutdown-cron-enable">
<span class="label-text">{$LL.device.shutdown_cron_enable()}</span>
</label>
<input
id="shutdown-cron-enable"
type="checkbox"
class="toggle toggle-success"
bind:checked={device.shutdown_cron_enabled}
/>
</div>
</div>
</div>
</div>
<div class="card bg-base-200 mt-6 w-full shadow-sm">
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{m.device_groups()}</h2>
<p>
{m.device_groups_desc()}
<h2 class="card-title">{$LL.device.password()}</h2>
<p class="my-2">
<!-- eslint-disable svelte/no-at-html-tags -->
{@html $LL.device.password_desc()}
</p>
<div class="form-control w-full">
<input
type="password"
placeholder="123456"
class="input w-full max-w-xs"
maxlength="6"
bind:value={device.password}
/>
</div>
</div>
</div>
<div class="card mt-6 w-full bg-base-300 shadow-xl">
<div class="card-body">
<h2 class="card-title">{$LL.device.groups()}</h2>
<p class="my-2">
{$LL.device.groups_desc()}
</p>
<div class="flex flex-row flex-wrap gap-2">
{#each deviceGroups as group (group.id)}
{#each deviceGroups as group}
<div class="join">
<div class=" tooltip" data-tip="Delete">
<button
class="btn btn-error join-item"
type="button"
onclick={() => deleteGroup(group)}><Fa icon={faX} /></button
on:click={() => deleteGroup(group)}><Fa icon={faX} /></button
>
</div>
<div
class="btn join-item bg-base-100 hover:bg-base-200"
onclick={() => toggleGroup(group.id)}
on:click={() => toggleGroup(group.id)}
role="none"
>
<input
type="checkbox"
class="checkbox"
class="checkbox checked:checkbox-primary"
checked={device.groups.indexOf(group.id) !== -1}
/>
{group.name}
@@ -691,43 +610,37 @@ second (0–59, optional)
</div>
{/each}
</div>
<div class="join">
<div class="join max-w-xs">
<input
class="input join-item"
placeholder={m.device_groups_placeholder()}
class="input join-item input-bordered w-full"
placeholder={$LL.device.groups_placeholder()}
type="text"
onkeydown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();
addGroup();
}
}}
bind:value={newGroup}
/>
<button class="btn btn-neutral join-item" type="button" onclick={() => addGroup()}
>{m.buttons_add()}</button
<button class="btn btn-primary join-item" type="button" on:click={() => addGroup()}
>{$LL.buttons.add()}</button
>
</div>
</div>
</div>
<div class="card-actions mt-6 justify-end gap-4">
{#if $pocketbase.authStore.isSuperuser || $permission.delete?.includes(device.id)}
<button class="btn btn-error" type="button" onclick={() => deleteModal.showModal()}
><Fa icon={faTrash} />{m.buttons_delete()}</button
{#if $pocketbase.authStore.isAdmin || $permission.delete?.includes(device.id)}
<button class="btn btn-error" type="button" on:click={() => deleteModal.showModal()}
><Fa icon={faTrash} />{$LL.buttons.delete()}</button
>
<dialog class="modal" bind:this={deleteModal}>
<form method="dialog" class="modal-box">
<h3 class="text-lg font-bold">{$LL.users.confirm_delete_title()}</h3>
<p class="py-4">{$LL.users.confirm_delete_desc({ username: device.name })}</p>
<div class="modal-action">
<button class="btn">{$LL.buttons.cancel()}</button>
<button class="btn btn-error" on:click={() => deleteDevice()}
>{$LL.buttons.delete()}</button
>
</div>
</form>
</dialog>
{/if}
<button class="btn btn-success" type="submit"><Fa icon={faSave} />{m.buttons_save()}</button>
<button class="btn btn-success" type="submit"><Fa icon={faSave} />{$LL.buttons.save()}</button>
</div>
</form>
<dialog class="modal" bind:this={deleteModal}>
<div class="modal-box">
<h3 class="text-lg font-bold">{m.users_confirm_delete_title()}</h3>
<p class="py-4">{m.users_confirm_delete_desc({ username: device.name })}</p>
<div class="modal-action">
<form method="dialog">
<button class="btn">{m.buttons_cancel()}</button>
<button class="btn btn-error" onclick={() => deleteDevice()}>{m.buttons_delete()}</button>
</form>
</div>
</div>
</dialog>

Some files were not shown because too many files have changed in this diff Show More