mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-11-27 12:21:56 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66ce01cb40 | |||
| 5435d914b3 | |||
| fc4e34da61 | |||
| 730873a347 | |||
| 9f05b1c134 | |||
| 2c244beaaa | |||
| c5d33fdae8 | |||
| b17b09109f | |||
| 0a798d6e94 | |||
| aee5c8c3c7 | |||
| 7045f74d77 | |||
| b3c4b376a0 | |||
| 7bbe114407 | |||
| 710329e8ab | |||
| df7a577db2 | |||
| d8eafbc123 | |||
| 11bdb8ad36 | |||
| 9057fa710b | |||
| b5fd864320 | |||
| 297518f008 | |||
| e3c7342932 | |||
| 89977debc5 | |||
| 391b218fe5 | |||
| 3614f3654b | |||
| c4cf006832 |
@@ -60,6 +60,7 @@ Temporary Items
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
!frontend/src/routes/logs/
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ RUN addgroup -g 1000 upsnap &&\
|
||||
WORKDIR /app
|
||||
COPY --from=downloader /app/upsnap upsnap
|
||||
LABEL org.opencontainers.image.source="https://github.com/seriousm4x/UpSnap" \
|
||||
org.opencontainers.image.url="https://github.com/seriousm4x/UpSnap" \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
org.opencontainers.image.url="https://github.com/seriousm4x/UpSnap" \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
HEALTHCHECK --interval=10s \
|
||||
CMD curl -fs "http://${UPSNAP_HTTP_LISTEN}/api/health" || exit 1
|
||||
CMD ["serve","--http","${UPSNAP_HTTP_LISTEN}"]
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM node:alpine AS node
|
||||
FROM node:bookworm AS node
|
||||
WORKDIR /app
|
||||
COPY frontend/ .
|
||||
RUN npm i -g pnpm &&\
|
||||
|
||||
@@ -18,23 +18,16 @@
|
||||
</div>
|
||||
</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
|
||||
- ⏰ Timed Events via Cron for Automation
|
||||
- 🔌 Ping Any Port You Choose
|
||||
- 🔍 Discover Devices with Network Scanning (nmap required)
|
||||
- 📌 Optional IP Address Tracking per Device via periodic ARP scan (nmap required, no extra privileges beyond network scanning)
|
||||
- ❎️ Shutdown Devices with a Custom Command
|
||||
- 👤 Secured User Management
|
||||
- 📋 Superuser Logs Page
|
||||
- 🌐 i18n support for [these](/frontend/translations) languages
|
||||
- 🎨 35 Themes
|
||||
- 🐳 [Docker images](https://github.com/seriousm4x/UpSnap/pkgs/container/upsnap) for amd64, arm64, arm/v7, arm/v6
|
||||
@@ -69,6 +62,8 @@ Just pull and run the image: `docker run --network=host seriousm4x/upsnap:latest
|
||||
|
||||
To run as non-root, refer to the Wiki: [Use non-root user](https://github.com/seriousm4x/UpSnap/wiki/Use-non%E2%80%90root-user)
|
||||
|
||||
Set `UPSNAP_LOG_LEVEL` to `DEBUG`, `INFO`, `WARN`, `ERROR`, or `OFF` to control UpSnap console logs. Default is `INFO`. PocketBase log persistence and retention remain configurable in PocketBase settings. PocketBase's `--dev` mode prints all logs regardless of this setting.
|
||||
|
||||
### Change port (Docker)
|
||||
|
||||
If you want to change the port from 8090 to something else, change the following (5000 in this case):
|
||||
@@ -195,7 +190,3 @@ pnpm run dev
|
||||
```
|
||||
|
||||
Open up [http://localhost:5173/](http://localhost:5173/), create an admin user and add some devices.
|
||||
|
||||
## 🌟 Star History
|
||||
|
||||
[](https://star-history.com/#seriousm4x/UpSnap&Date)
|
||||
|
||||
@@ -2,15 +2,6 @@ version: 2
|
||||
release:
|
||||
draft: false
|
||||
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
|
||||
@@ -29,6 +20,7 @@ builds:
|
||||
- amd64
|
||||
- arm64
|
||||
- arm
|
||||
- riscv64
|
||||
goarm:
|
||||
- "6"
|
||||
- "7"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package cronjobs
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/seriousm4x/upsnap/iptracking"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
"github.com/seriousm4x/upsnap/networking"
|
||||
)
|
||||
|
||||
@@ -19,7 +19,8 @@ var (
|
||||
)))
|
||||
)
|
||||
|
||||
func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
func SetPingJobs(app core.App) {
|
||||
log := logging.Logger(app)
|
||||
// remove existing jobs
|
||||
for _, job := range CronPing.Entries() {
|
||||
CronPing.Remove(job.ID)
|
||||
@@ -27,7 +28,8 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
|
||||
settingsPrivateRecords, err := app.FindAllRecords("settings_private")
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to load private settings", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
CronPing.AddFunc(settingsPrivateRecords[0].GetString("interval"), func() {
|
||||
@@ -39,7 +41,7 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
|
||||
devices, err := app.FindAllRecords("devices")
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to load devices for ping job", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,6 +51,7 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
}
|
||||
merr := app.ExpandRecords(devices, []string{"ports"}, expandFetchFunc)
|
||||
if len(merr) > 0 {
|
||||
log.Error("Failed to expand device ports", "errors", merr)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -61,7 +64,7 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
}
|
||||
isUp, err := networking.PingDevice(d)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to ping device", "device", d.GetString("name"), "error", err)
|
||||
}
|
||||
if isUp {
|
||||
if status == "online" {
|
||||
@@ -69,7 +72,9 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
}
|
||||
d.Set("status", "online")
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
log.Error("Failed to save device status", "device", d.GetString("name"), "error", err)
|
||||
} else {
|
||||
log.Info("Device turned on", "device", d.GetString("name"))
|
||||
}
|
||||
} else {
|
||||
if status == "offline" {
|
||||
@@ -77,7 +82,9 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
}
|
||||
d.Set("status", "offline")
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
log.Error("Failed to save device status", "device", d.GetString("name"), "error", err)
|
||||
} else {
|
||||
log.Info("Device turned off", "device", d.GetString("name"))
|
||||
}
|
||||
}
|
||||
}(device)
|
||||
@@ -86,26 +93,50 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
go func(d *core.Record) {
|
||||
ports, err := app.FindRecordsByIds("ports", d.GetStringSlice("ports"))
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to load device ports", "device", d.GetString("name"), "error", err)
|
||||
return
|
||||
}
|
||||
deviceIP, resolveErr := networking.ResolveToIPAddr(d.GetString("ip"))
|
||||
if resolveErr != nil {
|
||||
log.Error("Failed to resolve device IP", "device", d.GetString("name"), "error", resolveErr)
|
||||
}
|
||||
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 := false
|
||||
// No IP found means the device is down.
|
||||
if resolveErr == nil && deviceIP != "" {
|
||||
var checkErr error
|
||||
isUp, checkErr = networking.CheckPort(deviceIP, port.GetString("number"))
|
||||
if checkErr != nil {
|
||||
log.Error("Failed to check port", "device", d.GetString("name"), "port", port.GetString("number"), "error", checkErr)
|
||||
}
|
||||
}
|
||||
if isUp != port.GetBool("status") {
|
||||
port.Set("status", isUp)
|
||||
if err := app.Save(port); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
log.Error("Failed to save port status", "device", d.GetString("name"), "port", port.GetString("number"), "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}(device)
|
||||
}
|
||||
})
|
||||
|
||||
// update ip addresses of opted-in devices from a periodic arp scan
|
||||
trackIpInterval := settingsPrivateRecords[0].GetString("track_ip_interval")
|
||||
if trackIpInterval != "" {
|
||||
if _, err := CronPing.AddFunc(trackIpInterval, func() {
|
||||
// pause scans if no realtime clients connected and lazy_ping is
|
||||
// turned on; a catch-up sweep runs when the next client connects
|
||||
realtimeClients := len(app.SubscriptionsBroker().Clients())
|
||||
iptracking.PeriodicSweep(app, realtimeClients == 0 && settingsPrivateRecords[0].GetBool("lazy_ping"))
|
||||
}); err != nil {
|
||||
log.Error("Failed to add IP tracking cron job", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
func SetWakeShutdownJobs(app core.App) {
|
||||
log := logging.Logger(app)
|
||||
// remove existing jobs
|
||||
for _, job := range CronWakeShutdown.Entries() {
|
||||
CronWakeShutdown.Remove(job.ID)
|
||||
@@ -113,7 +144,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
|
||||
devices, err := app.FindAllRecords("devices")
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to load devices for wake and shutdown jobs", "error", err)
|
||||
return
|
||||
}
|
||||
for _, dev := range devices {
|
||||
@@ -126,7 +157,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
_, err := CronWakeShutdown.AddFunc(wake_cron, func() {
|
||||
d, err := app.FindRecordById("devices", dev.Id)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to load device for wake job", "device", dev.GetString("name"), "error", err)
|
||||
return
|
||||
}
|
||||
if d.GetString("status") == "pending" {
|
||||
@@ -134,7 +165,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
}
|
||||
isOnline, err := networking.PingDevice(d)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to ping device before wake", "device", d.GetString("name"), "error", err)
|
||||
return
|
||||
}
|
||||
if isOnline {
|
||||
@@ -142,21 +173,21 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
}
|
||||
d.Set("status", "pending")
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
log.Error("Failed to save pending device status", "device", d.GetString("name"), "error", err)
|
||||
return
|
||||
}
|
||||
if err := networking.WakeDevice(d); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := networking.WakeDevice(app, d, "cron"); err != nil {
|
||||
log.Error("Wake job failed", "device", d.GetString("name"), "error", err)
|
||||
d.Set("status", "offline")
|
||||
} else {
|
||||
d.Set("status", "online")
|
||||
}
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
log.Error("Failed to save device status after wake", "device", d.GetString("name"), "error", err)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error.Printf("device %s: %+v", dev.GetString("name"), err)
|
||||
log.Error("Failed to add wake cron job", "device", dev.GetString("name"), "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +195,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
_, err := CronWakeShutdown.AddFunc(shutdown_cron, func() {
|
||||
d, err := app.FindRecordById("devices", dev.Id)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to load device for shutdown job", "device", dev.GetString("name"), "error", err)
|
||||
return
|
||||
}
|
||||
if d.GetString("status") == "pending" {
|
||||
@@ -172,32 +203,31 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
}
|
||||
isOnline, err := networking.PingDevice(d)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to ping device before shutdown", "device", d.GetString("name"), "error", err)
|
||||
return
|
||||
}
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
status := d.GetString("status")
|
||||
if status != "online" {
|
||||
return
|
||||
}
|
||||
// The status can be stale when lazy ping marks devices offline after
|
||||
// the last client disconnects. The reachability check above is the
|
||||
// authoritative signal for whether a shutdown command may run.
|
||||
d.Set("status", "pending")
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
log.Error("Failed to save pending device status", "device", d.GetString("name"), "error", err)
|
||||
}
|
||||
if err := networking.ShutdownDevice(d); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := networking.ShutdownDevice(app, d, "cron"); err != nil {
|
||||
log.Error("Shutdown job failed", "device", d.GetString("name"), "error", err)
|
||||
d.Set("status", "online")
|
||||
} else {
|
||||
d.Set("status", "offline")
|
||||
}
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
log.Error("Failed to save device status after shutdown", "device", d.GetString("name"), "error", err)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error.Printf("device %s: %+v", dev.GetString("name"), err)
|
||||
log.Error("Failed to add shutdown cron job", "device", dev.GetString("name"), "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,9 +239,9 @@ func StartWakeShutdown() {
|
||||
|
||||
}
|
||||
|
||||
func StopWakeShutdown() {
|
||||
func StopWakeShutdown(app core.App) {
|
||||
if WakeShutdownRunning {
|
||||
logger.Info.Println("Stopping wake/shutdown cronjob")
|
||||
logging.Logger(app).Info("Stopping wake and shutdown cron jobs")
|
||||
CronWakeShutdown.Stop()
|
||||
}
|
||||
WakeShutdownRunning = false
|
||||
@@ -222,15 +252,15 @@ func StartPing() {
|
||||
go CronPing.Run()
|
||||
}
|
||||
|
||||
func StopPing() {
|
||||
func StopPing(app core.App) {
|
||||
if PingRunning {
|
||||
logger.Info.Println("Stopping wake/shutdown cronjob")
|
||||
logging.Logger(app).Info("Stopping ping cron jobs")
|
||||
CronPing.Stop()
|
||||
}
|
||||
PingRunning = false
|
||||
}
|
||||
|
||||
func StopAll() {
|
||||
StopPing()
|
||||
StopWakeShutdown()
|
||||
func StopAll(app core.App) {
|
||||
StopPing(app)
|
||||
StopWakeShutdown(app)
|
||||
}
|
||||
|
||||
+20
-19
@@ -1,14 +1,17 @@
|
||||
module github.com/seriousm4x/upsnap
|
||||
|
||||
go 1.26.3
|
||||
go 1.27
|
||||
|
||||
require (
|
||||
github.com/godbus/dbus/v5 v5.2.2
|
||||
github.com/holoplot/go-avahi v1.0.1
|
||||
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a
|
||||
github.com/pocketbase/dbx v1.12.0
|
||||
github.com/pocketbase/pocketbase v0.39.5
|
||||
github.com/pocketbase/pocketbase v0.40.4
|
||||
github.com/prometheus-community/pro-bing v0.9.1
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
golang.org/x/sys v0.46.0
|
||||
golang.org/x/net v0.59.0
|
||||
golang.org/x/sys v0.48.0
|
||||
kernel.org/pub/linux/libs/security/libcap/cap v1.2.78
|
||||
)
|
||||
|
||||
@@ -19,34 +22,32 @@ require (
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/fatih/color v1.19.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.10.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||
github.com/ganigeorgiev/fexpr v0.5.0 // indirect
|
||||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
|
||||
github.com/ganigeorgiev/fexpr v0.6.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/uuid v1.6.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/josharian/native v1.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.15 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
|
||||
github.com/mdlayher/packet v1.1.2 // indirect
|
||||
github.com/mdlayher/socket v0.6.1 // indirect
|
||||
github.com/mdlayher/packet v1.2.0 // indirect
|
||||
github.com/mdlayher/socket v0.7.0 // indirect
|
||||
github.com/ncruces/go-strftime v1.0.0 // indirect
|
||||
github.com/pocketbase/ozzo-validation/v4 v4.3.0 // 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.53.0 // indirect
|
||||
golang.org/x/image v0.43.0 // indirect
|
||||
golang.org/x/net v0.56.0 // indirect
|
||||
golang.org/x/oauth2 v0.36.0 // indirect
|
||||
golang.org/x/sync v0.21.0 // indirect
|
||||
golang.org/x/text v0.38.0 // indirect
|
||||
golang.org/x/crypto v0.57.0 // indirect
|
||||
golang.org/x/image v0.46.0 // indirect
|
||||
golang.org/x/oauth2 v0.37.0 // indirect
|
||||
golang.org/x/sync v0.23.0 // indirect
|
||||
golang.org/x/text v0.42.0 // indirect
|
||||
kernel.org/pub/linux/libs/security/libcap/psx v1.2.78 // indirect
|
||||
modernc.org/libc v1.72.3 // indirect
|
||||
modernc.org/libc v1.74.4 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
modernc.org/sqlite v1.52.0 // indirect
|
||||
modernc.org/memory v1.12.1 // indirect
|
||||
modernc.org/sqlite v1.57.0 // indirect
|
||||
)
|
||||
|
||||
+51
-48
@@ -19,15 +19,16 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
|
||||
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
|
||||
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/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/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI=
|
||||
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
||||
github.com/ganigeorgiev/fexpr v0.6.0 h1:Fza3O/QMBKEudUvxV862qe6GjxM60GJjjKytdp+VQus=
|
||||
github.com/ganigeorgiev/fexpr v0.6.0/go.mod h1:RyGiGqmeXhEQ6+mlGdnUleLHgtzzu/VGO2WtJkF5drE=
|
||||
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/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
|
||||
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
|
||||
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/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -36,35 +37,35 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
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-20260604005048-7023385849c0 h1:h1QTMDl6q9wDvDCJVpKQSjgleGFYnd2fOxmg2K+6BGE=
|
||||
github.com/google/pprof v0.0.0-20260604005048-7023385849c0/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
|
||||
github.com/google/pprof v0.0.0-20260902005441-ca85771921e4 h1:/6mPXfWmhv8eKck12I0YNIcIjwHtxP3YRIMKiEgTjWg=
|
||||
github.com/google/pprof v0.0.0-20260902005441-ca85771921e4/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=
|
||||
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/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/holoplot/go-avahi v1.0.1 h1:XcqR2keL4qWRnlxHD5CAOdWpLFZJ+EOUK0vEuylfvvk=
|
||||
github.com/holoplot/go-avahi v1.0.1/go.mod h1:qH5psEKb0DK+BRplMfc+RY4VMOlbf6mqfxgpMy6aP0M=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
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/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.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
|
||||
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||
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=
|
||||
github.com/mdlayher/packet v1.0.0/go.mod h1:eE7/ctqDhoiRhQ44ko5JZU2zxB88g+JH/6jmnjzPjOU=
|
||||
github.com/mdlayher/packet v1.1.2 h1:3Up1NG6LZrsgDVn6X4L9Ge/iyRyxFEFD9o6Pr3Q1nQY=
|
||||
github.com/mdlayher/packet v1.1.2/go.mod h1:GEu1+n9sG5VtiRE4SydOmX5GTwyyYlteZiFU+x0kew4=
|
||||
github.com/mdlayher/packet v1.2.0 h1:SX7/oY0+nkKo7p4Sv30+TIc3YuWgvDEf0eucTXRyPqk=
|
||||
github.com/mdlayher/packet v1.2.0/go.mod h1:UtYVnQt+Zj6UD0F89HfzkqGXaYqys1NwkrS86wlLCv4=
|
||||
github.com/mdlayher/raw v0.0.0-20190313224157-43dbcdd7739d/go.mod h1:r1fbeITl2xL/zLbVnNHFyOzQJTgr/3fpf1lJX/cjzR8=
|
||||
github.com/mdlayher/socket v0.2.1/go.mod h1:QLlNPkFR88mRUNQIzRBMfXxwKal8H7u1h3bL1CV+f0E=
|
||||
github.com/mdlayher/socket v0.6.1 h1:M7uj2NtuujUY4mYr1C57NmfNiRHbkKpnBxO856lsc3A=
|
||||
github.com/mdlayher/socket v0.6.1/go.mod h1:+/SGtqc9V+5dAuRgQsU0fGBI+oRDiW7O2Obx10OIWfg=
|
||||
github.com/mdlayher/socket v0.7.0 h1:qVREPVwtUMg17pwvveQxpurq0PVisMxi3FGgpsorMYQ=
|
||||
github.com/mdlayher/socket v0.7.0/go.mod h1:f7iKql2EK/rfsWYDKofKjk2Ig7I+6HQWdMIdn1tO4A4=
|
||||
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=
|
||||
@@ -73,8 +74,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
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.39.5 h1:tAqVi6/SfSXw4DwJZ6S6zaYlfdMDZG2t3sNc3f1xR+Q=
|
||||
github.com/pocketbase/pocketbase v0.39.5/go.mod h1:o/iskDiVCrYFC04uTBpMrwgZm07UCIOkuw1QP/oXOp0=
|
||||
github.com/pocketbase/ozzo-validation/v4 v4.3.0 h1:uKBDVma7bZqgR2a6AwE+k9hkuDFfiZMpBHQdZ1z3iQs=
|
||||
github.com/pocketbase/ozzo-validation/v4 v4.3.0/go.mod h1:6XNjSTw/Jb2F8LOkKO3oyzIWExbrGiYoS4uVxVwz90g=
|
||||
github.com/pocketbase/pocketbase v0.40.4 h1:0SvSUreR3NhUMCs9LchE59oEG53efZ3cKiMGyAGBN9U=
|
||||
github.com/pocketbase/pocketbase v0.40.4/go.mod h1:2mU+80FLiY1fb13WZRg8Xx/lKg4nTjgKVJMigyRH6k0=
|
||||
github.com/prometheus-community/pro-bing v0.9.1 h1:kpuAr6AU2oRtzGihJSUcetHtjc7ku7h6PxeuW9RVrQw=
|
||||
github.com/prometheus-community/pro-bing v0.9.1/go.mod h1:z79wYTxAOf6FpTng0QdIhZ3j/Nd5l3+gnFSCIT+SiSQ=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
@@ -97,36 +100,36 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
|
||||
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=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
|
||||
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.43.0 h1:FLxcP4ec2350nTfOC8ysKtqYSIFbk/QGjw1ZHNP4tsY=
|
||||
golang.org/x/image v0.43.0/go.mod h1:rrpelvGFt+kLPAjPM4HeWPgrl0FtafueU//e5N0qk/Q=
|
||||
golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4=
|
||||
golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ=
|
||||
golang.org/x/image v0.46.0 h1:b1+oYj0Jbp6K5MDT4i4/eZpYlk3V8SJhhDKh6LBHAyQ=
|
||||
golang.org/x/image v0.46.0/go.mod h1:3B3W05VGVQyuXucLINLjXKrqISASfi4Xj+iCVkLMwew=
|
||||
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
|
||||
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
|
||||
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/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.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
|
||||
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
|
||||
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
|
||||
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
|
||||
golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues=
|
||||
golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
|
||||
golang.org/x/oauth2 v0.37.0 h1:JUlcxA8oAtauLfiH8FX2/FkAWHAdi0QtGCGc+hofE98=
|
||||
golang.org/x/oauth2 v0.37.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=
|
||||
golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/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-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.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
||||
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
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.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
||||
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8=
|
||||
golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0=
|
||||
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
|
||||
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -137,30 +140,30 @@ kernel.org/pub/linux/libs/security/libcap/cap v1.2.78 h1:jgqg4gyu2BaYW9L6uzEtGLf
|
||||
kernel.org/pub/linux/libs/security/libcap/cap v1.2.78/go.mod h1:VjuVda6m2qGkpCVfrFkpTGyvkdlZ2N5/yfo89tujlg8=
|
||||
kernel.org/pub/linux/libs/security/libcap/psx v1.2.78 h1:PC3yNs51cX5LZ7U57a7xielBcoXB3xnV+rXD8V0H0DQ=
|
||||
kernel.org/pub/linux/libs/security/libcap/psx v1.2.78/go.mod h1:+l6Ee2F59XiJ2I6WR5ObpC1utCQJZ/VLsEbQCD8RG24=
|
||||
modernc.org/cc/v4 v4.28.2 h1:3tQ0lf2ADtoby2EtSP+J7IE2SHwEJdP8ioR59wx7XpY=
|
||||
modernc.org/cc/v4 v4.28.2/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.34.0 h1:yRLPFZieg532OT4rp4JFNIVcquwalMX26G95WQDqwCQ=
|
||||
modernc.org/ccgo/v4 v4.34.0/go.mod h1:AS5WYMyBakQ+fhsHhtP8mWB82KTGPkNNJDGfGQCe0/A=
|
||||
modernc.org/cc/v4 v4.29.1 h1:MKgdCV3WykTSPqpVrnxdEDS0HEd2FHpKZDzxzU5LyeI=
|
||||
modernc.org/cc/v4 v4.29.1/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.34.6 h1:sBgfIwyN0TQ9C5hwIeuqyeAKyMWnbvj2fvpF4L11uzU=
|
||||
modernc.org/ccgo/v4 v4.34.6/go.mod h1:SZ8YcN9NG7XVsQYdm6jYBvi8PQP1qi+kqB6OhjqI3Fk=
|
||||
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||
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.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo=
|
||||
modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=
|
||||
modernc.org/gc/v3 v3.1.4/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.72.3 h1:ZnDF4tXn4NBXFutMMQC4vtbTFSXhhKzR73fv0beZEAU=
|
||||
modernc.org/libc v1.72.3/go.mod h1:dn0dZNnnn1clLyvRxLxYExxiKRZIRENOfqQ8XEeg4Qs=
|
||||
modernc.org/libc v1.74.4 h1:fX1Omw4o2/1C2iRkkIsrQTasJQldLhRmuPreXLoWs9k=
|
||||
modernc.org/libc v1.74.4/go.mod h1:eeQAS9W3sZeKYMFubydxJpII9ybHWshk+7or7bLG9co=
|
||||
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/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
||||
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||
modernc.org/opt v0.2.0/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.52.0 h1:p4dhYh2tXZCiyaqHwRVJDjIGKWyXayiQpThxgDzJaxo=
|
||||
modernc.org/sqlite v1.52.0/go.mod h1:tcNzv5p84E0skkmJn038y+hWJbLQXQqEnQfeh5r2JLM=
|
||||
modernc.org/sqlite v1.57.0 h1:qNQP6xnx5M0ISNtlnxoOX0+cD5bJ0/gr9aMmndFczzg=
|
||||
modernc.org/sqlite v1.57.0/go.mod h1:yCJ2cmAaIkHQ25oXWrF8H4O1lIfPYPR26yCEDj2P3pQ=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// Package iptracking updates the stored ip addresses of opted-in devices by
|
||||
// scanning their local subnets for their mac addresses.
|
||||
package iptracking
|
||||
|
||||
import (
|
||||
"net"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
"github.com/seriousm4x/upsnap/networking"
|
||||
)
|
||||
|
||||
var sweepRunning atomic.Bool
|
||||
|
||||
// sweepOwed marks that a periodic sweep was skipped while no realtime
|
||||
// clients were connected, so the next client to connect gets a catch-up
|
||||
// sweep. Starts true so the first client after boot gets fresh ips.
|
||||
var sweepOwed atomic.Bool
|
||||
|
||||
func init() {
|
||||
sweepOwed.Store(true)
|
||||
}
|
||||
|
||||
// nmapScan is a seam for tests to stub out the privileged nmap invocation
|
||||
var nmapScan = networking.NmapScan
|
||||
|
||||
// TrackAllSubnets scans the local subnets of devices with ip tracking enabled
|
||||
// and updates their ip address if their mac address is found at a different
|
||||
// one. Non-scannable subnets are silently skipped, but their devices can
|
||||
// still be updated by another subnet's scan that finds their mac address,
|
||||
// as long as the new ip stays within the device's own subnet.
|
||||
func TrackAllSubnets(app core.App) {
|
||||
log := logging.Logger(app)
|
||||
// skip if the previous sweep is still running
|
||||
if !sweepRunning.CompareAndSwap(false, true) {
|
||||
return
|
||||
}
|
||||
defer sweepRunning.Store(false)
|
||||
|
||||
devices, err := app.FindRecordsByFilter("devices", "track_ip = true", "", 0, 0)
|
||||
if err != nil {
|
||||
log.Error("Failed to load devices for IP tracking", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
// collect the unique scannable subnets of the tracked devices
|
||||
subnets := make(map[string]*net.IPNet)
|
||||
for _, device := range devices {
|
||||
subnet, err := networking.DeviceSubnet(device.GetString("ip"), device.GetString("netmask"))
|
||||
if err != nil {
|
||||
log.Error("Failed to determine device subnet for IP tracking", "device", device.GetString("name"), "error", err)
|
||||
continue
|
||||
}
|
||||
if networking.ValidateScannableSubnet(subnet) != nil {
|
||||
continue
|
||||
}
|
||||
subnets[subnet.String()] = subnet
|
||||
}
|
||||
|
||||
for cidr, subnet := range subnets {
|
||||
if err := TrackOneSubnet(app, subnet); err != nil {
|
||||
log.Error("IP tracking scan failed", "subnet", cidr, "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PeriodicSweep runs the scheduled sweep, or skips it when paused — no
|
||||
// realtime clients connected while lazy_ping is on — owing a catch-up
|
||||
// sweep to the next client that connects.
|
||||
func PeriodicSweep(app core.App, pause bool) {
|
||||
if pause {
|
||||
sweepOwed.Store(true)
|
||||
return
|
||||
}
|
||||
TrackAllSubnets(app)
|
||||
}
|
||||
|
||||
// CatchUpSweep runs a sweep if one is owed, i.e. the periodic sweep was
|
||||
// skipped while nobody was connected or hasn't run since boot. Clients
|
||||
// connecting while sweeps run on schedule trigger nothing.
|
||||
func CatchUpSweep(app core.App) {
|
||||
if !sweepOwed.CompareAndSwap(true, false) {
|
||||
return
|
||||
}
|
||||
TrackAllSubnets(app)
|
||||
}
|
||||
|
||||
// TrackOneSubnet runs an nmap scan of the given subnet and updates the ip
|
||||
// address of any ip-tracked device whose mac address is found at a new
|
||||
// address within its own subnet. Returns an error for a non-scannable subnet.
|
||||
func TrackOneSubnet(app core.App, subnet *net.IPNet) error {
|
||||
log := logging.Logger(app)
|
||||
if err := networking.ValidateScannableSubnet(subnet); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
scan, err := nmapScan(subnet.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
macToIp := scan.MacToIP()
|
||||
|
||||
devices, err := app.FindRecordsByFilter("devices", "track_ip = true", "", 0, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, device := range devices {
|
||||
parsedMac, err := net.ParseMAC(device.GetString("mac"))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
newIp, ok := macToIp[parsedMac.String()]
|
||||
if !ok || newIp == device.GetString("ip") {
|
||||
continue
|
||||
}
|
||||
// only move a device within its own subnet, so that a scan can't
|
||||
// relocate devices tracked on other subnets that see the same mac
|
||||
deviceSubnet, err := networking.DeviceSubnet(device.GetString("ip"), device.GetString("netmask"))
|
||||
if err != nil || !deviceSubnet.Contains(net.ParseIP(newIp)) {
|
||||
continue
|
||||
}
|
||||
oldIP := device.GetString("ip")
|
||||
device.Set("ip", newIp)
|
||||
// only write the changed ip field to avoid clobbering concurrent
|
||||
// status updates from the ping and wake/shutdown cronjobs
|
||||
device.IgnoreUnchangedFields(true)
|
||||
if err := app.Save(device); err != nil {
|
||||
log.Error("Failed to save tracked device IP", "device", device.GetString("name"), "error", err)
|
||||
} else {
|
||||
log.Info("Device IP changed", "device", device.GetString("name"), "from", oldIP, "to", newIp)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
package iptracking
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/tests"
|
||||
"github.com/seriousm4x/upsnap/networking"
|
||||
|
||||
// register the app migrations so test apps get the real schema
|
||||
_ "github.com/seriousm4x/upsnap/migrations"
|
||||
)
|
||||
|
||||
// newTestApp returns a throwaway app with all migrations applied.
|
||||
func newTestApp(t *testing.T) *tests.TestApp {
|
||||
t.Helper()
|
||||
app, err := tests.NewTestApp(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
t.Cleanup(app.Cleanup)
|
||||
return app
|
||||
}
|
||||
|
||||
func buildDevice(t *testing.T, app core.App, name, ip, netmask, mac string, trackIp bool) *core.Record {
|
||||
t.Helper()
|
||||
collection, err := app.FindCollectionByNameOrId("devices")
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
device := core.NewRecord(collection)
|
||||
device.Set("name", name)
|
||||
device.Set("ip", ip)
|
||||
device.Set("netmask", netmask)
|
||||
device.Set("mac", mac)
|
||||
device.Set("track_ip", trackIp)
|
||||
return device
|
||||
}
|
||||
|
||||
func newDevice(t *testing.T, app core.App, name, ip, netmask, mac string, trackIp bool) *core.Record {
|
||||
t.Helper()
|
||||
device := buildDevice(t, app, name, ip, netmask, mac, trackIp)
|
||||
if err := app.Save(device); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
return device
|
||||
}
|
||||
|
||||
// newLegacyDevice saves a device bypassing field validation, like rows
|
||||
// created before the ip and mac format rules existed.
|
||||
func newLegacyDevice(t *testing.T, app core.App, name, ip, netmask, mac string, trackIp bool) *core.Record {
|
||||
t.Helper()
|
||||
device := buildDevice(t, app, name, ip, netmask, mac, trackIp)
|
||||
if err := app.SaveNoValidate(device); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
return device
|
||||
}
|
||||
|
||||
// stubScan replaces the nmap seam with a canned scan reporting the given
|
||||
// mac addresses at the given ips, and returns the list of scanned ranges.
|
||||
func stubScan(t *testing.T, macToHostIp map[string]string) *[]string {
|
||||
t.Helper()
|
||||
var sample strings.Builder
|
||||
sample.WriteString("<nmaprun>")
|
||||
for mac, ip := range macToHostIp {
|
||||
fmt.Fprintf(&sample, `<host><address addr=%q addrtype="ipv4"/><address addr=%q addrtype="mac"/></host>`, ip, mac)
|
||||
}
|
||||
sample.WriteString("</nmaprun>")
|
||||
scan := networking.Nmaprun{}
|
||||
if err := xml.Unmarshal([]byte(sample.String()), &scan); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
var scanned []string
|
||||
orig := nmapScan
|
||||
nmapScan = func(scanRange string) (networking.Nmaprun, error) {
|
||||
scanned = append(scanned, scanRange)
|
||||
return scan, nil
|
||||
}
|
||||
t.Cleanup(func() { nmapScan = orig })
|
||||
return &scanned
|
||||
}
|
||||
|
||||
func mustSubnet(t *testing.T, cidr string) *net.IPNet {
|
||||
t.Helper()
|
||||
_, subnet, err := net.ParseCIDR(cidr)
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
return subnet
|
||||
}
|
||||
|
||||
// The loopback /16 passes the scannable checks on any host, making it the
|
||||
// only subnet a test can scan without depending on the environment.
|
||||
const (
|
||||
testSubnet = "127.0.0.0/16"
|
||||
testNetmask = "255.255.0.0"
|
||||
)
|
||||
|
||||
func TestTrackOneSubnetSkipsUntrackedDevices(t *testing.T) {
|
||||
app := newTestApp(t)
|
||||
device := newDevice(t, app, "untracked", "127.0.0.50", testNetmask, "AA:BB:CC:DD:EE:01", false)
|
||||
stubScan(t, map[string]string{"AA:BB:CC:DD:EE:01": "127.0.0.99"})
|
||||
|
||||
if err := TrackOneSubnet(app, mustSubnet(t, testSubnet)); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
fresh, err := app.FindRecordById("devices", device.Id)
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
if ip := fresh.GetString("ip"); ip != "127.0.0.50" {
|
||||
t.Errorf("Ip of device without track_ip changed to %s", ip)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrackOneSubnetSkipPaths(t *testing.T) {
|
||||
app := newTestApp(t)
|
||||
saves := 0
|
||||
app.OnRecordUpdate("devices").BindFunc(func(e *core.RecordEvent) error {
|
||||
saves++
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip string
|
||||
mac string
|
||||
legacy bool
|
||||
}{
|
||||
// A device mac that can't be parsed never matches
|
||||
{
|
||||
name: "Invalid Mac",
|
||||
ip: "127.0.0.50",
|
||||
mac: "not-a-mac",
|
||||
legacy: true,
|
||||
},
|
||||
// A device mac missing from the scan results is left alone
|
||||
{
|
||||
name: "Mac Not In Scan",
|
||||
ip: "127.0.0.50",
|
||||
mac: "AA:BB:CC:DD:EE:02",
|
||||
},
|
||||
// A device ip without a computable subnet is never moved
|
||||
{
|
||||
name: "Invalid Device Ip",
|
||||
ip: "999.999.999.999",
|
||||
mac: "AA:BB:CC:DD:EE:01",
|
||||
legacy: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
create := newDevice
|
||||
if tc.legacy {
|
||||
create = newLegacyDevice
|
||||
}
|
||||
device := create(t, app, tc.name, tc.ip, testNetmask, tc.mac, true)
|
||||
stubScan(t, map[string]string{"AA:BB:CC:DD:EE:01": "127.0.0.99"})
|
||||
|
||||
if err := TrackOneSubnet(app, mustSubnet(t, testSubnet)); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
fresh, err := app.FindRecordById("devices", device.Id)
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
if ip := fresh.GetString("ip"); ip != tc.ip {
|
||||
t.Errorf("Ip mismatch: expected %s, got %s", tc.ip, ip)
|
||||
}
|
||||
if saves != 0 {
|
||||
t.Errorf("Expected no record updates, got %d", saves)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrackOneSubnetUnscannable(t *testing.T) {
|
||||
app := newTestApp(t)
|
||||
// TEST-NET-1 (RFC 5737) is never assigned to an interface
|
||||
scanned := stubScan(t, nil)
|
||||
|
||||
if err := TrackOneSubnet(app, mustSubnet(t, "192.0.2.0/24")); err == nil {
|
||||
t.Error("Expected error but got none")
|
||||
}
|
||||
if len(*scanned) != 0 {
|
||||
t.Errorf("Expected no scans of an unscannable subnet, got %v", *scanned)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrackOneSubnetSameSubnetGuard(t *testing.T) {
|
||||
app := newTestApp(t)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip string
|
||||
netmask string
|
||||
mac string
|
||||
scanMac string
|
||||
foundIp string
|
||||
wantIp string
|
||||
}{
|
||||
// A move within the device's own subnet is applied, with the
|
||||
// stored dashed lower case mac matching the scanned
|
||||
// colon-separated upper case one
|
||||
{
|
||||
name: "Within Own Subnet",
|
||||
ip: "127.0.0.50",
|
||||
netmask: testNetmask,
|
||||
mac: "aa-bb-cc-dd-01-01",
|
||||
scanMac: "AA:BB:CC:DD:01:01",
|
||||
foundIp: "127.0.0.99",
|
||||
wantIp: "127.0.0.99",
|
||||
},
|
||||
// The device's own subnet bounds the move, not the scanned one
|
||||
{
|
||||
name: "Narrower Subnet Within Scan",
|
||||
ip: "127.0.5.5",
|
||||
netmask: "255.255.255.0",
|
||||
mac: "AA:BB:CC:DD:01:02",
|
||||
foundIp: "127.0.5.9",
|
||||
wantIp: "127.0.5.9",
|
||||
},
|
||||
// A found ip outside the device's narrower subnet is not applied,
|
||||
// even though it is inside the scanned subnet
|
||||
{
|
||||
name: "Outside Own Subnet",
|
||||
ip: "127.0.5.5",
|
||||
netmask: "255.255.255.0",
|
||||
mac: "AA:BB:CC:DD:01:03",
|
||||
foundIp: "127.0.6.9",
|
||||
wantIp: "127.0.5.5",
|
||||
},
|
||||
// A device from a disjoint subnet is never moved into the scanned one
|
||||
{
|
||||
name: "Disjoint Subnet",
|
||||
ip: "10.9.9.9",
|
||||
netmask: "255.255.255.0",
|
||||
mac: "AA:BB:CC:DD:01:04",
|
||||
foundIp: "127.0.0.99",
|
||||
wantIp: "10.9.9.9",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
device := newDevice(t, app, tc.name, tc.ip, tc.netmask, tc.mac, true)
|
||||
scanMac := tc.scanMac
|
||||
if scanMac == "" {
|
||||
scanMac = tc.mac
|
||||
}
|
||||
stubScan(t, map[string]string{scanMac: tc.foundIp})
|
||||
|
||||
if err := TrackOneSubnet(app, mustSubnet(t, testSubnet)); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
fresh, err := app.FindRecordById("devices", device.Id)
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
if ip := fresh.GetString("ip"); ip != tc.wantIp {
|
||||
t.Errorf("Ip mismatch: expected %s, got %s", tc.wantIp, ip)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A paused periodic sweep scans nothing and owes a catch-up sweep, which
|
||||
// runs at most once until the next pause; an unpaused sweep scans directly.
|
||||
func TestPeriodicSweepAndCatchUp(t *testing.T) {
|
||||
app := newTestApp(t)
|
||||
newDevice(t, app, "tracked", "127.0.0.50", testNetmask, "AA:BB:CC:DD:09:01", true)
|
||||
scanned := stubScan(t, map[string]string{"AA:BB:CC:DD:09:01": "127.0.0.99"})
|
||||
|
||||
PeriodicSweep(app, true)
|
||||
if len(*scanned) != 0 {
|
||||
t.Fatalf("Expected no scans while paused, got %v", *scanned)
|
||||
}
|
||||
|
||||
CatchUpSweep(app)
|
||||
if len(*scanned) != 1 {
|
||||
t.Fatalf("Expected one scan after a paused sweep, got %v", *scanned)
|
||||
}
|
||||
|
||||
CatchUpSweep(app)
|
||||
if len(*scanned) != 1 {
|
||||
t.Errorf("Expected no scan when none is owed, got %v", *scanned)
|
||||
}
|
||||
|
||||
PeriodicSweep(app, false)
|
||||
if len(*scanned) != 2 {
|
||||
t.Errorf("Expected an unpaused sweep to scan, got %v", *scanned)
|
||||
}
|
||||
|
||||
CatchUpSweep(app)
|
||||
if len(*scanned) != 2 {
|
||||
t.Errorf("Expected an unpaused sweep to owe nothing, got %v", *scanned)
|
||||
}
|
||||
}
|
||||
|
||||
// TrackAllSubnets scans each unique scannable subnet once, silently skips the
|
||||
// rest, and updates any tracked device found at a new ip within its own
|
||||
// subnet — even one whose own subnet couldn't be scanned.
|
||||
func TestTrackAllSubnets(t *testing.T) {
|
||||
app := newTestApp(t)
|
||||
first := newDevice(t, app, "first", "127.0.0.10", testNetmask, "AA:BB:CC:DD:02:01", true)
|
||||
second := newDevice(t, app, "second", "127.0.0.20", testNetmask, "AA:BB:CC:DD:02:02", true)
|
||||
// TEST-NET-1 (RFC 5737) is never assigned to an interface
|
||||
unscannable := newDevice(t, app, "unscannable", "192.0.2.5", "255.255.255.0", "AA:BB:CC:DD:02:03", true)
|
||||
// a /8 subnet is too large to scan but contains the found ip
|
||||
wide := newDevice(t, app, "wide", "127.0.0.60", "255.0.0.0", "AA:BB:CC:DD:02:04", true)
|
||||
scanned := stubScan(t, map[string]string{
|
||||
"AA:BB:CC:DD:02:01": "127.0.0.11",
|
||||
"AA:BB:CC:DD:02:02": "127.0.0.21",
|
||||
"AA:BB:CC:DD:02:04": "127.0.0.61",
|
||||
})
|
||||
|
||||
TrackAllSubnets(app)
|
||||
|
||||
if len(*scanned) != 1 || (*scanned)[0] != testSubnet {
|
||||
t.Errorf("Expected a single scan of %s, got %v", testSubnet, *scanned)
|
||||
}
|
||||
wantIps := map[string]string{
|
||||
first.Id: "127.0.0.11",
|
||||
second.Id: "127.0.0.21",
|
||||
unscannable.Id: "192.0.2.5",
|
||||
wide.Id: "127.0.0.61",
|
||||
}
|
||||
for id, wantIp := range wantIps {
|
||||
fresh, err := app.FindRecordById("devices", id)
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
if ip := fresh.GetString("ip"); ip != wantIp {
|
||||
t.Errorf("Ip mismatch for %s: expected %s, got %s", fresh.GetString("name"), wantIp, ip)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
flags = log.Ldate | log.Ltime | log.Lshortfile
|
||||
)
|
||||
|
||||
var (
|
||||
Info = log.New(os.Stdout, "[INFO] ", flags)
|
||||
Debug = log.New(os.Stdout, "[DEBUG] ", flags)
|
||||
Warning = log.New(os.Stdout, "[WARNING] ", flags)
|
||||
Error = log.New(os.Stderr, "[ERROR] ", flags)
|
||||
)
|
||||
|
||||
func init() {
|
||||
// TODO: decide if you want to log to a file to max
|
||||
// output := io.MultiWriter(os.Stdout, logFile)
|
||||
output := os.Stdout
|
||||
Info.SetOutput(output)
|
||||
Error.SetOutput(output)
|
||||
Debug.SetOutput(output)
|
||||
|
||||
log.SetOutput(Debug.Writer())
|
||||
log.SetPrefix("[DEBUG]")
|
||||
log.SetFlags(flags)
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
var consoleHandler slog.Handler
|
||||
|
||||
// ConfigureConsole sets console output for UpSnap logs. PocketBase persistence
|
||||
// remains controlled by PocketBase's built-in log settings.
|
||||
func ConfigureConsole(level string) error {
|
||||
level = strings.TrimSpace(level)
|
||||
if level == "" {
|
||||
level = "INFO"
|
||||
}
|
||||
|
||||
if strings.EqualFold(level, "OFF") {
|
||||
consoleHandler = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
var parsed slog.Level
|
||||
if err := parsed.UnmarshalText([]byte(strings.ToUpper(level))); err != nil {
|
||||
return fmt.Errorf("invalid UPSNAP_LOG_LEVEL %q (expected DEBUG, INFO, WARN, ERROR, or OFF)", level)
|
||||
}
|
||||
|
||||
consoleHandler = slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: parsed,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func relativeSource(file string) string {
|
||||
file = strings.ReplaceAll(file, "\\", "/")
|
||||
if index := strings.LastIndex(file, "/backend/"); index >= 0 {
|
||||
return file[index+1:]
|
||||
}
|
||||
return file
|
||||
}
|
||||
|
||||
// Logger writes through PocketBase's logger and mirrors UpSnap logs to stdout.
|
||||
func Logger(app core.App) *slog.Logger {
|
||||
handlers := []slog.Handler{app.Logger().Handler()}
|
||||
if consoleHandler != nil && !app.IsDev() {
|
||||
handlers = append(handlers, consoleHandler)
|
||||
}
|
||||
return slog.New(multiHandler(handlers)).With("upsnap", true)
|
||||
}
|
||||
|
||||
type multiHandler []slog.Handler
|
||||
|
||||
func (h multiHandler) Enabled(ctx context.Context, level slog.Level) bool {
|
||||
for _, handler := range h {
|
||||
if handler.Enabled(ctx, level) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (h multiHandler) Handle(ctx context.Context, record slog.Record) error {
|
||||
if record.PC != 0 {
|
||||
frames := runtime.CallersFrames([]uintptr{record.PC})
|
||||
frame, _ := frames.Next()
|
||||
record.AddAttrs(slog.String(slog.SourceKey, relativeSource(frame.File)+":"+strconv.Itoa(frame.Line)))
|
||||
}
|
||||
|
||||
var errs []error
|
||||
for _, handler := range h {
|
||||
if handler.Enabled(ctx, record.Level) {
|
||||
if err := handler.Handle(ctx, record.Clone()); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
func (h multiHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||
handlers := make(multiHandler, len(h))
|
||||
for i, handler := range h {
|
||||
handlers[i] = handler.WithAttrs(attrs)
|
||||
}
|
||||
return handlers
|
||||
}
|
||||
|
||||
func (h multiHandler) WithGroup(name string) slog.Handler {
|
||||
handlers := make(multiHandler, len(h))
|
||||
for i, handler := range h {
|
||||
handlers[i] = handler.WithGroup(name)
|
||||
}
|
||||
return handlers
|
||||
}
|
||||
+4
-1
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"log"
|
||||
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/seriousm4x/upsnap/pb"
|
||||
@@ -12,5 +13,7 @@ var distDir embed.FS
|
||||
var distDirFS = apis.MustSubFS(distDir, "pb_public")
|
||||
|
||||
func main() {
|
||||
pb.StartPocketBase(distDirFS)
|
||||
if err := pb.StartPocketBase(distDirFS); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "1si6ajha",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "ip",
|
||||
"pattern": "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"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
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "1si6ajha",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "ip",
|
||||
"pattern": "^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "s8c5z7n0",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "netmask",
|
||||
"pattern": "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"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
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "s8c5z7n0",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "netmask",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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(6, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "bool2618032555",
|
||||
"name": "track_ip",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "bool"
|
||||
}`)); 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("bool2618032555")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text3846109882",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "track_ip_interval",
|
||||
"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("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove field
|
||||
collection.Fields.RemoveById("text3846109882")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
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
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "1si6ajha",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "ip",
|
||||
"pattern": "^(?:(?:[\\p{L}\\p{N}](?:[\\p{L}\\p{N}-]{0,61}[\\p{L}\\p{N}])?\\.)+[\\p{L}\\p{N}](?:[\\p{L}\\p{N}-]{0,61}[\\p{L}\\p{N}])?|(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "s8c5z7n0",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "netmask",
|
||||
"pattern": "^(?:255\\.255\\.255\\.(?:255|254|252|248|240|224|192|128|0)|255\\.255\\.(?:255|254|252|248|240|224|192|128|0)\\.0|255\\.(?:255|254|252|248|240|224|192|128|0)\\.0\\.0|(?:255|254|252|248|240|224|192|128|0)\\.0\\.0\\.0)$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"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
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "1si6ajha",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "ip",
|
||||
"pattern": "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(4, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"help": "",
|
||||
"hidden": false,
|
||||
"id": "s8c5z7n0",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "netmask",
|
||||
"pattern": "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -10,7 +10,10 @@ import (
|
||||
)
|
||||
|
||||
func SendMagicPacket(device *core.Record) error {
|
||||
ip := device.GetString("ip")
|
||||
ip, err := ResolveToIPAddr(device.GetString("ip"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mac := device.GetString("mac")
|
||||
netmask := device.GetString("netmask")
|
||||
password := device.GetString("password")
|
||||
@@ -20,24 +23,45 @@ func SendMagicPacket(device *core.Record) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !ValidateSubnetMask(netmask) {
|
||||
return fmt.Errorf("%q is not a valid subnet mask", netmask)
|
||||
}
|
||||
|
||||
// calculate broadcast IP, if possible
|
||||
var broadcastIp string
|
||||
// an IP was provided or FQDN resolved to an IP so calculate broadcast destination based on that
|
||||
if ip != "" {
|
||||
broadcastIp, err = getBroadcastIp(ip, netmask)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// No IP available, so no broadcast IP can be calculated. This occurs if FQDN is .local and the device is powered off
|
||||
broadcastIp = ""
|
||||
}
|
||||
|
||||
var bytePassword []byte
|
||||
if len(password) == 0 || len(password) == 4 || len(password) == 6 {
|
||||
bytePassword = []byte(password)
|
||||
} else {
|
||||
return fmt.Errorf("error: password must be 0, 4 or 6 characters long")
|
||||
return errors.New("error: password must be 0, 4 or 6 characters long")
|
||||
}
|
||||
|
||||
// get target addr
|
||||
broadcastIp, err := getBroadcastIp(ip, netmask)
|
||||
if err != nil {
|
||||
return err
|
||||
// an IP was provided or FQDN resolved to an IP so calculate broadcast destination based on that
|
||||
if ip != "" {
|
||||
broadcastIp, err = getBroadcastIp(ip, netmask)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
// No IP available, so no broadcast IP can be calculated. This occurs if FQDN is .local and the device is powered off
|
||||
broadcastIp = ""
|
||||
}
|
||||
|
||||
// send wake via udp port 9
|
||||
// send wake
|
||||
if err := wakeUDP(broadcastIp, ip, parsedMac, bytePassword); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -48,50 +72,51 @@ func wakeUDP(broadcastIp string, deviceIp string, target net.HardwareAddr, passw
|
||||
}
|
||||
defer c.Close()
|
||||
|
||||
// send 6 magic packets to different addresses to enhance chance 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",
|
||||
// send direct to device via port 9 (for routed network WOL)
|
||||
fmt.Sprintf("%s:9", deviceIp),
|
||||
// send direct to device via alternative port 7 (for routed network WOL)
|
||||
fmt.Sprintf("%s:7", deviceIp),
|
||||
var destinations []string
|
||||
|
||||
// Broadcast IP available, add to destinations
|
||||
if broadcastIp != "" {
|
||||
// user-calculated broadcast packet to port 9 and alternative port 7
|
||||
destinations = append(destinations,
|
||||
fmt.Sprintf("%s:9", broadcastIp),
|
||||
fmt.Sprintf("%s:7", broadcastIp),
|
||||
)
|
||||
}
|
||||
|
||||
if deviceIp != "" {
|
||||
// For routed network WOL, send a unicast packet to device IP on port 9 and alternative port 7
|
||||
destinations = append(destinations,
|
||||
fmt.Sprintf("%s:9", deviceIp),
|
||||
fmt.Sprintf("%s:7", deviceIp),
|
||||
)
|
||||
}
|
||||
|
||||
// No IP for the device is available, broadcast WOL packet to all interfaces
|
||||
if deviceIp == "" {
|
||||
allBroadcastDests, err := getAllBroadcastDests()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
destinations = append(destinations, allBroadcastDests...)
|
||||
}
|
||||
for _, dest := range destinations {
|
||||
if err := c.WakePassword(dest, target, password); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getBroadcastIp(ipStr, maskStr string) (string, error) {
|
||||
ip := net.ParseIP(ipStr)
|
||||
if ip == nil {
|
||||
return "", errors.New("ip not a valid ipv4 address")
|
||||
}
|
||||
ip = ip.To4()
|
||||
ip := net.ParseIP(ipStr).To4()
|
||||
if ip == nil {
|
||||
return "", errors.New("ip not a valid ipv4 address")
|
||||
}
|
||||
|
||||
mask := net.ParseIP(maskStr)
|
||||
mask := net.ParseIP(maskStr).To4()
|
||||
if mask == nil {
|
||||
return "", errors.New("subnet mask not a valid ipv4 address")
|
||||
}
|
||||
mask = mask.To4()
|
||||
ip = ip.To4()
|
||||
if ip == nil {
|
||||
return "", errors.New("subnet mask not a valid ipv4 address")
|
||||
}
|
||||
|
||||
broadcast := make(net.IP, 4)
|
||||
for i := range ip {
|
||||
@@ -100,3 +125,42 @@ func getBroadcastIp(ipStr, maskStr string) (string, error) {
|
||||
|
||||
return broadcast.String(), nil
|
||||
}
|
||||
|
||||
// Returns a slice of all broadcast addresses for ports 9 and 7 using local interfaces
|
||||
func getAllBroadcastDests() ([]string, error) {
|
||||
var allIps []string
|
||||
interfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Iterate through all the interfaces
|
||||
for _, iface := range interfaces {
|
||||
isRunning := iface.Flags&net.FlagRunning != 0
|
||||
isLoopback := iface.Flags&net.FlagLoopback != 0
|
||||
isNotBroadcast := iface.Flags&net.FlagBroadcast == 0
|
||||
// exclude interfaces that are not running, are loopback, or can't broadcast
|
||||
if !isRunning || isLoopback || isNotBroadcast {
|
||||
continue
|
||||
}
|
||||
addrs, err := iface.Addrs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Iterate through each interface's address
|
||||
for _, addr := range addrs {
|
||||
if ipNet, ok := addr.(*net.IPNet); ok {
|
||||
ip := ipNet.IP
|
||||
// Only use IPv4
|
||||
if ip.To4() != nil {
|
||||
bcastip, err := getBroadcastIp(ip.String(), net.IP(ipNet.Mask).String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
allIps = append(allIps, fmt.Sprintf("%s:9", bcastip), fmt.Sprintf("%s:7", bcastip))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return allIps, nil
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ func CheckPort(host string, port string) (bool, error) {
|
||||
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 netErr, ok := errors.AsType[*net.OpError](err); ok {
|
||||
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) ||
|
||||
errors.Is(netErr.Err, syscall.ECONNREFUSED) ||
|
||||
netErr.Timeout() {
|
||||
|
||||
@@ -17,7 +17,14 @@ import (
|
||||
func PingDevice(device *core.Record) (bool, error) {
|
||||
ping_cmd := device.GetString("ping_cmd")
|
||||
if ping_cmd == "" {
|
||||
pinger, err := probing.NewPinger(device.GetString("ip"))
|
||||
ip, err := ResolveToIPAddr(device.GetString("ip"))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if ip == "" {
|
||||
return false, nil
|
||||
}
|
||||
pinger, err := probing.NewPinger(ip)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -16,7 +16,11 @@ import (
|
||||
func PingDevice(device *core.Record) (bool, error) {
|
||||
ping_cmd := device.GetString("ping_cmd")
|
||||
if ping_cmd == "" {
|
||||
pinger, err := probing.NewPinger(device.GetString("ip"))
|
||||
ip, err := ResolveToIPAddr(device.GetString("ip"))
|
||||
if err != nil || ip == "" {
|
||||
return false, err
|
||||
}
|
||||
pinger, err := probing.NewPinger(ip)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
//go:build windows || darwin
|
||||
|
||||
package networking
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
Takes one parameter 'host' and returns its IP. If 'host' is already formatted
|
||||
as an IP, simply return it. If 'host' is formatted as an FQDN, attempt to
|
||||
resolve it with mDNS (if .local suffix) or else use a DNS lookup with
|
||||
net.DefaultResolver
|
||||
|
||||
Windows and MacOS can resolve mDNS/DNS with one call to net.DefaultResolver
|
||||
*/
|
||||
func ResolveToIPAddr(host string) (string, error) {
|
||||
// If host is already an IP, simply return it
|
||||
addr, err := netip.ParseAddr(host)
|
||||
if err == nil && addr.Is4() {
|
||||
return host, nil
|
||||
}
|
||||
if err := ValidateFQDN(host); err != nil {
|
||||
return "", fmt.Errorf("%q is the host", host)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
ips, err := net.DefaultResolver.LookupNetIP(ctx, "ip4", host)
|
||||
if err != nil {
|
||||
if strings.HasSuffix(strings.ToLower(host), ".local") {
|
||||
var dnsErr *net.DNSError
|
||||
isNotFound := errors.As(err, &dnsErr) && dnsErr.IsNotFound
|
||||
isTimeout := errors.Is(err, context.DeadlineExceeded) || ctx.Err() == context.DeadlineExceeded
|
||||
if isTimeout || isNotFound {
|
||||
return "", nil
|
||||
}
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
if len(ips) > 0 {
|
||||
// only return one result
|
||||
return ips[0].String(), nil
|
||||
}
|
||||
// No results, but it's expected for a .local FQDN device that is offline. Don't return an error.
|
||||
if strings.HasSuffix(strings.ToLower(host), ".local") {
|
||||
return "", nil
|
||||
} else {
|
||||
// No results, but FQDN should have resolved since it's not .local. Return an error.
|
||||
return "", fmt.Errorf("No IP address found for %s", host)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
//go:build linux || freebsd
|
||||
|
||||
package networking
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
"github.com/holoplot/go-avahi"
|
||||
)
|
||||
|
||||
var (
|
||||
avahiServer *avahi.Server
|
||||
avahiErr error
|
||||
avahiOnce sync.Once
|
||||
)
|
||||
|
||||
// getAvahiServer initializes and returns a shared, long-lived Avahi client.
|
||||
// It handles high throughput gracefully by using a single D-Bus socket connection.
|
||||
func getAvahiServer() (*avahi.Server, error) {
|
||||
avahiOnce.Do(func() {
|
||||
// Using the cached system bus here is safe because we never call server.Close() on it.
|
||||
conn, err := dbus.SystemBus()
|
||||
if err != nil {
|
||||
avahiErr = fmt.Errorf("failed to connect to dbus: %w", err)
|
||||
return
|
||||
}
|
||||
server, err := avahi.ServerNew(conn)
|
||||
if err != nil {
|
||||
avahiErr = fmt.Errorf("failed to create avahi server: %w", err)
|
||||
return
|
||||
}
|
||||
avahiServer = server
|
||||
})
|
||||
return avahiServer, avahiErr
|
||||
}
|
||||
|
||||
/*
|
||||
Takes one parameter 'host' and returns its IP. If 'host' is already formatted
|
||||
as an IP, simply return it. If 'host' is formatted as an FQDN, attempt to
|
||||
resolve it with mDNS (if .local suffix) or else use a DNS lookup with
|
||||
net.DefaultResolver
|
||||
|
||||
Linux and FreeBSD require dbus and avahi for mDNS lookups
|
||||
*/
|
||||
func ResolveToIPAddr(host string) (string, error) {
|
||||
// If host is already an IP, simply return it
|
||||
addr, err := netip.ParseAddr(host)
|
||||
if err == nil && addr.Is4() {
|
||||
return host, nil
|
||||
}
|
||||
if err := ValidateFQDN(host); err != nil {
|
||||
return "", err
|
||||
}
|
||||
// attempt mDNS query first
|
||||
if strings.HasSuffix(strings.ToLower(host), ".local") {
|
||||
// conn, err := dbus.Dial("unix:path=/var/run/dbus/system_bus_socket")
|
||||
server, err := getAvahiServer()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to create connection: %w", err)
|
||||
}
|
||||
// defer conn.Close()
|
||||
|
||||
// server, err := avahi.ServerNew(conn)
|
||||
// if err != nil {
|
||||
// return "", fmt.Errorf("Failed to create avahi server: %w", err)
|
||||
// }
|
||||
// defer server.Close()
|
||||
|
||||
// set a context with 2 secs and only wait that long for an mDNS response. otherwise, avahi takes 5 secs
|
||||
ctx1, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
|
||||
type result struct {
|
||||
address string
|
||||
err error
|
||||
}
|
||||
ch := make(chan result, 1)
|
||||
|
||||
go func() {
|
||||
resolved, err := server.ResolveHostName(
|
||||
avahi.InterfaceUnspec,
|
||||
avahi.ProtoInet,
|
||||
host,
|
||||
avahi.ProtoInet,
|
||||
0,
|
||||
)
|
||||
if err != nil {
|
||||
ch <- result{"", err}
|
||||
return
|
||||
}
|
||||
// mDNS result received
|
||||
ch <- result{resolved.Address, nil}
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-ctx1.Done():
|
||||
// 2 second timeout reached,
|
||||
return "", nil
|
||||
|
||||
case res := <-ch:
|
||||
if res.err != nil {
|
||||
var dbusErr *dbus.Error
|
||||
// in theory we shouldn't encounter this error since the 2 second context always beats the race
|
||||
if errors.As(res.err, &dbusErr) && dbusErr.Name == "org.freedesktop.Avahi.TimeoutError" {
|
||||
return "", nil
|
||||
}
|
||||
return "", fmt.Errorf("%s: %w", host, res.err)
|
||||
}
|
||||
return res.address, nil
|
||||
}
|
||||
}
|
||||
// Not .local, attempt unicast (regular) DNS lookup
|
||||
ctx2, cancel2 := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel2()
|
||||
ips, err := net.DefaultResolver.LookupNetIP(ctx2, "ip4", host)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(ips) > 0 {
|
||||
// only return one result
|
||||
return ips[0].String(), nil
|
||||
}
|
||||
// No results, but FQDN should have resolved since it's not .local. Return an error.
|
||||
return "", err
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type Nmaprun struct {
|
||||
Host []struct {
|
||||
Address []struct {
|
||||
Addr string `xml:"addr,attr" binding:"required"`
|
||||
Addrtype string `xml:"addrtype,attr" binding:"required"`
|
||||
Vendor string `xml:"vendor,attr"`
|
||||
} `xml:"address"`
|
||||
} `xml:"host"`
|
||||
}
|
||||
|
||||
// MacToIP maps each scanned host's normalized mac address to its ipv4
|
||||
// address, skipping hosts that lack either.
|
||||
func (n Nmaprun) MacToIP() map[string]string {
|
||||
macToIp := make(map[string]string)
|
||||
for _, host := range n.Host {
|
||||
var hostIp, hostMac string
|
||||
for _, addr := range host.Address {
|
||||
switch addr.Addrtype {
|
||||
case "ipv4":
|
||||
hostIp = addr.Addr
|
||||
case "mac":
|
||||
hostMac = addr.Addr
|
||||
}
|
||||
}
|
||||
if parsedMac, err := net.ParseMAC(hostMac); hostIp != "" && err == nil {
|
||||
macToIp[parsedMac.String()] = hostIp
|
||||
}
|
||||
}
|
||||
return macToIp
|
||||
}
|
||||
|
||||
func runNmap(scanRange string) (Nmaprun, error) {
|
||||
nmapOutput := Nmaprun{}
|
||||
|
||||
nmap, err := exec.LookPath("nmap")
|
||||
if err != nil {
|
||||
return nmapOutput, err
|
||||
}
|
||||
|
||||
timeout := os.Getenv("UPSNAP_SCAN_TIMEOUT")
|
||||
if timeout == "" {
|
||||
timeout = "500ms"
|
||||
}
|
||||
|
||||
cmd := exec.Command(nmap, "-sn", "-oX", "-", scanRange, "--host-timeout", timeout, "--privileged")
|
||||
cmdOutput, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nmapOutput, err
|
||||
}
|
||||
|
||||
if err := xml.Unmarshal(cmdOutput, &nmapOutput); err != nil {
|
||||
return nmapOutput, err
|
||||
}
|
||||
|
||||
return nmapOutput, nil
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//go:build linux
|
||||
|
||||
package networking
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"kernel.org/pub/linux/libs/security/libcap/cap"
|
||||
)
|
||||
|
||||
func NmapScan(scanRange string) (Nmaprun, error) {
|
||||
orig := cap.GetProc()
|
||||
defer orig.SetProc() // restore original caps on exit.
|
||||
|
||||
c, err := orig.Dup()
|
||||
if err != nil {
|
||||
return Nmaprun{}, fmt.Errorf("Failed to dup existing capabilities: %v", err)
|
||||
}
|
||||
|
||||
if on, _ := c.GetFlag(cap.Permitted, cap.NET_RAW); !on {
|
||||
return Nmaprun{}, fmt.Errorf("unable to get NET_RAW permissions")
|
||||
}
|
||||
|
||||
if err := c.SetFlag(cap.Effective, true, cap.NET_RAW); err != nil {
|
||||
return Nmaprun{}, fmt.Errorf("unable to set NET_RAW capability effective")
|
||||
}
|
||||
|
||||
if err := c.SetFlag(cap.Inheritable, true, cap.NET_RAW); err != nil {
|
||||
return Nmaprun{}, fmt.Errorf("unable to set NET_RAW capability inheritable")
|
||||
}
|
||||
|
||||
if err := c.SetProc(); err != nil {
|
||||
return Nmaprun{}, fmt.Errorf("unable to raise NET_RAW capability")
|
||||
}
|
||||
|
||||
if err := cap.SetAmbient(true, cap.NET_RAW); err != nil {
|
||||
return Nmaprun{}, fmt.Errorf("unable to set NET_RAW capability ambient")
|
||||
}
|
||||
|
||||
return runNmap(scanRange)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//go:build !linux
|
||||
|
||||
package networking
|
||||
|
||||
func NmapScan(scanRange string) (Nmaprun, error) {
|
||||
return runNmap(scanRange)
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Trimmed from real `nmap -sn -oX -` output: one host with a mac (scanned
|
||||
// with raw socket privileges), one without (the scanning host itself).
|
||||
const nmapSample = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<nmaprun scanner="nmap" args="nmap -sn -oX - 10.1.10.0/24" version="7.94">
|
||||
<host><status state="up" reason="arp-response"/>
|
||||
<address addr="10.1.10.1" addrtype="ipv4"/>
|
||||
<address addr="AA:BB:CC:DD:EE:FF" addrtype="mac" vendor="Ubiquiti Networks"/>
|
||||
<hostnames></hostnames>
|
||||
</host>
|
||||
<host><status state="up" reason="localhost-response"/>
|
||||
<address addr="10.1.10.9" addrtype="ipv4"/>
|
||||
<hostnames></hostnames>
|
||||
</host>
|
||||
<runstats><finished time="1754000000" exit="success"/></runstats>
|
||||
</nmaprun>`
|
||||
|
||||
func TestNmaprunUnmarshal(t *testing.T) {
|
||||
nmapOutput := Nmaprun{}
|
||||
if err := xml.Unmarshal([]byte(nmapSample), &nmapOutput); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
if len(nmapOutput.Host) != 2 {
|
||||
t.Fatalf("Host count mismatch: expected 2, got %d", len(nmapOutput.Host))
|
||||
}
|
||||
|
||||
first := nmapOutput.Host[0].Address
|
||||
if len(first) != 2 {
|
||||
t.Fatalf("Address count mismatch: expected 2, got %d", len(first))
|
||||
}
|
||||
if first[0].Addrtype != "ipv4" || first[0].Addr != "10.1.10.1" {
|
||||
t.Errorf("Unexpected ipv4 address: %+v", first[0])
|
||||
}
|
||||
if first[1].Addrtype != "mac" || first[1].Addr != "AA:BB:CC:DD:EE:FF" || first[1].Vendor != "Ubiquiti Networks" {
|
||||
t.Errorf("Unexpected mac address: %+v", first[1])
|
||||
}
|
||||
|
||||
second := nmapOutput.Host[1].Address
|
||||
if len(second) != 1 || second[0].Addrtype != "ipv4" {
|
||||
t.Errorf("Unexpected addresses for mac-less host: %+v", second)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNmaprunMacToIP(t *testing.T) {
|
||||
nmapOutput := Nmaprun{}
|
||||
if err := xml.Unmarshal([]byte(nmapSample), &nmapOutput); err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
macToIp := nmapOutput.MacToIP()
|
||||
if len(macToIp) != 1 {
|
||||
t.Fatalf("Entry count mismatch: expected 1, got %d", len(macToIp))
|
||||
}
|
||||
// the mac address is normalized to lower case, the mac-less host is skipped
|
||||
if ip := macToIp["aa:bb:cc:dd:ee:ff"]; ip != "10.1.10.1" {
|
||||
t.Errorf("Unexpected ip for aa:bb:cc:dd:ee:ff: %q", ip)
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,15 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
)
|
||||
|
||||
func ShutdownDevice(device *core.Record) error {
|
||||
logger.Info.Println("Shutdown triggered for", device.GetString("name"))
|
||||
func ShutdownDevice(app core.App, device *core.Record, trigger string) error {
|
||||
log := logging.Logger(app)
|
||||
log.Info("Shutdown triggered", "device", device.GetString("name"), "trigger", trigger)
|
||||
shutdown_cmd := device.GetString("shutdown_cmd")
|
||||
if shutdown_cmd == "" {
|
||||
return fmt.Errorf("%s: no shutdown_cmd definded", device.GetString("name"))
|
||||
return fmt.Errorf("%s: no shutdown_cmd defined", device.GetString("name"))
|
||||
}
|
||||
|
||||
var shell string
|
||||
@@ -31,18 +32,19 @@ func ShutdownDevice(device *core.Record) error {
|
||||
shell_arg = "-c"
|
||||
}
|
||||
|
||||
// Validate IP and MAC addresses before replacing placeholders to prevent command injection
|
||||
deviceIP := device.GetString("ip")
|
||||
if net.ParseIP(deviceIP) == nil {
|
||||
return fmt.Errorf("invalid device IP address: %q", deviceIP)
|
||||
// Validate IP or resolve FQDN to IP
|
||||
deviceIP, err := ResolveToIPAddr(device.GetString("ip"))
|
||||
if err != nil || deviceIP == "" {
|
||||
return fmt.Errorf("Unable to resolve %s to an IP address", device.GetString("ip"))
|
||||
}
|
||||
// Validate MAC address before replacing placeholder to prevent command injection
|
||||
deviceMAC := device.GetString("mac")
|
||||
if _, err := net.ParseMAC(deviceMAC); err != nil {
|
||||
return fmt.Errorf("invalid device MAC address: %q", deviceMAC)
|
||||
}
|
||||
|
||||
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_IP }}", device.GetString("ip"))
|
||||
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_MAC }}", device.GetString("mac"))
|
||||
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_IP }}", deviceIP)
|
||||
shutdown_cmd = strings.ReplaceAll(shutdown_cmd, "{{ DEVICE_MAC }}", deviceMAC)
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
@@ -79,7 +81,7 @@ func ShutdownDevice(device *core.Record) error {
|
||||
for {
|
||||
isOnline, err := PingDevice(device)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to ping device during shutdown", "error", err)
|
||||
return err
|
||||
}
|
||||
if isOnline {
|
||||
@@ -96,18 +98,18 @@ func ShutdownDevice(device *core.Record) error {
|
||||
default:
|
||||
isOnline, err := PingDevice(device)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to ping device during shutdown", "error", err)
|
||||
return err
|
||||
}
|
||||
if time.Since(start) >= time.Duration(shutdownTimeout)*time.Second {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := KillProcess(app, cmd.Process); err != nil {
|
||||
log.Error("Failed to kill shutdown command", "error", err)
|
||||
}
|
||||
return fmt.Errorf("%s not offline after %d seconds", device.GetString("name"), shutdownTimeout)
|
||||
}
|
||||
if !isOnline {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := KillProcess(app, cmd.Process); err != nil {
|
||||
log.Error("Failed to kill shutdown command", "error", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -16,8 +17,8 @@ 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.")
|
||||
func KillProcess(app core.App, process *os.Process) error {
|
||||
logging.Logger(app).Warn("Command did not finish in time and will be killed")
|
||||
pgid, err := unix.Getpgid(process.Pid)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
@@ -13,6 +15,6 @@ import (
|
||||
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 {
|
||||
func KillProcess(_ core.App, process *os.Process) error {
|
||||
return windows.GenerateConsoleCtrlEvent(windows.CTRL_BREAK_EVENT, uint32(process.Pid))
|
||||
}
|
||||
|
||||
@@ -8,24 +8,28 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
)
|
||||
|
||||
type SolResponse struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func SleepDevice(device *core.Record) (SolResponse, error) {
|
||||
logger.Info.Println("Sleep triggered for", device.GetString("name"))
|
||||
func SleepDevice(app core.App, device *core.Record) (SolResponse, error) {
|
||||
logging.Logger(app).Info("Sleep triggered", "device", device.GetString("name"))
|
||||
|
||||
var solResp SolResponse
|
||||
var url string
|
||||
|
||||
deviceIP, err := ResolveToIPAddr(device.GetString("ip"))
|
||||
if err != nil || deviceIP == "" {
|
||||
return solResp, fmt.Errorf("Unable to resolve %s to an IP address: %w", device.GetString("ip"), err)
|
||||
}
|
||||
if device.GetBool("sol_auth") {
|
||||
url = fmt.Sprintf("http://%s:%s@%s:%d/sleep?format=JSON",
|
||||
device.GetString("sol_user"), device.GetString("sol_password"), device.GetString("ip"), device.GetInt("sol_port"))
|
||||
device.GetString("sol_user"), device.GetString("sol_password"), deviceIP, device.GetInt("sol_port"))
|
||||
} else {
|
||||
url = fmt.Sprintf("http://%s:%d/sleep?format=JSON", device.GetString("ip"), device.GetInt("sol_port"))
|
||||
url = fmt.Sprintf("http://%s:%d/sleep?format=JSON", deviceIP, device.GetInt("sol_port"))
|
||||
}
|
||||
|
||||
resp, err := http.Get(url)
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
// DeviceSubnet returns the device's IPv4 subnet computed from its ip and netmask.
|
||||
func DeviceSubnet(ipStr, maskStr string) (*net.IPNet, error) {
|
||||
ip := net.ParseIP(ipStr)
|
||||
if ip == nil || ip.To4() == nil {
|
||||
return nil, errors.New("ip not a valid ipv4 address")
|
||||
}
|
||||
ip = ip.To4()
|
||||
|
||||
mask := net.ParseIP(maskStr)
|
||||
if mask == nil || mask.To4() == nil {
|
||||
return nil, errors.New("subnet mask not a valid ipv4 address")
|
||||
}
|
||||
ipMask := net.IPMask(mask.To4())
|
||||
|
||||
return &net.IPNet{IP: ip.Mask(ipMask), Mask: ipMask}, nil
|
||||
}
|
||||
|
||||
// ValidateScannableSubnet returns nil if the subnet is suitable for an nmap
|
||||
// scan, or an error explaining why it isn't.
|
||||
func ValidateScannableSubnet(subnet *net.IPNet) error {
|
||||
ones, bits := subnet.Mask.Size()
|
||||
if ones == 0 && bits == 0 {
|
||||
// Size() returns 0,0 for a non-contiguous mask, which has no cidr
|
||||
// notation to hand to nmap
|
||||
return errors.New("netmask is not contiguous")
|
||||
}
|
||||
if ones == bits {
|
||||
return errors.New("a single address has nothing to scan")
|
||||
}
|
||||
if ones < 16 {
|
||||
return errors.New("subnets larger than a /16 take too long to scan")
|
||||
}
|
||||
|
||||
// arp only answers on-link, so the subnet must overlap one of the
|
||||
// host's attached ipv4 networks for a scan to find mac addresses
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, addr := range addrs {
|
||||
attached, ok := addr.(*net.IPNet)
|
||||
if !ok || attached.IP.To4() == nil {
|
||||
continue
|
||||
}
|
||||
// subnets are either disjoint or nested, so checking containment
|
||||
// in both directions covers overlap
|
||||
if attached.Contains(subnet.IP) || subnet.Contains(attached.IP) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return errors.New("subnet does not overlap a directly attached network")
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDeviceSubnet(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip string
|
||||
netmask string
|
||||
wantCidr string
|
||||
wantError bool
|
||||
}{
|
||||
// Valid case: address is masked down to the network
|
||||
{
|
||||
name: "Valid Case",
|
||||
ip: "192.168.1.100",
|
||||
netmask: "255.255.255.0",
|
||||
wantCidr: "192.168.1.0/24",
|
||||
wantError: false,
|
||||
},
|
||||
// Valid case: wider mask
|
||||
{
|
||||
name: "Valid /16",
|
||||
ip: "10.1.10.142",
|
||||
netmask: "255.255.0.0",
|
||||
wantCidr: "10.1.0.0/16",
|
||||
wantError: false,
|
||||
},
|
||||
// Valid case: host mask
|
||||
{
|
||||
name: "Valid /32",
|
||||
ip: "192.168.1.5",
|
||||
netmask: "255.255.255.255",
|
||||
wantCidr: "192.168.1.5/32",
|
||||
wantError: false,
|
||||
},
|
||||
// Invalid IP address
|
||||
{
|
||||
name: "Invalid IP",
|
||||
ip: "256.1.1.1", // invalid
|
||||
netmask: "255.255.255.0",
|
||||
wantCidr: "",
|
||||
wantError: true,
|
||||
},
|
||||
// Invalid netmask
|
||||
{
|
||||
name: "Invalid Netmask",
|
||||
ip: "192.168.1.100",
|
||||
netmask: "300.255.255.0", // invalid
|
||||
wantCidr: "",
|
||||
wantError: true,
|
||||
},
|
||||
// IPv6 address is not a valid device ip
|
||||
{
|
||||
name: "IPv6 IP",
|
||||
ip: "fe80::1",
|
||||
netmask: "255.255.255.0",
|
||||
wantCidr: "",
|
||||
wantError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
subnet, err := DeviceSubnet(tc.ip, tc.netmask)
|
||||
if tc.wantError {
|
||||
if err == nil {
|
||||
t.Errorf("Expected error but got none")
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
t.Errorf("Got unexpected error: %v", err)
|
||||
} else if subnet.String() != tc.wantCidr {
|
||||
t.Errorf("Subnet mismatch: expected %s, got %s", tc.wantCidr, subnet.String())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScannableSubnet(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip string
|
||||
netmask string
|
||||
wantError bool
|
||||
}{
|
||||
// A /32 has nothing to scan
|
||||
{
|
||||
name: "Host Mask",
|
||||
ip: "192.168.1.5",
|
||||
netmask: "255.255.255.255",
|
||||
wantError: true,
|
||||
},
|
||||
// A non-contiguous mask has no cidr notation to scan
|
||||
{
|
||||
name: "Non-contiguous Mask",
|
||||
ip: "10.0.1.5",
|
||||
netmask: "255.0.255.0",
|
||||
wantError: true,
|
||||
},
|
||||
// Anything larger than a /16 takes too long to scan
|
||||
{
|
||||
name: "Too Large",
|
||||
ip: "10.0.0.1",
|
||||
netmask: "255.0.0.0",
|
||||
wantError: true,
|
||||
},
|
||||
// The loopback address as a /16 is within limits and always attached
|
||||
{
|
||||
name: "Local /16",
|
||||
ip: "127.0.0.1",
|
||||
netmask: "255.255.0.0",
|
||||
wantError: false,
|
||||
},
|
||||
// A sub-block of the attached loopback /8 is on-link even though
|
||||
// it doesn't contain the host's own 127.0.0.1
|
||||
{
|
||||
name: "Nested In Attached",
|
||||
ip: "127.0.1.5",
|
||||
netmask: "255.255.255.0",
|
||||
wantError: false,
|
||||
},
|
||||
// TEST-NET-1 (RFC 5737) is never assigned to an interface
|
||||
{
|
||||
name: "No Overlap",
|
||||
ip: "192.0.2.1",
|
||||
netmask: "255.255.255.0",
|
||||
wantError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
subnet, err := DeviceSubnet(tc.ip, tc.netmask)
|
||||
if err != nil {
|
||||
t.Fatalf("Got unexpected error: %v", err)
|
||||
}
|
||||
if err := ValidateScannableSubnet(subnet); (err != nil) != tc.wantError {
|
||||
t.Errorf("ValidateScannableSubnet(%s): expected error=%v, got %v", subnet.String(), tc.wantError, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/idna"
|
||||
)
|
||||
|
||||
var fqdnRegex = regexp.MustCompile(`^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9-]{2,63}$`)
|
||||
|
||||
/*
|
||||
Validate's FQDN by converting it to Punycode and checking it against several criteria
|
||||
*/
|
||||
func ValidateFQDN(host string) error {
|
||||
// Remove trailing . just in case, but DB and form validation should already prevent that
|
||||
trimmedHost := strings.TrimSuffix(host, ".")
|
||||
if len(trimmedHost) == 0 {
|
||||
return fmt.Errorf("%q: invalid length of 0. original %q", trimmedHost, host)
|
||||
}
|
||||
|
||||
// convert to punycode
|
||||
punycodeHost, err := idna.Lookup.ToASCII(trimmedHost)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%q: failed to convert to punycode - %w", trimmedHost, err)
|
||||
}
|
||||
|
||||
if len(punycodeHost) < 1 || len(punycodeHost) > 253 {
|
||||
return fmt.Errorf("%q -> %q: invalid length %d bytes. Must be 1-253 bytes (chars) after conversion.", trimmedHost, punycodeHost, len(punycodeHost))
|
||||
}
|
||||
|
||||
if !fqdnRegex.MatchString(punycodeHost) {
|
||||
return fmt.Errorf("%q -> %q: Failed validation.", trimmedHost, punycodeHost)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateSubnetMask(mask string) bool {
|
||||
addr, err := netip.ParseAddr(mask)
|
||||
if err != nil || !addr.Is4() {
|
||||
return false
|
||||
}
|
||||
|
||||
byteArray := addr.As4()
|
||||
maskInt := uint32(byteArray[0])<<24 | uint32(byteArray[1])<<16 | uint32(byteArray[2])<<8 | uint32(byteArray[3])
|
||||
inverted := ^maskInt
|
||||
return (inverted & (inverted + 1)) == 0
|
||||
}
|
||||
+19
-15
@@ -11,11 +11,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
)
|
||||
|
||||
func WakeDevice(device *core.Record) error {
|
||||
logger.Info.Println("Wake triggered for", device.GetString("name"))
|
||||
func WakeDevice(app core.App, device *core.Record, trigger string) error {
|
||||
log := logging.Logger(app)
|
||||
log.Info("Wake triggered", "device", device.GetString("name"), "trigger", trigger)
|
||||
|
||||
wakeTimeout := device.GetInt("wake_timeout")
|
||||
if wakeTimeout <= 0 {
|
||||
@@ -34,11 +35,14 @@ func WakeDevice(device *core.Record) error {
|
||||
shell_arg = "-c"
|
||||
}
|
||||
|
||||
// Validate IP and MAC addresses before replacing placeholders to prevent command injection
|
||||
deviceIP := device.GetString("ip")
|
||||
if net.ParseIP(deviceIP) == nil {
|
||||
return fmt.Errorf("invalid device IP address: %q", deviceIP)
|
||||
deviceIP, err := ResolveToIPAddr(device.GetString("ip"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if deviceIP == "" {
|
||||
deviceIP = device.GetString("ip")
|
||||
}
|
||||
// Validate MAC address before replacing placeholders to prevent command injection
|
||||
deviceMAC := device.GetString("mac")
|
||||
if _, err := net.ParseMAC(deviceMAC); err != nil {
|
||||
return fmt.Errorf("invalid device MAC address: %q", deviceMAC)
|
||||
@@ -57,7 +61,7 @@ func WakeDevice(device *core.Record) error {
|
||||
cmd.Stderr = &stderr
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to start wake command", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -73,20 +77,20 @@ func WakeDevice(device *core.Record) error {
|
||||
case <-time.After(1 * time.Second):
|
||||
if time.Since(start) >= time.Duration(wakeTimeout)*time.Second {
|
||||
if cmd.Process != nil {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := KillProcess(app, cmd.Process); err != nil {
|
||||
log.Error("Failed to kill wake command", "error", 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)
|
||||
log.Error("Failed to ping device after wake", "error", err)
|
||||
return err
|
||||
}
|
||||
if isOnline {
|
||||
if cmd.Process != nil {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
if err := KillProcess(app, cmd.Process); err != nil {
|
||||
// Process might have already finished
|
||||
}
|
||||
}
|
||||
@@ -95,8 +99,8 @@ func WakeDevice(device *core.Record) error {
|
||||
case err := <-done:
|
||||
if err != nil {
|
||||
if cmd.Process != nil {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := KillProcess(app, cmd.Process); err != nil {
|
||||
log.Error("Failed to kill wake command", "error", err)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("%s", stderr.String())
|
||||
@@ -115,7 +119,7 @@ func WakeDevice(device *core.Record) error {
|
||||
time.Sleep(1 * time.Second)
|
||||
isOnline, err := PingDevice(device)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
log.Error("Failed to ping device after wake", "error", err)
|
||||
return err
|
||||
}
|
||||
if isOnline {
|
||||
|
||||
+37
-37
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/tools/router"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
"github.com/seriousm4x/upsnap/networking"
|
||||
)
|
||||
|
||||
@@ -25,22 +25,22 @@ func HandlerWake(e *core.RequestEvent) error {
|
||||
|
||||
record.Set("status", "pending")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save pending device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
if err := asyncCall(e, func() *router.ApiError {
|
||||
if err := networking.WakeDevice(record); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := networking.WakeDevice(e.App, record, "manual"); err != nil {
|
||||
logging.Logger(e.App).Error("Failed to wake device", "device", record.GetString("name"), "error", err)
|
||||
record.Set("status", "offline")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", 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)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -59,23 +59,23 @@ func HandlerSleep(e *core.RequestEvent) error {
|
||||
|
||||
record.Set("status", "pending")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save pending device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
if err := asyncCall(e, func() *router.ApiError {
|
||||
resp, err := networking.SleepDevice(record)
|
||||
resp, err := networking.SleepDevice(e.App, record)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
logging.Logger(e.App).Error("Failed to sleep device", "device", record.GetString("name"), "error", err)
|
||||
record.Set("status", "online")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", 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)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -94,15 +94,15 @@ func HandlerReboot(e *core.RequestEvent) error {
|
||||
|
||||
record.Set("status", "pending")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save pending device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
if err := asyncCall(e, func() *router.ApiError {
|
||||
if err := networking.ShutdownDevice(record); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := networking.ShutdownDevice(e.App, record, "manual"); err != nil {
|
||||
logging.Logger(e.App).Error("Failed to shut down device for reboot", "device", record.GetString("name"), "error", err)
|
||||
record.Set("status", "online")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
return apis.NewBadRequestError(err.Error(), nil)
|
||||
}
|
||||
@@ -112,18 +112,18 @@ func HandlerReboot(e *core.RequestEvent) error {
|
||||
// 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)
|
||||
if err := networking.WakeDevice(e.App, record, "manual"); err != nil {
|
||||
logging.Logger(e.App).Error("Failed to wake device after reboot", "device", record.GetString("name"), "error", err)
|
||||
record.Set("status", "offline")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", 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)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -142,22 +142,22 @@ func HandlerShutdown(e *core.RequestEvent) error {
|
||||
|
||||
record.Set("status", "pending")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save pending device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
if err := asyncCall(e, func() *router.ApiError {
|
||||
if err := networking.ShutdownDevice(record); err != nil {
|
||||
logger.Error.Println(strings.ReplaceAll(err.Error(), "\n", ""))
|
||||
if err := networking.ShutdownDevice(e.App, record, "manual"); err != nil {
|
||||
logging.Logger(e.App).Error("Failed to shut down device", "device", record.GetString("name"), "error", strings.ReplaceAll(err.Error(), "\n", ""))
|
||||
record.Set("status", "online")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", 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)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -169,7 +169,7 @@ func HandlerShutdown(e *core.RequestEvent) error {
|
||||
}
|
||||
|
||||
func HandlerWakeGroup(e *core.RequestEvent) error {
|
||||
records, err := e.App.FindRecordsByFilter("devices", "groups.id = {:grpId} && status = 'offline'", "", 0, 0,
|
||||
records, err := e.App.FindRecordsByFilter("devices", "groups.id ?= {:grpId} && status = 'offline'", "", 0, 0,
|
||||
dbx.Params{"grpId": e.Request.PathValue("id")},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -180,21 +180,21 @@ func HandlerWakeGroup(e *core.RequestEvent) error {
|
||||
go func() {
|
||||
record.Set("status", "pending")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save pending device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
if err := networking.WakeDevice(record); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := networking.WakeDevice(e.App, record, "manual"); err != nil {
|
||||
logging.Logger(e.App).Error("Failed to wake device", "device", record.GetString("name"), "error", err)
|
||||
record.Set("status", "offline")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
record.Set("status", "online")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -203,7 +203,7 @@ func HandlerWakeGroup(e *core.RequestEvent) error {
|
||||
}
|
||||
|
||||
func HandlerShutdownGroup(e *core.RequestEvent) error {
|
||||
records, err := e.App.FindRecordsByFilter("devices", "groups.id = {:grpId} && status = 'online'", "", 0, 0,
|
||||
records, err := e.App.FindRecordsByFilter("devices", "groups.id ?= {:grpId} && status = 'online'", "", 0, 0,
|
||||
dbx.Params{"grpId": e.Request.PathValue("id")},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -214,21 +214,21 @@ func HandlerShutdownGroup(e *core.RequestEvent) error {
|
||||
go func() {
|
||||
record.Set("status", "pending")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save pending device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
|
||||
if err := networking.ShutdownDevice(record); err != nil {
|
||||
logger.Error.Println(err)
|
||||
if err := networking.ShutdownDevice(e.App, record, "manual"); err != nil {
|
||||
logging.Logger(e.App).Error("Failed to shut down device", "device", record.GetString("name"), "error", err)
|
||||
record.Set("status", "online")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
record.Set("status", "offline")
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
logging.Logger(e.App).Error("Failed to save device status", "device", record.GetString("name"), "error", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func HandlerValidateCron(e *core.RequestEvent) error {
|
||||
var body ValidateCronRequest
|
||||
|
||||
if err := e.BindBody(&body); err != nil {
|
||||
logger.Error.Println(err)
|
||||
logging.Logger(e.App).Error("Failed to bind cron validation request", "error", err)
|
||||
return e.BadRequestError("invalid request", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,16 @@ import (
|
||||
"github.com/pocketbase/pocketbase/tools/hook"
|
||||
)
|
||||
|
||||
// SkipSuccessfulHealthCheckLog prevents routine Docker health checks from being
|
||||
// persisted while retaining failed health checks for diagnostics.
|
||||
func SkipSuccessfulHealthCheckLog(e *core.RequestEvent) error {
|
||||
if e.Request.URL.Path == "/api/health" {
|
||||
return apis.SkipSuccessActivityLog().Func(e)
|
||||
}
|
||||
|
||||
return e.Next()
|
||||
}
|
||||
|
||||
func RequireScanDevicesPermission() *hook.Handler[*core.RequestEvent] {
|
||||
return &hook.Handler[*core.RequestEvent]{
|
||||
Func: func(e *core.RequestEvent) error {
|
||||
|
||||
+110
-25
@@ -5,7 +5,9 @@ import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
@@ -13,20 +15,26 @@ import (
|
||||
"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/iptracking"
|
||||
"github.com/seriousm4x/upsnap/logging"
|
||||
_ "github.com/seriousm4x/upsnap/migrations"
|
||||
"github.com/seriousm4x/upsnap/networking"
|
||||
)
|
||||
|
||||
var Version = "(untracked)"
|
||||
|
||||
func StartPocketBase(distDirFS fs.FS) {
|
||||
func StartPocketBase(distDirFS fs.FS) error {
|
||||
if err := logging.ConfigureConsole(os.Getenv("UPSNAP_LOG_LEVEL")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// set data dir
|
||||
// use "./pb_data" if it's in the same dir as upsnap binary
|
||||
// else use os.UserConfigDir() / upsnap
|
||||
var dataDir string
|
||||
baseDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
return err
|
||||
}
|
||||
pb_data := path.Join(baseDir, "pb_data")
|
||||
if _, err = os.Stat(pb_data); err == nil {
|
||||
@@ -34,14 +42,14 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
} else if os.IsNotExist(err) {
|
||||
userConfigDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
return err
|
||||
}
|
||||
upsnap_data := path.Join(userConfigDir, "upsnap")
|
||||
if _, err = os.Stat(upsnap_data); err == nil {
|
||||
dataDir = upsnap_data
|
||||
} else if os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(upsnap_data, 0700); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +75,7 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
|
||||
// event hooks
|
||||
app.OnServe().BindFunc(func(se *core.ServeEvent) error {
|
||||
se.Router.BindFunc(SkipSuccessfulHealthCheckLog)
|
||||
se.Router.GET("/{path...}", apis.Static(distDirFS, true))
|
||||
se.Router.GET("/api/upsnap/wake/{id}", HandlerWake).Bind(RequireUpSnapPermission())
|
||||
se.Router.GET("/api/upsnap/wakegroup/{id}", HandlerWakeGroup).Bind(RequireUpSnapPermission())
|
||||
@@ -138,14 +147,14 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
return se.Next()
|
||||
})
|
||||
|
||||
app.OnModelAfterCreateSuccess().BindFunc(func(e *core.ModelEvent) error {
|
||||
app.OnModelAfterCreateSuccess("_superusers", "devices").BindFunc(func(e *core.ModelEvent) error {
|
||||
if e.Model.TableName() == "_superusers" {
|
||||
// when pocketbase creates it's default superuser, do not trigger setSetupCompleted()
|
||||
if e.Model.(*core.Record).Email() == core.DefaultInstallerEmail {
|
||||
return e.Next()
|
||||
}
|
||||
if err := setSetupCompleted(e.App); err != nil {
|
||||
logger.Error.Println(err)
|
||||
logging.Logger(e.App).Error("Failed to update setup state", "error", err)
|
||||
return err
|
||||
}
|
||||
return e.Next()
|
||||
@@ -158,7 +167,7 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
permissionRec, err := app.FindFirstRecordByFilter("permissions",
|
||||
fmt.Sprintf("user.id = '%s'", userId))
|
||||
if err != nil && err.Error() != "sql: no rows in result set" {
|
||||
logger.Error.Println(err)
|
||||
logging.Logger(e.App).Error("Failed to load permissions for new device", "error", err)
|
||||
return err
|
||||
} else if permissionRec != nil {
|
||||
permissionRec.Set("read", append(permissionRec.GetStringSlice("read"), deviceRec.Id))
|
||||
@@ -166,7 +175,7 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
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 {
|
||||
logger.Error.Println(err)
|
||||
logging.Logger(e.App).Error("Failed to grant permissions for new device", "error", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -174,18 +183,95 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
app.OnModelAfterDeleteSuccess().BindFunc(func(e *core.ModelEvent) error {
|
||||
if e.Model.TableName() == "_superusers" {
|
||||
if err := setSetupCompleted(e.App); err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
app.OnModelAfterDeleteSuccess("_superusers").BindFunc(func(e *core.ModelEvent) error {
|
||||
if err := setSetupCompleted(e.App); err != nil {
|
||||
logging.Logger(e.App).Error("Failed to update setup state", "error", err)
|
||||
return err
|
||||
}
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
app.OnRecordValidate("devices").BindFunc(func(e *core.RecordEvent) error {
|
||||
if !networking.ValidateSubnetMask(e.Record.GetString("netmask")) {
|
||||
logging.Logger(e.App).Warn("Device has invalid netmask; using broadcast default", "device", e.Record.GetString("name"), "netmask", "255.255.255.255")
|
||||
e.Record.Set("netmask", "255.255.255.255")
|
||||
saveErr := e.App.Save(e.Record)
|
||||
if saveErr != nil {
|
||||
return saveErr
|
||||
}
|
||||
}
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
app.OnRealtimeConnectRequest().BindFunc(func(e *core.RealtimeConnectRequestEvent) error {
|
||||
// a client just became active: catch up on any tracking sweep that
|
||||
// was skipped while nobody was connected
|
||||
settings, err := e.App.FindFirstRecordByFilter("settings_private", "")
|
||||
if err != nil {
|
||||
logging.Logger(e.App).Error("Failed to load private settings on realtime connection", "error", err)
|
||||
} else if settings.GetBool("lazy_ping") && settings.GetString("track_ip_interval") != "" {
|
||||
go iptracking.CatchUpSweep(e.App)
|
||||
}
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
app.OnRealtimeConnectRequest().BindFunc(func(e *core.RealtimeConnectRequestEvent) error {
|
||||
// PocketBase has no realtime disconnect hook. When a browser refreshes,
|
||||
// the old client may disappear before the new connection is registered.
|
||||
// Delay the offline transition and use the connecting client's id to
|
||||
// distinguish a refresh from a genuine disconnect.
|
||||
clientID := e.Client.Id()
|
||||
defer func() {
|
||||
// with lazy ping disabled the ping cron keeps updating device
|
||||
// statuses while no clients are connected, so there is nothing
|
||||
// to compensate for here
|
||||
settings, err := e.App.FindFirstRecordByFilter("settings_private", "")
|
||||
if err != nil {
|
||||
logging.Logger(e.App).Error("Failed to load private settings for offline transition", "error", err)
|
||||
return
|
||||
}
|
||||
if !settings.GetBool("lazy_ping") {
|
||||
return
|
||||
}
|
||||
if len(e.App.SubscriptionsBroker().Clients()) != 0 {
|
||||
return
|
||||
}
|
||||
time.AfterFunc(2*time.Second, func() {
|
||||
if _, err := e.App.SubscriptionsBroker().ClientById(clientID); err == nil {
|
||||
return
|
||||
}
|
||||
if len(e.App.SubscriptionsBroker().Clients()) != 0 {
|
||||
return
|
||||
}
|
||||
allDevices, err := app.FindAllRecords("devices", dbx.NewExp("shutdown_cmd != ''"))
|
||||
if err != nil {
|
||||
logging.Logger(app).Error("Failed to load devices for offline transition", "error", err)
|
||||
return
|
||||
}
|
||||
marked := 0
|
||||
for _, device := range allDevices {
|
||||
// leave devices that are already offline alone so the
|
||||
// "offline since" timestamp keeps its real meaning
|
||||
if device.GetString("status") == "offline" {
|
||||
continue
|
||||
}
|
||||
device.Set("status", "offline")
|
||||
if err := app.Save(device); err != nil {
|
||||
logging.Logger(app).Error("Failed to save offline device status", "device", device.GetString("name"), "error", err)
|
||||
return
|
||||
}
|
||||
marked++
|
||||
}
|
||||
if marked > 0 {
|
||||
logging.Logger(app).Info("Marked devices offline after the last client disconnected", "count", marked)
|
||||
}
|
||||
})
|
||||
}()
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
app.OnTerminate().BindFunc(func(e *core.TerminateEvent) error {
|
||||
cronjobs.StopAll()
|
||||
cronjobs.StopAll(e.App)
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
@@ -193,23 +279,24 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
httpListen := os.Getenv("UPSNAP_HTTP_LISTEN")
|
||||
if httpListen != "" {
|
||||
if err := app.Bootstrap(); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
return err
|
||||
}
|
||||
if err := apis.Serve(app, apis.ServeConfig{
|
||||
HttpAddr: httpListen,
|
||||
ShowStartBanner: true,
|
||||
}); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := app.Start(); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func importSettings(app *pocketbase.PocketBase) error {
|
||||
func importSettings(app core.App) error {
|
||||
settingsPrivateRecords, err := app.FindAllRecords("settings_private")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -255,12 +342,10 @@ func importSettings(app *pocketbase.PocketBase) error {
|
||||
if interval == "*/3 * * * *" || interval == "@every 3s" {
|
||||
settingsPrivate.Set("interval", defaultInterval)
|
||||
if e := app.Save(settingsPrivate); e != nil {
|
||||
logger.Error.Println(e)
|
||||
logging.Logger(app).Error("Failed to save default ping interval", "error", 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)
|
||||
logging.Logger(app).Error("Invalid ping interval; using default", "interval", interval, "default", defaultInterval)
|
||||
}
|
||||
interval = defaultInterval
|
||||
}
|
||||
@@ -281,14 +366,14 @@ func importSettings(app *pocketbase.PocketBase) error {
|
||||
return err
|
||||
}
|
||||
if err := setSetupCompleted(app); err != nil {
|
||||
logger.Error.Println(err)
|
||||
logging.Logger(app).Error("Failed to update setup state", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resetDeviceStates(app *pocketbase.PocketBase) error {
|
||||
func resetDeviceStates(app core.App) error {
|
||||
devices, err := app.FindAllRecords("devices")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
services:
|
||||
upsnap:
|
||||
cap_add:
|
||||
- NET_RAW # Required for privileged ping, network device scan, and IP address tracking (nmap)
|
||||
cap_drop:
|
||||
- ALL
|
||||
container_name: upsnap
|
||||
build:
|
||||
dockerfile: Dockerfile.dev
|
||||
@@ -7,6 +11,10 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/app/pb_data
|
||||
# # If you want to use FQDN instead of an IP and it is a ".local" domain, avahi and dbus must be installed on
|
||||
# # the host, and the host dbus must be mounted in the container.
|
||||
# # Before uncommmenting, ensure you are familiar with potential security implications of mounting dbus
|
||||
# - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro
|
||||
# # To use a non-root user, create the mountpoint first before starting
|
||||
# # the container (mkdir data) so that it has the right permissions.
|
||||
# user: 1000:1000
|
||||
@@ -14,6 +22,7 @@ services:
|
||||
# - 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_LOG_LEVEL=INFO # Console level for UpSnap logs: DEBUG, INFO, WARN, ERROR, or OFF
|
||||
# - 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
|
||||
|
||||
+7
-1
@@ -1,7 +1,7 @@
|
||||
services:
|
||||
upsnap:
|
||||
cap_add:
|
||||
- NET_RAW # NET_RAW is required for privileged ping and network device scan (nmap)
|
||||
- NET_RAW # NET_RAW is required for privileged ping, network device scan and ip address tracking (nmap)
|
||||
cap_drop:
|
||||
- ALL
|
||||
container_name: upsnap
|
||||
@@ -10,12 +10,18 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/app/pb_data
|
||||
# # If you want to use FQDN instead of an IP and it is a ".local" domain, avahi and dbus must be installed on
|
||||
# # the host, and the host dbus must be mounted in the container.
|
||||
# # Before uncommmenting, ensure you are familiar with potential security implications of mounting dbus
|
||||
# - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro
|
||||
|
||||
# # To use a non-root user, create the mountpoint first (mkdir data) so that it has the right permission.
|
||||
# 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_LOG_LEVEL=INFO # Console level for UpSnap logs: DEBUG, INFO, WARN, ERROR, or OFF
|
||||
# - 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 # Default is true. Set to false for unprivileged ping
|
||||
|
||||
+20
-20
@@ -15,29 +15,29 @@
|
||||
"machine-translate": "inlang machine translate --project project.inlang"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^2.1.0",
|
||||
"@eslint/compat": "^2.1.1",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@inlang/cli": "^3.1.14",
|
||||
"@inlang/paraglide-js": "2.18.1",
|
||||
"@inlang/cli": "^3.3.7",
|
||||
"@inlang/paraglide-js": "^2.25.3",
|
||||
"@sveltejs/adapter-static": "^3.0.10",
|
||||
"@sveltejs/kit": "^2.69.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
||||
"daisyui": "^5.6.10",
|
||||
"eslint": "^10.6.0",
|
||||
"@sveltejs/kit": "^2.70.3",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
||||
"daisyui": "^5.7.38",
|
||||
"eslint": "^10.10.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-svelte": "^3.20.0",
|
||||
"globals": "^17.7.0",
|
||||
"eslint-plugin-svelte": "^3.23.0",
|
||||
"globals": "^17.12.0",
|
||||
"husky": "^9.1.7",
|
||||
"prettier": "^3.9.4",
|
||||
"prettier": "^3.9.7",
|
||||
"prettier-plugin-svelte": "^4.1.1",
|
||||
"prettier-plugin-tailwindcss": "^0.8.0",
|
||||
"svelte": "^5.56.4",
|
||||
"svelte-check": "^4.7.1",
|
||||
"tailwindcss": "^4.3.2",
|
||||
"prettier-plugin-tailwindcss": "^0.8.1",
|
||||
"svelte": "^5.57.0",
|
||||
"svelte-check": "^4.7.6",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.62.1",
|
||||
"vite": "^8.1.3"
|
||||
"typescript-eslint": "^8.70.0",
|
||||
"vite": "^8.3.0"
|
||||
},
|
||||
"type": "module",
|
||||
"lint-staged": {
|
||||
@@ -45,11 +45,11 @@
|
||||
"*.{js,css,md,svelte,scss}": "prettier --write --cache --cache-strategy content --ignore-path ../.gitignore ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/free-solid-svg-icons": "^7.3.0",
|
||||
"@tailwindcss/vite": "^4.3.2",
|
||||
"cron-parser": "^5.6.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^7.3.1",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"cron-parser": "^5.10.1",
|
||||
"date-fns": "^4.4.0",
|
||||
"pocketbase": "^0.27.0",
|
||||
"pocketbase": "^0.28.1",
|
||||
"svelte-fa": "^4.0.4",
|
||||
"svelte-french-toast": "github:seriousm4x/svelte-french-toast#fix-72-build",
|
||||
"theme-change": "^2.5.2"
|
||||
|
||||
Generated
+1316
-611
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@
|
||||
import { nextCronDate, parseCron as validateCron } from '$lib/helpers/cron';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { permission, pocketbase } from '$lib/stores/pocketbase';
|
||||
import { settingsPriv } from '$lib/stores/settings';
|
||||
import type { Device, Group, Port } from '$lib/types/device';
|
||||
import { faSave, faTrash, faX } from '@fortawesome/free-solid-svg-icons';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -21,7 +22,25 @@
|
||||
await getGroups();
|
||||
});
|
||||
|
||||
const fqdnPattern =
|
||||
/^(?:[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?\.)+[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?$/u;
|
||||
const ipPattern =
|
||||
/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
|
||||
const macPattern = '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$';
|
||||
const netmaskPattern =
|
||||
'^(?:255\\.255\\.255\\.(?:255|254|252|248|240|224|192|128|0)|255\\.255\\.(?:255|254|252|248|240|224|192|128|0)\\.0|255\\.(?:255|254|252|248|240|224|192|128|0)\\.0\\.0|(?:255|254|252|248|240|224|192|128|0)\\.0\\.0\\.0)$';
|
||||
|
||||
$: if ($settingsPriv?.track_ip_interval === '' || !ipPattern.test(device.ip)) {
|
||||
device.track_ip = false;
|
||||
}
|
||||
|
||||
async function save() {
|
||||
// validate FQDN/IP
|
||||
if (!(ipPattern.test(device.ip) || fqdnPattern.test(device.ip))) {
|
||||
toast.error(m.settings_invalid_fqdnip());
|
||||
throw new Error('fqdn_ip not valid');
|
||||
}
|
||||
|
||||
// validate crons
|
||||
if (device.wake_cron_enabled && !(await validateCron(device.wake_cron))) {
|
||||
toast.error(m.settings_invalid_cron());
|
||||
@@ -225,7 +244,7 @@
|
||||
type="text"
|
||||
placeholder={m.device_general_ip()}
|
||||
class="input"
|
||||
pattern="^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b)\{4}$"
|
||||
maxlength="255"
|
||||
bind:value={device.ip}
|
||||
required
|
||||
/>
|
||||
@@ -238,7 +257,8 @@
|
||||
type="text"
|
||||
placeholder={m.device_general_mac()}
|
||||
class="input"
|
||||
pattern="^([0-9\A-Fa-f]{2}[:-]){5}([0-9\A-Fa-f]{2})$"
|
||||
maxlength="18"
|
||||
pattern={macPattern}
|
||||
bind:value={device.mac}
|
||||
required
|
||||
/>
|
||||
@@ -251,6 +271,8 @@
|
||||
type="text"
|
||||
placeholder={m.device_general_netmask()}
|
||||
class="input"
|
||||
maxlength="16"
|
||||
pattern={netmaskPattern}
|
||||
bind:value={device.netmask}
|
||||
required
|
||||
/>
|
||||
@@ -269,6 +291,19 @@
|
||||
</fieldset>
|
||||
<span class="badge text-error self-center">* {m.device_general_required_field()}</span>
|
||||
</div>
|
||||
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box mt-2 w-fit border p-4">
|
||||
<legend class="fieldset-legend">{m.device_general_track_ip()}</legend>
|
||||
<label class="fieldset-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={device.track_ip}
|
||||
class="toggle toggle-success"
|
||||
disabled={$settingsPriv?.track_ip_interval === '' || !ipPattern.test(device.ip)}
|
||||
/>
|
||||
{m.device_general_track_ip()}
|
||||
</label>
|
||||
<p class="fieldset-label max-w-md">{m.device_general_track_ip_desc()}</p>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
faCog,
|
||||
faDoorOpen,
|
||||
faHome,
|
||||
faListUl,
|
||||
faPlus,
|
||||
faSwatchbook,
|
||||
faUserGear,
|
||||
@@ -132,6 +133,14 @@
|
||||
><Fa icon={faCog} />{m.settings_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href={resolve('/logs/')}
|
||||
class="px-4 py-2"
|
||||
class:active={page.url.pathname.startsWith(resolve('/logs'))}
|
||||
><Fa icon={faListUl} />{m.logs_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
{/if}
|
||||
<li>
|
||||
<details>
|
||||
@@ -207,6 +216,14 @@
|
||||
><Fa icon={faCog} />{m.settings_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
<li class="h-full">
|
||||
<a
|
||||
href={resolve('/logs/')}
|
||||
class="p-2"
|
||||
class:menu-active={page.url.pathname.startsWith(resolve('/logs'))}
|
||||
><Fa icon={faListUl} />{m.logs_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
{/if}
|
||||
<div class="dropdown dropdown-end">
|
||||
<button class="btn btn-ghost hover:bg-base-content/10 h-full border-0 p-2" tabindex="0">
|
||||
|
||||
@@ -5,6 +5,7 @@ export type Device = RecordModel & {
|
||||
ip: string;
|
||||
mac: string;
|
||||
netmask: string;
|
||||
track_ip: boolean;
|
||||
description: string;
|
||||
status: 'pending' | 'online' | 'offline' | '';
|
||||
ports: string[];
|
||||
|
||||
@@ -11,4 +11,5 @@ export type SettingsPrivate = RecordModel & {
|
||||
interval: string;
|
||||
lazy_ping: boolean;
|
||||
scan_range: string;
|
||||
track_ip_interval: string;
|
||||
};
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
import { localeStore } from '$lib/stores/locale';
|
||||
import { backendUrl, permission, pocketbase } from '$lib/stores/pocketbase';
|
||||
import { settingsPub } from '$lib/stores/settings';
|
||||
import { settingsPriv, settingsPub } from '$lib/stores/settings';
|
||||
import type { Permission } from '$lib/types/permission';
|
||||
import type { SettingsPublic } from '$lib/types/settings';
|
||||
import type { SettingsPrivate, SettingsPublic } from '$lib/types/settings';
|
||||
import { onMount } from 'svelte';
|
||||
import toast, { Toaster, type ToastOptions } from 'svelte-french-toast';
|
||||
import '../app.css';
|
||||
@@ -79,6 +79,13 @@
|
||||
await $pocketbase
|
||||
.collection('_superusers')
|
||||
.authRefresh()
|
||||
.then(async () => {
|
||||
// set settingsPriv store on load
|
||||
if (!$settingsPriv) {
|
||||
const res = await $pocketbase.collection('settings_private').getFirstListItem('');
|
||||
settingsPriv.set(res as SettingsPrivate);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
// clear the store only on invalidated/expired token
|
||||
const status = err?.status << 0;
|
||||
@@ -93,6 +100,14 @@
|
||||
await $pocketbase
|
||||
.collection('users')
|
||||
.authRefresh()
|
||||
.then(async () => {
|
||||
// set settingsPriv store on load
|
||||
if (!$settingsPriv) {
|
||||
const res = await $pocketbase.collection('settings_private').getFirstListItem('');
|
||||
settingsPriv.set(res as SettingsPrivate);
|
||||
}
|
||||
})
|
||||
|
||||
.catch((err) => {
|
||||
// clear the store only on invalidated/expired token
|
||||
const status = err?.status << 0;
|
||||
|
||||
@@ -0,0 +1,492 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { resolve } from '$app/paths';
|
||||
import { page } from '$app/state';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { pocketbase } from '$lib/stores/pocketbase';
|
||||
import {
|
||||
faArrowDown,
|
||||
faArrowUp,
|
||||
faArrowsRotate,
|
||||
faChevronDown,
|
||||
faChevronLeft,
|
||||
faChevronRight,
|
||||
faChevronUp,
|
||||
faFilter
|
||||
} from '@fortawesome/free-solid-svg-icons';
|
||||
import type { LogModel } from 'pocketbase';
|
||||
import { onMount } from 'svelte';
|
||||
import Fa from 'svelte-fa';
|
||||
import toast from 'svelte-french-toast';
|
||||
|
||||
let logs = $state.raw<LogModel[]>([]);
|
||||
let currentPage = $state(1);
|
||||
let perPage = $state(20);
|
||||
let totalItems = $state(0);
|
||||
let totalPages = $state(0);
|
||||
let selectedLevel = $state('');
|
||||
let textSearch = $state('');
|
||||
let onlyUpSnapLogs = $state(true);
|
||||
let sort = $state('-created');
|
||||
let intervalSeconds = $state(5);
|
||||
let loading = $state(true);
|
||||
let refreshing = $state(false);
|
||||
let reloadPending = false;
|
||||
let error = $state('');
|
||||
let lastUpdated = $state<Date>();
|
||||
let pollTimer: ReturnType<typeof setInterval> | undefined;
|
||||
let searchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let detailsDialog: HTMLDialogElement;
|
||||
let selectedLog = $state<LogModel>();
|
||||
let mobileFiltersOpen = $state(false);
|
||||
|
||||
const levels = [
|
||||
{ value: '', label: () => m.logs_level_all() },
|
||||
{ value: '8', label: () => 'ERROR' },
|
||||
{ value: '4', label: () => 'WARN' },
|
||||
{ value: '0', label: () => 'INFO' },
|
||||
{ value: '-4', label: () => 'DEBUG' }
|
||||
];
|
||||
|
||||
function levelMeta(level: string) {
|
||||
switch (Number(level)) {
|
||||
case 8:
|
||||
return { label: 'ERROR', dotClass: 'bg-error' };
|
||||
case 4:
|
||||
return { label: 'WARN', dotClass: 'bg-warning' };
|
||||
case 0:
|
||||
return { label: 'INFO', dotClass: 'bg-success' };
|
||||
case -4:
|
||||
return { label: 'DEBUG', dotClass: 'bg-info' };
|
||||
default:
|
||||
return { label: 'UNKNOWN', dotClass: 'bg-base-content/60' };
|
||||
}
|
||||
}
|
||||
|
||||
function hasData(entry: LogModel) {
|
||||
return entry.data && Object.keys(entry.data).length > 0;
|
||||
}
|
||||
|
||||
function showDetails(entry: LogModel) {
|
||||
selectedLog = entry;
|
||||
detailsDialog.showModal();
|
||||
}
|
||||
|
||||
function dataEntries(entry: LogModel) {
|
||||
return Object.entries(entry.data ?? {});
|
||||
}
|
||||
|
||||
function dataValue(value: unknown) {
|
||||
if (value === '') return 'N/A';
|
||||
if (typeof value === 'object') return JSON.stringify(value);
|
||||
return String(value);
|
||||
}
|
||||
|
||||
function updateSearch() {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(() => updateQuery(), 250);
|
||||
}
|
||||
|
||||
function toggleSort(field: 'created' | 'message') {
|
||||
sort = sort === field ? `-${field}` : field;
|
||||
void loadLogs();
|
||||
}
|
||||
|
||||
async function loadLogs(initial = false, notifyError = false) {
|
||||
if (refreshing) {
|
||||
reloadPending = true;
|
||||
return;
|
||||
}
|
||||
|
||||
refreshing = true;
|
||||
if (initial) loading = true;
|
||||
error = '';
|
||||
|
||||
try {
|
||||
const filters = [];
|
||||
if (selectedLevel) filters.push(`level = ${selectedLevel}`);
|
||||
if (onlyUpSnapLogs) filters.push('data.upsnap = true');
|
||||
if (textSearch.trim()) {
|
||||
filters.push(
|
||||
$pocketbase.filter('(level ?~ {:search} || message ?~ {:search} || data ?~ {:search})', {
|
||||
search: textSearch.trim()
|
||||
})
|
||||
);
|
||||
}
|
||||
const result = await $pocketbase.logs.getList(currentPage, perPage, {
|
||||
sort,
|
||||
filter: filters.join(' && ')
|
||||
});
|
||||
if (result.totalPages > 0 && currentPage > result.totalPages) {
|
||||
currentPage = result.totalPages;
|
||||
reloadPending = true;
|
||||
return;
|
||||
}
|
||||
if (result.totalPages === 0) currentPage = 1;
|
||||
logs = result.items;
|
||||
totalItems = result.totalItems;
|
||||
totalPages = result.totalPages;
|
||||
lastUpdated = new Date();
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
error = m.logs_refresh_failed({ message });
|
||||
if (notifyError) toast.error(error);
|
||||
} finally {
|
||||
loading = false;
|
||||
refreshing = false;
|
||||
if (reloadPending) {
|
||||
reloadPending = false;
|
||||
void loadLogs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function restartPolling() {
|
||||
if (pollTimer) clearInterval(pollTimer);
|
||||
pollTimer = undefined;
|
||||
|
||||
if (intervalSeconds > 0) {
|
||||
pollTimer = setInterval(() => void loadLogs(), intervalSeconds * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function updateQuery() {
|
||||
currentPage = 1;
|
||||
void loadLogs();
|
||||
}
|
||||
|
||||
function changePage(nextPage: number) {
|
||||
currentPage = nextPage;
|
||||
void loadLogs();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (!$pocketbase.authStore.isSuperuser) {
|
||||
toast(m.toasts_no_permission({ url: page.url.pathname }), { icon: '⛔' });
|
||||
goto(resolve('/'));
|
||||
return;
|
||||
}
|
||||
|
||||
void loadLogs(true);
|
||||
restartPolling();
|
||||
|
||||
return () => {
|
||||
if (pollTimer) clearInterval(pollTimer);
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<main class="container mx-auto flex flex-col gap-4 p-4">
|
||||
<header class="flex flex-col justify-between gap-3 md:flex-row md:items-end">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold">{m.logs_page_title()}</h1>
|
||||
{#if lastUpdated}
|
||||
<p class="text-base-content/60 text-sm">
|
||||
{m.logs_refreshed_at({ time: lastUpdated.toLocaleTimeString() })}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="join w-full md:w-auto">
|
||||
<button
|
||||
class="btn btn-sm join-item flex-1 md:flex-none"
|
||||
onclick={() => loadLogs(false, true)}
|
||||
disabled={refreshing}
|
||||
>
|
||||
<Fa icon={faArrowsRotate} class={refreshing ? 'animate-spin' : ''} />
|
||||
{m.logs_refresh()}
|
||||
</button>
|
||||
<select
|
||||
class="select select-sm join-item"
|
||||
aria-label={m.logs_refresh()}
|
||||
bind:value={intervalSeconds}
|
||||
onchange={restartPolling}
|
||||
>
|
||||
<option value={0}>{m.logs_off()}</option>
|
||||
{#each [2, 5, 10, 30, 60] as seconds (seconds)}
|
||||
<option value={seconds}>{m.logs_seconds({ seconds })}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="xl:hidden">
|
||||
<button
|
||||
class="btn w-full justify-start gap-3"
|
||||
aria-expanded={mobileFiltersOpen}
|
||||
onclick={() => (mobileFiltersOpen = !mobileFiltersOpen)}
|
||||
>
|
||||
<Fa icon={faFilter} />
|
||||
<span class="text-base-content/60 flex-1 truncate text-left font-normal">
|
||||
{m.logs_filters()}
|
||||
</span>
|
||||
<Fa icon={mobileFiltersOpen ? faChevronUp : faChevronDown} />
|
||||
</button>
|
||||
|
||||
{#if mobileFiltersOpen}
|
||||
<div class="card card-border bg-base-100 mt-2">
|
||||
<div class="card-body grid grid-cols-2 gap-3 p-3">
|
||||
<fieldset class="fieldset gap-1">
|
||||
<legend class="fieldset-legend">{m.logs_column_level()}</legend>
|
||||
<select
|
||||
class="select select-sm w-full"
|
||||
bind:value={selectedLevel}
|
||||
onchange={updateQuery}
|
||||
>
|
||||
{#each levels as level (level.value)}
|
||||
<option value={level.value}>{level.label()}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fieldset gap-1">
|
||||
<legend class="fieldset-legend">{m.logs_upsnap_logs()}</legend>
|
||||
<label class="label gap-2 py-1">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="toggle toggle-sm"
|
||||
bind:checked={onlyUpSnapLogs}
|
||||
onchange={updateQuery}
|
||||
/>
|
||||
<span class="text-sm">{m.logs_only()}</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fieldset gap-1">
|
||||
<legend class="fieldset-legend">{m.logs_page_size()}</legend>
|
||||
<select class="select select-sm w-full" bind:value={perPage} onchange={updateQuery}>
|
||||
<option value={10}>10</option>
|
||||
<option value={20}>20</option>
|
||||
<option value={40}>40</option>
|
||||
<option value={80}>80</option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<input
|
||||
class="input mt-3 w-full"
|
||||
placeholder={m.logs_search_placeholder()}
|
||||
aria-label={m.logs_column_message()}
|
||||
bind:value={textSearch}
|
||||
oninput={updateSearch}
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="card card-border bg-base-100 hidden xl:block">
|
||||
<div class="flex items-end gap-3 p-4">
|
||||
<fieldset class="fieldset shrink-0">
|
||||
<legend class="fieldset-legend">{m.logs_column_level()}</legend>
|
||||
<select class="select w-auto" bind:value={selectedLevel} onchange={updateQuery}>
|
||||
{#each levels as level (level.value)}
|
||||
<option value={level.value}>{level.label()}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fieldset flex-1">
|
||||
<legend class="fieldset-legend">{m.logs_column_message()}</legend>
|
||||
<input
|
||||
class="input w-full"
|
||||
placeholder={m.logs_search_placeholder()}
|
||||
bind:value={textSearch}
|
||||
oninput={updateSearch}
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fieldset flex! shrink-0 flex-col self-stretch">
|
||||
<legend class="fieldset-legend">{m.logs_upsnap_logs()}</legend>
|
||||
<label class="label flex-1 gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="toggle"
|
||||
bind:checked={onlyUpSnapLogs}
|
||||
onchange={updateQuery}
|
||||
/>
|
||||
<span>{m.logs_only()}</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fieldset shrink-0">
|
||||
<legend class="fieldset-legend">{m.logs_page_size()}</legend>
|
||||
<select class="select w-auto" bind:value={perPage} onchange={updateQuery}>
|
||||
<option value={10}>10</option>
|
||||
<option value={20}>20</option>
|
||||
<option value={40}>40</option>
|
||||
<option value={80}>80</option>
|
||||
</select>
|
||||
</fieldset>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if error}
|
||||
<div role="alert" class="alert alert-error">
|
||||
<span>{error}</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<section class="card card-border bg-base-100 overflow-hidden">
|
||||
{#if loading}
|
||||
<div class="flex min-h-64 items-center justify-center">
|
||||
<span class="loading loading-spinner loading-lg"></span>
|
||||
</div>
|
||||
{:else if logs.length === 0}
|
||||
<div class="flex min-h-64 items-center justify-center p-6 text-center">
|
||||
<p class="text-base-content/60">{m.logs_empty()}</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="hidden md:block">
|
||||
<div class="border-base-300 flex border-b text-sm font-bold">
|
||||
<div class="w-32 shrink-0 p-3">{m.logs_column_level()}</div>
|
||||
<button
|
||||
class="hover:bg-base-300 flex flex-1 items-center gap-1 p-3 text-left"
|
||||
onclick={() => toggleSort('message')}
|
||||
>
|
||||
{m.logs_column_message()}
|
||||
{#if sort === 'message'}<Fa icon={faArrowUp} />{:else if sort === '-message'}<Fa
|
||||
icon={faArrowDown}
|
||||
/>{/if}
|
||||
</button>
|
||||
<button
|
||||
class="hover:bg-base-300 flex w-40 shrink-0 items-center gap-1 p-3 text-left"
|
||||
onclick={() => toggleSort('created')}
|
||||
>
|
||||
{m.logs_column_time()}
|
||||
{#if sort === 'created'}<Fa icon={faArrowUp} />{:else if sort === '-created'}<Fa
|
||||
icon={faArrowDown}
|
||||
/>{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="divide-base-300 divide-y">
|
||||
{#each logs as entry (entry.id)}
|
||||
{@const meta = levelMeta(entry.level)}
|
||||
<button
|
||||
class="hover:bg-base-200 flex w-full cursor-pointer items-start text-left"
|
||||
onclick={() => showDetails(entry)}
|
||||
>
|
||||
<div class="w-32 shrink-0 p-3">
|
||||
<span class="badge bg-base-300 badge-sm gap-1.5 border-0 font-semibold"
|
||||
><span class={`size-2 rounded-full ${meta.dotClass}`}></span>{meta.label}</span
|
||||
>
|
||||
</div>
|
||||
<div class="flex-1 p-3">
|
||||
<p class="text-xs wrap-break-word whitespace-pre-wrap">{entry.message}</p>
|
||||
{#if hasData(entry)}
|
||||
<div class="mt-1 flex flex-wrap gap-1">
|
||||
{#each dataEntries(entry) as [key, value] (key)}
|
||||
<span
|
||||
class="badge bg-base-300 badge-ghost badge-xs h-auto min-h-4 gap-1 py-0.5 font-normal whitespace-normal"
|
||||
>
|
||||
<span class="shrink-0">{key}:</span>
|
||||
<span>{dataValue(value)}</span>
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<time class="w-40 shrink-0 p-3 text-xs whitespace-nowrap"
|
||||
>{new Date(entry.created).toLocaleString()}</time
|
||||
>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="divide-base-300 divide-y md:hidden">
|
||||
{#each logs as entry (entry.id)}
|
||||
{@const meta = levelMeta(entry.level)}
|
||||
<li>
|
||||
<button
|
||||
class="hover:bg-base-200 flex w-full cursor-pointer flex-col gap-2 p-4 text-left"
|
||||
onclick={() => showDetails(entry)}
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="badge bg-base-300 badge-sm gap-1.5 border-0 font-semibold"
|
||||
><span class={`size-2 rounded-full ${meta.dotClass}`}></span>{meta.label}</span
|
||||
>
|
||||
<time class="text-base-content/60 text-xs"
|
||||
>{new Date(entry.created).toLocaleString()}</time
|
||||
>
|
||||
</div>
|
||||
<p class="text-xs wrap-break-word whitespace-pre-wrap">{entry.message}</p>
|
||||
{#if hasData(entry)}
|
||||
<div class="flex flex-wrap gap-1">
|
||||
{#each dataEntries(entry) as [key, value] (key)}
|
||||
<span
|
||||
class="badge bg-base-300 badge-ghost badge-xs h-auto min-h-4 gap-1 py-0.5 font-normal whitespace-normal"
|
||||
>
|
||||
<span class="shrink-0">{key}:</span>
|
||||
<span>{dataValue(value)}</span>
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
{#if totalPages > 1}
|
||||
<footer class="border-base-300 flex items-center justify-between border-t p-3">
|
||||
<span class="text-base-content/60 text-sm">{currentPage} / {totalPages} ({totalItems})</span
|
||||
>
|
||||
<div class="join">
|
||||
<button
|
||||
class="btn btn-sm join-item"
|
||||
onclick={() => changePage(currentPage - 1)}
|
||||
disabled={currentPage <= 1 || refreshing}
|
||||
aria-label={m.logs_previous()}
|
||||
>
|
||||
<Fa icon={faChevronLeft} />
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm join-item"
|
||||
onclick={() => changePage(currentPage + 1)}
|
||||
disabled={currentPage >= totalPages || refreshing}
|
||||
aria-label={m.logs_next()}
|
||||
>
|
||||
<Fa icon={faChevronRight} />
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
{/if}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<dialog class="modal" bind:this={detailsDialog}>
|
||||
<div class="modal-box max-w-3xl">
|
||||
{#if selectedLog}
|
||||
{@const meta = levelMeta(selectedLog.level)}
|
||||
<h2 class="text-lg font-bold">{m.logs_column_data()}</h2>
|
||||
<dl class="mt-4 grid items-center gap-x-6 gap-y-2 text-xs sm:grid-cols-[auto_1fr]">
|
||||
<dt class="text-base-content/60">ID</dt>
|
||||
<dd class="break-all">{selectedLog.id}</dd>
|
||||
<dt class="text-base-content/60">{m.logs_column_level()}</dt>
|
||||
<dd>
|
||||
<span class="badge bg-base-300 badge-sm gap-1.5 border-0 font-semibold"
|
||||
><span class={`size-2 rounded-full ${meta.dotClass}`}></span>{meta.label}</span
|
||||
>
|
||||
</dd>
|
||||
<dt class="text-base-content/60">{m.logs_column_message()}</dt>
|
||||
<dd class="wrap-break-word whitespace-pre-wrap">{selectedLog.message}</dd>
|
||||
<dt class="text-base-content/60">{m.logs_column_time()}</dt>
|
||||
<dd>{new Date(selectedLog.created).toLocaleString()}</dd>
|
||||
</dl>
|
||||
<pre class="bg-base-200 rounded-box mt-4 max-h-96 overflow-auto p-4 text-xs">{JSON.stringify(
|
||||
selectedLog,
|
||||
null,
|
||||
2
|
||||
)}</pre>
|
||||
{/if}
|
||||
<div class="modal-action">
|
||||
<form method="dialog">
|
||||
<button class="btn">{m.buttons_cancel()}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<form method="dialog" class="modal-backdrop"><button>close</button></form>
|
||||
</dialog>
|
||||
@@ -72,6 +72,14 @@
|
||||
throw new Error('ping_interval not valid');
|
||||
}
|
||||
|
||||
if (
|
||||
settingsPrivClone.track_ip_interval !== '' &&
|
||||
!(await parseCron(settingsPrivClone.track_ip_interval))
|
||||
) {
|
||||
toast.error(m.settings_invalid_cron());
|
||||
throw new Error('track_ip_interval not valid');
|
||||
}
|
||||
|
||||
await $pocketbase
|
||||
.collection('settings_public')
|
||||
.update(settingsPubClone.id, settingsPubClone)
|
||||
@@ -153,6 +161,29 @@
|
||||
| minute (0–59)
|
||||
second (0–59, optional)
|
||||
</code></pre>
|
||||
<h2 class="card-title mt-2">{m.settings_track_ip_title()}</h2>
|
||||
<p class="mt-2">
|
||||
{m.settings_track_ip_desc()}
|
||||
</p>
|
||||
<div class="mt-2 w-full">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="e.g. '0 */30 * * * *'"
|
||||
class="input"
|
||||
bind:value={settingsPrivClone.track_ip_interval}
|
||||
/>
|
||||
</div>
|
||||
{#if settingsPrivClone.track_ip_interval}
|
||||
<p class="fieldset-label">
|
||||
{#await parseCron(settingsPrivClone.track_ip_interval)}
|
||||
<span class="loading loading-spinner loading-xs"></span>
|
||||
{:then valid}
|
||||
{valid
|
||||
? '✅ ' + nextCronDate(settingsPrivClone.track_ip_interval)
|
||||
: m.settings_invalid_cron()}
|
||||
{/await}
|
||||
</p>
|
||||
{/if}
|
||||
<h2 class="card-title mt-2">{m.settings_lazy_ping_title()}</h2>
|
||||
<p class="mt-2">
|
||||
{m.settings_lazy_ping_desc()}
|
||||
|
||||
@@ -21,7 +21,8 @@ const config = {
|
||||
'/device',
|
||||
'/device/new',
|
||||
'/users',
|
||||
'/settings'
|
||||
'/settings',
|
||||
'/logs'
|
||||
],
|
||||
handleHttpError: ({ path, message }) => {
|
||||
if (path === '/api/upsnap/manifest.webmanifest') {
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "عوامل التصفية",
|
||||
"logs_column_data": "التفاصيل",
|
||||
"logs_column_level": "المستوى",
|
||||
"logs_column_message": "الرسالة",
|
||||
"logs_column_time": "الوقت",
|
||||
"logs_empty": "لا توجد سجلات تطابق هذا الفلتر.",
|
||||
"logs_upsnap_logs": "سجلات UpSnap",
|
||||
"logs_only": "فقط",
|
||||
"logs_level_all": "كل المستويات",
|
||||
"logs_next": "التالي",
|
||||
"logs_off": "إيقاف",
|
||||
"logs_page_size": "صفوف لكل صفحة",
|
||||
"logs_page_title": "السجلات",
|
||||
"logs_previous": "السابق",
|
||||
"logs_refresh": "تحديث",
|
||||
"logs_refresh_failed": "تعذر تحميل السجلات: {message}",
|
||||
"logs_refreshed_at": "تم التحديث {time}",
|
||||
"logs_search_placeholder": "البحث في السجلات",
|
||||
"logs_seconds": "{seconds} ثوانٍ",
|
||||
"account_account_type_admin": "مسؤول",
|
||||
"account_account_type_user": "مستخدم",
|
||||
"account_avatar_title": "صورة",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "عام",
|
||||
"device_general_description": "الوصف",
|
||||
"device_general_description_placeholder": "وصف للجهاز",
|
||||
"device_general_ip": "عنوان IP",
|
||||
"device_general_ip": "عنوان IP/FQDN",
|
||||
"device_general_mac": "عنوان Mac",
|
||||
"device_general_name": "الاسم",
|
||||
"device_general_netmask": "قناع الشبكة",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "تعيين أيقونة مفضلة مخصصة. أنواع الملفات المدعومة هي:",
|
||||
"settings_icon_title": "الأيقونة",
|
||||
"settings_invalid_cron": "❌ صيغة cron غير صالحة",
|
||||
"settings_invalid_fqdnip": "❌ عنوان FQDN/IPv4 غير صالح",
|
||||
"settings_lazy_ping_desc": "عندما يتم تشغيل الـ ping خامل سيقوم UpSnap بفحص الأجهزة فقط إذا كان هناك مستخدم نشط يزور الموقع. إذا تم إيقاف تشغيله، سيقوم UpSnap دائماً بفحص الأجهزة.",
|
||||
"settings_lazy_ping_enable": "تفعيل",
|
||||
"settings_lazy_ping_title": "Ping خامل",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Филтри",
|
||||
"logs_column_data": "Подробности",
|
||||
"logs_column_level": "Ниво",
|
||||
"logs_column_message": "Съобщение",
|
||||
"logs_column_time": "Време",
|
||||
"logs_empty": "Няма логове, съответстващи на този филтър.",
|
||||
"logs_upsnap_logs": "Дневници на UpSnap",
|
||||
"logs_only": "Само",
|
||||
"logs_level_all": "Всички нива",
|
||||
"logs_next": "Напред",
|
||||
"logs_off": "Изключено",
|
||||
"logs_page_size": "Редове на страница",
|
||||
"logs_page_title": "Логове",
|
||||
"logs_previous": "Назад",
|
||||
"logs_refresh": "Опресни",
|
||||
"logs_refresh_failed": "Неуспешно зареждане на логовете: {message}",
|
||||
"logs_refreshed_at": "Обновено {time}",
|
||||
"logs_search_placeholder": "Търсене в логовете",
|
||||
"logs_seconds": "{seconds} секунди",
|
||||
"account_account_type_admin": "Администратор",
|
||||
"account_account_type_user": "Потребител",
|
||||
"account_avatar_title": "Аватар",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Общи",
|
||||
"device_general_description": "Описание",
|
||||
"device_general_description_placeholder": "Описание на устройството",
|
||||
"device_general_ip": "IP адрес",
|
||||
"device_general_ip": "IP адрес/FQDN",
|
||||
"device_general_mac": "MAC адрес",
|
||||
"device_general_name": "Име",
|
||||
"device_general_netmask": "Мрежова маска",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Задайте персонализирана икона. Поддържани типове файлове:",
|
||||
"settings_icon_title": "Икона",
|
||||
"settings_invalid_cron": "❌ Невалиден cron синтаксис",
|
||||
"settings_invalid_fqdnip": "❌ Невалиден FQDN/IPv4 адрес",
|
||||
"settings_lazy_ping_desc": "Когато „мързелив ping“ е активиран, UpSnap ще ping-ва устройства само когато потребител действително посети сайта. Ако е деактивиран, UpSnap винаги ще ping-ва.",
|
||||
"settings_lazy_ping_enable": "Активиране",
|
||||
"settings_lazy_ping_title": "Мързелив ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtry",
|
||||
"logs_column_data": "Podrobnosti",
|
||||
"logs_column_level": "Úroveň",
|
||||
"logs_column_message": "Zpráva",
|
||||
"logs_column_time": "Čas",
|
||||
"logs_empty": "Žádné záznamy neodpovídají tomuto filtru.",
|
||||
"logs_upsnap_logs": "Záznamy UpSnap",
|
||||
"logs_only": "Pouze",
|
||||
"logs_level_all": "Všechny úrovně",
|
||||
"logs_next": "Další",
|
||||
"logs_off": "Vypnuto",
|
||||
"logs_page_size": "Řádků na stránku",
|
||||
"logs_page_title": "Záznamy",
|
||||
"logs_previous": "Předchozí",
|
||||
"logs_refresh": "Obnovit",
|
||||
"logs_refresh_failed": "Nelze načíst záznamy: {message}",
|
||||
"logs_refreshed_at": "Aktualizováno {time}",
|
||||
"logs_search_placeholder": "Hledat v záznamech",
|
||||
"logs_seconds": "{seconds} sekund",
|
||||
"account_account_type_admin": "Administrátor",
|
||||
"account_account_type_user": "Uživatel",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Obecné",
|
||||
"device_general_description": "Popisek",
|
||||
"device_general_description_placeholder": "Stručný popis zařízení",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "MAC",
|
||||
"device_general_name": "Jméno",
|
||||
"device_general_netmask": "Síťová maska",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Nastavit vlastní ikonu. Podporované typy souborů jsou:",
|
||||
"settings_icon_title": "Ikona",
|
||||
"settings_invalid_cron": "❌ Neplatná syntaxe cronu",
|
||||
"settings_invalid_fqdnip": "❌ Neplatná adresa FQDN/IPv4",
|
||||
"settings_lazy_ping_desc": "Když je funkce líného pingu zapnutá, UpSnap bude pingovat zařízení pouze v případě, že web navštíví aktivní uživatel. Pokud je tato funkce vypnutá, UpSnap bude pingovat zařízení vždy.",
|
||||
"settings_lazy_ping_enable": "Povolit",
|
||||
"settings_lazy_ping_title": "Líný ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filter",
|
||||
"logs_column_data": "Details",
|
||||
"logs_column_level": "Stufe",
|
||||
"logs_column_message": "Nachricht",
|
||||
"logs_column_time": "Zeit",
|
||||
"logs_empty": "Keine Protokolle entsprechen diesem Filter.",
|
||||
"logs_upsnap_logs": "UpSnap-Protokolle",
|
||||
"logs_only": "Nur",
|
||||
"logs_level_all": "Alle Stufen",
|
||||
"logs_next": "Weiter",
|
||||
"logs_off": "Aus",
|
||||
"logs_page_size": "Zeilen pro Seite",
|
||||
"logs_page_title": "Protokolle",
|
||||
"logs_previous": "Zurück",
|
||||
"logs_refresh": "Aktualisieren",
|
||||
"logs_refresh_failed": "Protokolle konnten nicht geladen werden: {message}",
|
||||
"logs_refreshed_at": "Aktualisiert {time}",
|
||||
"logs_search_placeholder": "Protokolle durchsuchen",
|
||||
"logs_seconds": "{seconds} Sekunden",
|
||||
"account_account_type_admin": "Admin",
|
||||
"account_account_type_user": "Benutzer",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Allgemein",
|
||||
"device_general_description": "Beschreibung",
|
||||
"device_general_description_placeholder": "Eine Beschreibung des Geräts",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Name",
|
||||
"device_general_netmask": "Netmask",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Eigenes Favicon nutzen. Unterstützte Dateitypen sind:",
|
||||
"settings_icon_title": "Icon",
|
||||
"settings_invalid_cron": "❌ Ungültige cron Syntax",
|
||||
"settings_invalid_fqdnip": "❌ Ungültige FQDN-/IPv4-Adresse",
|
||||
"settings_lazy_ping_desc": "Wenn Lazy Ping aktiviert ist, pingt UpSnap die Geräte nur an, wenn ein aktiver Benutzer die Website besucht. Wenn es ausgeschaltet ist, pingt UpSnap die Geräte immer an.",
|
||||
"settings_lazy_ping_enable": "Aktivieren",
|
||||
"settings_lazy_ping_title": "Lazy Ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Φίλτρα",
|
||||
"logs_column_data": "Λεπτομέρειες",
|
||||
"logs_column_level": "Επίπεδο",
|
||||
"logs_column_message": "Μήνυμα",
|
||||
"logs_column_time": "Ώρα",
|
||||
"logs_empty": "Κανένα αρχείο καταγραφής δεν ταιριάζει με αυτό το φίλτρο.",
|
||||
"logs_upsnap_logs": "Αρχεία καταγραφής UpSnap",
|
||||
"logs_only": "Μόνο",
|
||||
"logs_level_all": "Όλα τα επίπεδα",
|
||||
"logs_next": "Επόμενο",
|
||||
"logs_off": "Απενεργοποίηση",
|
||||
"logs_page_size": "Γραμμές ανά σελίδα",
|
||||
"logs_page_title": "Αρχεία καταγραφής",
|
||||
"logs_previous": "Προηγούμενο",
|
||||
"logs_refresh": "Ανανέωση",
|
||||
"logs_refresh_failed": "Δεν ήταν δυνατή η φόρτωση αρχείων καταγραφής: {message}",
|
||||
"logs_refreshed_at": "Ενημερώθηκε {time}",
|
||||
"logs_search_placeholder": "Αναζήτηση αρχείων καταγραφής",
|
||||
"logs_seconds": "{seconds} δευτερόλεπτα",
|
||||
"account_account_type_admin": "Διαχειριστής",
|
||||
"account_account_type_user": "Χρήστης",
|
||||
"account_avatar_title": "Άβαταρ",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Γενικά",
|
||||
"device_general_description": "Περιγραφή",
|
||||
"device_general_description_placeholder": "Περιγραφή συσκευής",
|
||||
"device_general_ip": "IP Διεύθυνση",
|
||||
"device_general_ip": "IP Διεύθυνση/FQDN",
|
||||
"device_general_mac": "Mac Φυσική Διεύθυνση",
|
||||
"device_general_name": "Όνομα",
|
||||
"device_general_netmask": "Μάσκα δικτύου",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Προσδιορισμός προσαρμοσμένου favicon. Υποστηριζόμενοι τύποι είναι:",
|
||||
"settings_icon_title": "Εικονίδιο",
|
||||
"settings_invalid_cron": "❌ Μη έγκυρο συντακτικό πραγμαμματισμού",
|
||||
"settings_invalid_fqdnip": "❌ Μη έγκυρη διεύθυνση FQDN/IPv4",
|
||||
"settings_lazy_ping_desc": "Όταν το lazy ping είναι ενεργό, το UpSnap θα στείλει ping στις συσκευές αν υπάρχει ενεργός χρήστης εντός του ιστότοπου. Αν δεν είναι ενεργό, το UpSnap θα στέλνει πάντα ping στις συσκευές.",
|
||||
"settings_lazy_ping_enable": "Ενεργοποίηση",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filters",
|
||||
"account_account_type_admin": "Admin",
|
||||
"account_account_type_user": "User",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,11 +36,13 @@
|
||||
"device_general": "General",
|
||||
"device_general_description": "Description",
|
||||
"device_general_description_placeholder": "Some description of the device",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Name",
|
||||
"device_general_netmask": "Netmask",
|
||||
"device_general_required_field": "required field",
|
||||
"device_general_track_ip": "Track IP address",
|
||||
"device_general_track_ip_desc": "Updates this device's IP address automatically whenever the periodic network scan finds its MAC address at a different IP. Requires the 'IP address tracking' interval to be set in the settings and only works on subnets UpSnap is directly attached to.",
|
||||
"device_groups": "Groups",
|
||||
"device_groups_desc": "You can add devices to a group to have them sorted by group on the dashboard.",
|
||||
"device_groups_placeholder": "e.g. 'Basement' or 'Office'",
|
||||
@@ -126,6 +129,24 @@
|
||||
"login_menu_title_auth_providers": "Other Auth Providers",
|
||||
"login_password_label": "Password:",
|
||||
"login_welcome": "Welcome",
|
||||
"logs_column_data": "Details",
|
||||
"logs_column_level": "Level",
|
||||
"logs_column_message": "Message",
|
||||
"logs_column_time": "Time",
|
||||
"logs_empty": "No logs match this filter.",
|
||||
"logs_upsnap_logs": "UpSnap logs",
|
||||
"logs_only": "Only",
|
||||
"logs_level_all": "All levels",
|
||||
"logs_next": "Next",
|
||||
"logs_off": "Off",
|
||||
"logs_page_size": "Rows per page",
|
||||
"logs_page_title": "Logs",
|
||||
"logs_previous": "Previous",
|
||||
"logs_refresh": "Refresh",
|
||||
"logs_refresh_failed": "Could not load logs: {message}",
|
||||
"logs_refreshed_at": "Updated {time}",
|
||||
"logs_search_placeholder": "Search logs",
|
||||
"logs_seconds": "{seconds} seconds",
|
||||
"navbar_edit_account": "Edit account",
|
||||
"navbar_logout": "Logout",
|
||||
"navbar_new": "New",
|
||||
@@ -133,13 +154,16 @@
|
||||
"settings_icon_desc": "Set a custom favicon. Supported file types are:",
|
||||
"settings_icon_title": "Icon",
|
||||
"settings_invalid_cron": "❌ Invalid cron syntax",
|
||||
"settings_lazy_ping_desc": "When lazy ping is turned on, UpSnap will only ping devices if there is an active user visiting the website. If it's turned off, UpSnap will always ping devices.",
|
||||
"settings_invalid_fqdnip": "❌ Invalid FQDN/IPv4 address",
|
||||
"settings_lazy_ping_desc": "When lazy ping is turned on, UpSnap will only ping devices and run IP tracking scans while a user has the website open. If it's turned off, UpSnap always pings and scans.",
|
||||
"settings_lazy_ping_enable": "Enable",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
"settings_page_title": "Settings",
|
||||
"settings_ping_interval_desc1": "Sets the interval in which the devices are pinged. Leave blank to use default value of <span class=\"badge\">*/3 * * * * *</span>.",
|
||||
"settings_ping_interval_desc2": "Learn more about the correct syntax for cron on <a class=\"link\" href=\"https://en.wikipedia.org/wiki/Cron\" target=\"_blank\">Wikipedia</a> or refer to the <a class=\"link\" href=\"https://github.com/harrisiirak/cron-parser\" target=\"_blank\">package documentation</a>.",
|
||||
"settings_ping_interval_title": "Ping interval",
|
||||
"settings_track_ip_desc": "Cron interval at which UpSnap scans the local subnets of devices with 'Track IP address' enabled and updates their IP address if their MAC address is found at a different one. Every 15-60 minutes is plenty; short intervals broadcast-scan your network aggressively, which can be especially bad on wider subnets. Leave empty to disable. Requires nmap, same as the network scan.",
|
||||
"settings_track_ip_title": "IP address tracking",
|
||||
"settings_upsnap_version": "UpSnap version",
|
||||
"settings_website_title_desc": "Sets the title of the website and in the browser tab.",
|
||||
"settings_website_title_title": "Website title",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtros",
|
||||
"logs_column_data": "Detalles",
|
||||
"logs_column_level": "Nivel",
|
||||
"logs_column_message": "Mensaje",
|
||||
"logs_column_time": "Hora",
|
||||
"logs_empty": "Ningún registro coincide con este filtro.",
|
||||
"logs_upsnap_logs": "Registros de UpSnap",
|
||||
"logs_only": "Solo",
|
||||
"logs_level_all": "Todos los niveles",
|
||||
"logs_next": "Siguiente",
|
||||
"logs_off": "Desactivado",
|
||||
"logs_page_size": "Filas por página",
|
||||
"logs_page_title": "Registros",
|
||||
"logs_previous": "Anterior",
|
||||
"logs_refresh": "Actualizar",
|
||||
"logs_refresh_failed": "No se pudieron cargar los registros: {message}",
|
||||
"logs_refreshed_at": "Actualizado {time}",
|
||||
"logs_search_placeholder": "Buscar registros",
|
||||
"logs_seconds": "{seconds} segundos",
|
||||
"account_account_type_admin": "Admin",
|
||||
"account_account_type_user": "Usuario",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "General",
|
||||
"device_general_description": "Descripción",
|
||||
"device_general_description_placeholder": "Descripción del dispositivo",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Nombre",
|
||||
"device_general_netmask": "Máscara de red",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Establece un favicon personalizado. Los tipos de archivos admitidos son:",
|
||||
"settings_icon_title": "Icon",
|
||||
"settings_invalid_cron": "❌ Sintaxis cron no válida",
|
||||
"settings_invalid_fqdnip": "❌ Invalid FQDN/IPv4 address",
|
||||
"settings_lazy_ping_desc": "Cuando el ping diferido está activado, UpSnap solo hará ping a los dispositivos si hay un usuario activo visitando el sitio web. Si está desactivado, UpSnap siempre hará ping a los dispositivos.",
|
||||
"settings_lazy_ping_enable": "Activar",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtres",
|
||||
"logs_column_data": "Détails",
|
||||
"logs_column_level": "Niveau",
|
||||
"logs_column_message": "Message",
|
||||
"logs_column_time": "Heure",
|
||||
"logs_empty": "Aucun journal ne correspond à ce filtre.",
|
||||
"logs_upsnap_logs": "Journaux UpSnap",
|
||||
"logs_only": "Seulement",
|
||||
"logs_level_all": "Tous les niveaux",
|
||||
"logs_next": "Suivant",
|
||||
"logs_off": "Désactivé",
|
||||
"logs_page_size": "Lignes par page",
|
||||
"logs_page_title": "Journaux",
|
||||
"logs_previous": "Précédent",
|
||||
"logs_refresh": "Actualiser",
|
||||
"logs_refresh_failed": "Impossible de charger les journaux : {message}",
|
||||
"logs_refreshed_at": "Mis à jour {time}",
|
||||
"logs_search_placeholder": "Rechercher dans les journaux",
|
||||
"logs_seconds": "{seconds} secondes",
|
||||
"account_account_type_admin": "Administrateur",
|
||||
"account_account_type_user": "Utilisateur",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Général",
|
||||
"device_general_description": "Description",
|
||||
"device_general_description_placeholder": "Description de l'appareil",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Nom",
|
||||
"device_general_netmask": "Masque réseau",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Définit un favicon personnalisé. Les types de fichier compatibles sont :",
|
||||
"settings_icon_title": "Icône",
|
||||
"settings_invalid_cron": "❌ Syntaxe cron invalide",
|
||||
"settings_invalid_fqdnip": "❌ Adresse FQDN/IPv4 invalide",
|
||||
"settings_lazy_ping_desc": "Lorsque le mode ping fainéant est activé, UpSnap ne va effectuer des requêtes de ping sur les appareils que lorsqu'un utilisateur actif visite le site. Si vous désactivez cette fonction, UpSnap exécutera toujours ces requêtes.",
|
||||
"settings_lazy_ping_enable": "Activer",
|
||||
"settings_lazy_ping_title": "Ping fainéant",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "फ़िल्टर",
|
||||
"logs_column_data": "विवरण",
|
||||
"logs_column_level": "स्तर",
|
||||
"logs_column_message": "संदेश",
|
||||
"logs_column_time": "समय",
|
||||
"logs_empty": "इस फ़िल्टर से कोई लॉग मेल नहीं खाता।",
|
||||
"logs_upsnap_logs": "UpSnap लॉग",
|
||||
"logs_only": "केवल",
|
||||
"logs_level_all": "सभी स्तर",
|
||||
"logs_next": "अगला",
|
||||
"logs_off": "बंद",
|
||||
"logs_page_size": "प्रति पृष्ठ पंक्तियाँ",
|
||||
"logs_page_title": "लॉग",
|
||||
"logs_previous": "पिछला",
|
||||
"logs_refresh": "रीफ़्रेश करें",
|
||||
"logs_refresh_failed": "लॉग लोड नहीं किए जा सके: {message}",
|
||||
"logs_refreshed_at": "अपडेट किया गया {time}",
|
||||
"logs_search_placeholder": "लॉग खोजें",
|
||||
"logs_seconds": "{seconds} सेकंड",
|
||||
"account_account_type_admin": "प्रशासक",
|
||||
"account_account_type_user": "उपयोगकर्ता",
|
||||
"account_avatar_title": "अवतार",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "सामान्य",
|
||||
"device_general_description": "विवरण",
|
||||
"device_general_description_placeholder": "डिवाइस का कुछ विवरण",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "नाम",
|
||||
"device_general_netmask": "नेटमास्क",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "एक कस्टम favicon सेट करें। समर्थित फ़ाइल प्रकार हैं:",
|
||||
"settings_icon_title": "आइकन",
|
||||
"settings_invalid_cron": "❌ अमान्य क्रोन सिंटैक्स",
|
||||
"settings_invalid_fqdnip": "❌ अमान्य FQDN/IPv4 पता",
|
||||
"settings_lazy_ping_desc": "जब Lazy Ping चालू होता है, UpSnap केवल तब पिंग करेगा जब कोई सक्रिय उपयोगकर्ता वेबसाइट पर हो। बंद होने पर यह हमेशा पिंग करेगा।",
|
||||
"settings_lazy_ping_enable": "सक्रिय करें",
|
||||
"settings_lazy_ping_title": "Lazy पिंग",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filter",
|
||||
"logs_column_data": "Detail",
|
||||
"logs_column_level": "Tingkat",
|
||||
"logs_column_message": "Pesan",
|
||||
"logs_column_time": "Waktu",
|
||||
"logs_empty": "Tidak ada log yang cocok dengan filter ini.",
|
||||
"logs_upsnap_logs": "Log UpSnap",
|
||||
"logs_only": "Hanya",
|
||||
"logs_level_all": "Semua tingkat",
|
||||
"logs_next": "Berikutnya",
|
||||
"logs_off": "Nonaktif",
|
||||
"logs_page_size": "Baris per halaman",
|
||||
"logs_page_title": "Log",
|
||||
"logs_previous": "Sebelumnya",
|
||||
"logs_refresh": "Segarkan",
|
||||
"logs_refresh_failed": "Tidak dapat memuat log: {message}",
|
||||
"logs_refreshed_at": "Diperbarui {time}",
|
||||
"logs_search_placeholder": "Cari log",
|
||||
"logs_seconds": "{seconds} detik",
|
||||
"account_account_type_admin": "Admin",
|
||||
"account_account_type_user": "Pengguna",
|
||||
"account_avatar_title": "Personifikasi",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Umum",
|
||||
"device_general_description": "Deskripsi",
|
||||
"device_general_description_placeholder": "Deskripsi perangkat ini",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Nama",
|
||||
"device_general_netmask": "Netmask",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Atur favicon khusus. Jenis file yang didukung:",
|
||||
"settings_icon_title": "Ikon",
|
||||
"settings_invalid_cron": "❌ Sintaks tugas penjadwalan tidak valid",
|
||||
"settings_invalid_fqdnip": "❌ Alamat FQDN/IPv4 tidak valid",
|
||||
"settings_lazy_ping_desc": "Saat Ping Santai diaktifkan, UpSnap hanya akan memping perangkat jika ada pengguna yang mengakses situs web. Jika dinonaktifkan, UpSnap akan selalu memping perangkat.",
|
||||
"settings_lazy_ping_enable": "Aktifkan",
|
||||
"settings_lazy_ping_title": "Ping Santai",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtri",
|
||||
"logs_column_data": "Dettagli",
|
||||
"logs_column_level": "Livello",
|
||||
"logs_column_message": "Messaggio",
|
||||
"logs_column_time": "Ora",
|
||||
"logs_empty": "Nessun registro corrisponde a questo filtro.",
|
||||
"logs_upsnap_logs": "Registri di UpSnap",
|
||||
"logs_only": "Solo",
|
||||
"logs_level_all": "Tutti i livelli",
|
||||
"logs_next": "Successivo",
|
||||
"logs_off": "Disattivato",
|
||||
"logs_page_size": "Righe per pagina",
|
||||
"logs_page_title": "Registri",
|
||||
"logs_previous": "Precedente",
|
||||
"logs_refresh": "Aggiorna",
|
||||
"logs_refresh_failed": "Impossibile caricare i registri: {message}",
|
||||
"logs_refreshed_at": "Aggiornato {time}",
|
||||
"logs_search_placeholder": "Cerca nei registri",
|
||||
"logs_seconds": "{seconds} secondi",
|
||||
"account_account_type_admin": "Amministratore",
|
||||
"account_account_type_user": "Utente",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Generale",
|
||||
"device_general_description": "Descrizione",
|
||||
"device_general_description_placeholder": "Descrizione del dispositivo",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Nome",
|
||||
"device_general_netmask": "Maschera di rete",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Imposta una icona personalizzata. I tipi di file supportati sono:",
|
||||
"settings_icon_title": "Icona",
|
||||
"settings_invalid_cron": "❌ Sintassi cron non valida",
|
||||
"settings_invalid_fqdnip": "❌ Indirizzo FQDN/IPv4 non valido",
|
||||
"settings_lazy_ping_desc": "Quando il ping pigro è abilitato, UpSnap effettuerà i ping verso di dispositivi solamente quando un utente effettivamente visita il sito. Se è spento, allora UpSnap continuerà con il ping sempre.",
|
||||
"settings_lazy_ping_enable": "Abilita",
|
||||
"settings_lazy_ping_title": "Ping pigro",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "フィルター",
|
||||
"logs_column_data": "詳細",
|
||||
"logs_column_level": "レベル",
|
||||
"logs_column_message": "メッセージ",
|
||||
"logs_column_time": "時刻",
|
||||
"logs_empty": "このフィルターに一致するログはありません。",
|
||||
"logs_upsnap_logs": "UpSnap ログ",
|
||||
"logs_only": "のみ",
|
||||
"logs_level_all": "すべてのレベル",
|
||||
"logs_next": "次へ",
|
||||
"logs_off": "オフ",
|
||||
"logs_page_size": "ページあたりの行数",
|
||||
"logs_page_title": "ログ",
|
||||
"logs_previous": "前へ",
|
||||
"logs_refresh": "更新",
|
||||
"logs_refresh_failed": "ログを読み込めませんでした: {message}",
|
||||
"logs_refreshed_at": "更新日時: {time}",
|
||||
"logs_search_placeholder": "ログを検索",
|
||||
"logs_seconds": "{seconds} 秒",
|
||||
"account_account_type_admin": "管理者",
|
||||
"account_account_type_user": "ユーザー",
|
||||
"account_avatar_title": "アバター",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "一般",
|
||||
"device_general_description": "説明",
|
||||
"device_general_description_placeholder": "装置の説明",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "名前",
|
||||
"device_general_netmask": "ネットマスク",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "カスタムファビコンを設定します。サポートされているファイルタイプ:",
|
||||
"settings_icon_title": "アイコン",
|
||||
"settings_invalid_cron": "❌ 無効なcron構文",
|
||||
"settings_invalid_fqdnip": "❌ 無効なFQDN/IPv4アドレス",
|
||||
"settings_lazy_ping_desc": "Lazy ping をオンにすると、UpSnap はアクティブなユーザーがウェブサイトを訪れている場合にのみデバイスを ping します。オフの場合、UpSnap は常にデバイスを ping します。",
|
||||
"settings_lazy_ping_enable": "有効化",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "필터",
|
||||
"logs_column_data": "세부 정보",
|
||||
"logs_column_level": "수준",
|
||||
"logs_column_message": "메시지",
|
||||
"logs_column_time": "시간",
|
||||
"logs_empty": "이 필터와 일치하는 로그가 없습니다.",
|
||||
"logs_upsnap_logs": "UpSnap 로그",
|
||||
"logs_only": "만",
|
||||
"logs_level_all": "모든 수준",
|
||||
"logs_next": "다음",
|
||||
"logs_off": "끔",
|
||||
"logs_page_size": "페이지당 행 수",
|
||||
"logs_page_title": "로그",
|
||||
"logs_previous": "이전",
|
||||
"logs_refresh": "새로고침",
|
||||
"logs_refresh_failed": "로그를 불러올 수 없습니다: {message}",
|
||||
"logs_refreshed_at": "업데이트됨 {time}",
|
||||
"logs_search_placeholder": "로그 검색",
|
||||
"logs_seconds": "{seconds}초",
|
||||
"account_account_type_admin": "관리자",
|
||||
"account_account_type_user": "사용자",
|
||||
"account_avatar_title": "아바타",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "일반",
|
||||
"device_general_description": "설명",
|
||||
"device_general_description_placeholder": "기기에 관한 설명",
|
||||
"device_general_ip": "IP 주소",
|
||||
"device_general_ip": "IP 주소/FQDN",
|
||||
"device_general_mac": "Mac 주소",
|
||||
"device_general_name": "이름",
|
||||
"device_general_netmask": "넷 마스크",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "사용자 지정 favicon을 설정하세요. 지원되는 파일 형식:",
|
||||
"settings_icon_title": "아이콘",
|
||||
"settings_invalid_cron": "❌ 잘못된 크론 구문",
|
||||
"settings_invalid_fqdnip": "❌ 유효하지 않은 FQDN/IPv4 주소입니다",
|
||||
"settings_lazy_ping_desc": "Lazy Ping이 활성화되면, UpSnap은 웹사이트를 방문하는 활성 사용자가 있을 때만 장치를 핑합니다. 비활성화되면, UpSnap은 항상 장치를 핑합니다.",
|
||||
"settings_lazy_ping_enable": "활성화",
|
||||
"settings_lazy_ping_title": "Lazy Ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtre",
|
||||
"logs_column_data": "Detaljer",
|
||||
"logs_column_level": "Nivå",
|
||||
"logs_column_message": "Melding",
|
||||
"logs_column_time": "Tid",
|
||||
"logs_empty": "Ingen logger samsvarer med dette filteret.",
|
||||
"logs_upsnap_logs": "UpSnap-logger",
|
||||
"logs_only": "Kun",
|
||||
"logs_level_all": "Alle nivåer",
|
||||
"logs_next": "Neste",
|
||||
"logs_off": "Av",
|
||||
"logs_page_size": "Rader per side",
|
||||
"logs_page_title": "Logger",
|
||||
"logs_previous": "Forrige",
|
||||
"logs_refresh": "Oppdater",
|
||||
"logs_refresh_failed": "Kunne ikke laste logger: {message}",
|
||||
"logs_refreshed_at": "Oppdatert {time}",
|
||||
"logs_search_placeholder": "Søk i logger",
|
||||
"logs_seconds": "{seconds} sekunder",
|
||||
"account_account_type_admin": "Admin",
|
||||
"account_account_type_user": "Bruker",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Generelt",
|
||||
"device_general_description": "Beskrivelse",
|
||||
"device_general_description_placeholder": "Liten beskrivelse av enheten",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "MAC",
|
||||
"device_general_name": "Navn",
|
||||
"device_general_netmask": "Nettmaske",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Angi et egendefinert favorittikon. Støttede filtyper er:",
|
||||
"settings_icon_title": "Ikon",
|
||||
"settings_invalid_cron": "❌ Ugyldig cron-syntaks",
|
||||
"settings_invalid_fqdnip": "❌ Ugyldig FQDN/IPv4-adresse",
|
||||
"settings_lazy_ping_desc": "Når lat ping er slått på, vil UpSnap bare pinge enheter hvis det er en aktiv bruker som besøker nettstedet. Hvis den er slått av, vil UpSnap alltid pinge enheter.",
|
||||
"settings_lazy_ping_enable": "Aktiver",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filters",
|
||||
"logs_column_data": "Details",
|
||||
"logs_column_level": "Niveau",
|
||||
"logs_column_message": "Bericht",
|
||||
"logs_column_time": "Tijd",
|
||||
"logs_empty": "Geen logboeken komen overeen met dit filter.",
|
||||
"logs_upsnap_logs": "UpSnap-logboeken",
|
||||
"logs_only": "Alleen",
|
||||
"logs_level_all": "Alle niveaus",
|
||||
"logs_next": "Volgende",
|
||||
"logs_off": "Uit",
|
||||
"logs_page_size": "Rijen per pagina",
|
||||
"logs_page_title": "Logboeken",
|
||||
"logs_previous": "Vorige",
|
||||
"logs_refresh": "Vernieuwen",
|
||||
"logs_refresh_failed": "Kan logboeken niet laden: {message}",
|
||||
"logs_refreshed_at": "Bijgewerkt {time}",
|
||||
"logs_search_placeholder": "Logboeken zoeken",
|
||||
"logs_seconds": "{seconds} seconden",
|
||||
"account_account_type_admin": "Beheerder",
|
||||
"account_account_type_user": "Gebruiker",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Algemeen",
|
||||
"device_general_description": "Beschrijving",
|
||||
"device_general_description_placeholder": "Enige beschrijving van het apparaat",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Naam",
|
||||
"device_general_netmask": "Subnetmask",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Stel een aangepast favicon in. Ondersteunde bestandstypen zijn:",
|
||||
"settings_icon_title": "Icoon",
|
||||
"settings_invalid_cron": "❌ Ongeldige cron syntaxis",
|
||||
"settings_invalid_fqdnip": "❌ Ongeldig FQDN/IPv4-adres",
|
||||
"settings_lazy_ping_desc": "Wanneer lazy ping is ingeschakeld, pingt UpSnap alleen apparaten als er een actieve gebruiker de website bezoekt. Als het is uitgeschakeld, pingt UpSnap altijd apparaten.",
|
||||
"settings_lazy_ping_enable": "Inschakelen",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtry",
|
||||
"logs_column_data": "Szczegóły",
|
||||
"logs_column_level": "Poziom",
|
||||
"logs_column_message": "Wiadomość",
|
||||
"logs_column_time": "Czas",
|
||||
"logs_empty": "Żadne logi nie pasują do tego filtra.",
|
||||
"logs_upsnap_logs": "Dzienniki UpSnap",
|
||||
"logs_only": "Tylko",
|
||||
"logs_level_all": "Wszystkie poziomy",
|
||||
"logs_next": "Następny",
|
||||
"logs_off": "Wyłączone",
|
||||
"logs_page_size": "Wiersze na stronę",
|
||||
"logs_page_title": "Logi",
|
||||
"logs_previous": "Poprzedni",
|
||||
"logs_refresh": "Odśwież",
|
||||
"logs_refresh_failed": "Nie udało się załadować logów: {message}",
|
||||
"logs_refreshed_at": "Zaktualizowano {time}",
|
||||
"logs_search_placeholder": "Szukaj w logach",
|
||||
"logs_seconds": "{seconds} sekund",
|
||||
"account_account_type_admin": "Administrator",
|
||||
"account_account_type_user": "Użytkownik",
|
||||
"account_avatar_title": "Awatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Ogólne",
|
||||
"device_general_description": "Opis",
|
||||
"device_general_description_placeholder": "Przykładowy opis urządzenia",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "MAC",
|
||||
"device_general_name": "Nazwa",
|
||||
"device_general_netmask": "Maska sieci",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Ustaw niestandardowy favicon. Obsługiwane są typy plików:",
|
||||
"settings_icon_title": "Ikona",
|
||||
"settings_invalid_cron": "❌ Nieprawidłowa składnia cron",
|
||||
"settings_invalid_fqdnip": "❌ Nieprawidłowy adres FQDN/IPv4",
|
||||
"settings_lazy_ping_desc": "Gdy leniwe pingowanie jest włączone, UpSnap będzie pingować urządzenia tylko wtedy, gdy użytkownicy odwiedzają stronę. Gdy ta opcja jest wyłączona, UpSnap będzie pingować urządzenia nieustannie.",
|
||||
"settings_lazy_ping_enable": "Włącz",
|
||||
"settings_lazy_ping_title": "Leniwe pingowanie",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtros",
|
||||
"logs_column_data": "Detalhes",
|
||||
"logs_column_level": "Nível",
|
||||
"logs_column_message": "Mensagem",
|
||||
"logs_column_time": "Hora",
|
||||
"logs_empty": "Nenhum registro corresponde a este filtro.",
|
||||
"logs_upsnap_logs": "Registros do UpSnap",
|
||||
"logs_only": "Somente",
|
||||
"logs_level_all": "Todos os níveis",
|
||||
"logs_next": "Próximo",
|
||||
"logs_off": "Desativado",
|
||||
"logs_page_size": "Linhas por página",
|
||||
"logs_page_title": "Registros",
|
||||
"logs_previous": "Anterior",
|
||||
"logs_refresh": "Atualizar",
|
||||
"logs_refresh_failed": "Não foi possível carregar os registros: {message}",
|
||||
"logs_refreshed_at": "Atualizado {time}",
|
||||
"logs_search_placeholder": "Pesquisar registros",
|
||||
"logs_seconds": "{seconds} segundos",
|
||||
"account_account_type_admin": "Admin",
|
||||
"account_account_type_user": "Usuário",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Geral",
|
||||
"device_general_description": "Descrição",
|
||||
"device_general_description_placeholder": "Alguma descrição do dispositivo",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Nome",
|
||||
"device_general_netmask": "Máscara de rede",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Define um favicon personalizado. Tipos de ficheiros suportados são:",
|
||||
"settings_icon_title": "Ícone",
|
||||
"settings_invalid_cron": "❌ Sintaxe inválida de agendamento cron",
|
||||
"settings_invalid_fqdnip": "❌ Endereço FQDN/IPv4 inválido",
|
||||
"settings_lazy_ping_desc": "Quando o lazy ping está ativo, o UpSnap irá apenas executar o ping se existir um usuário ativo no website. Se desligado, o UpSnap irá executar sempre o ping.",
|
||||
"settings_lazy_ping_enable": "Ativar",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Filtros",
|
||||
"logs_column_data": "Detalhes",
|
||||
"logs_column_level": "Nível",
|
||||
"logs_column_message": "Mensagem",
|
||||
"logs_column_time": "Hora",
|
||||
"logs_empty": "Nenhum registo corresponde a este filtro.",
|
||||
"logs_upsnap_logs": "Registos do UpSnap",
|
||||
"logs_only": "Apenas",
|
||||
"logs_level_all": "Todos os níveis",
|
||||
"logs_next": "Seguinte",
|
||||
"logs_off": "Desligado",
|
||||
"logs_page_size": "Linhas por página",
|
||||
"logs_page_title": "Registos",
|
||||
"logs_previous": "Anterior",
|
||||
"logs_refresh": "Atualizar",
|
||||
"logs_refresh_failed": "Não foi possível carregar os registos: {message}",
|
||||
"logs_refreshed_at": "Atualizado {time}",
|
||||
"logs_search_placeholder": "Pesquisar registos",
|
||||
"logs_seconds": "{seconds} segundos",
|
||||
"account_account_type_admin": "Admin",
|
||||
"account_account_type_user": "Utilizador",
|
||||
"account_avatar_title": "Avatar",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Geral",
|
||||
"device_general_description": "Descrição",
|
||||
"device_general_description_placeholder": "Alguma descrição do dispositivo",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Nome",
|
||||
"device_general_netmask": "Máscara de rede",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Define um favicon personalizado. Tipos de ficheiros suportados são:",
|
||||
"settings_icon_title": "Ícone",
|
||||
"settings_invalid_cron": "❌ Sintaxe inválida do cron",
|
||||
"settings_invalid_fqdnip": "❌ Endereço FQDN/IPv4 inválido",
|
||||
"settings_lazy_ping_desc": "Quando o lazy ping está activo, o UpSnap irá apenas executar o ping se existir um utilizador ativo no website. Se desligado, o UpSnap irá executar sempre o ping.",
|
||||
"settings_lazy_ping_enable": "Activar",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Фильтры",
|
||||
"logs_column_data": "Подробности",
|
||||
"logs_column_level": "Уровень",
|
||||
"logs_column_message": "Сообщение",
|
||||
"logs_column_time": "Время",
|
||||
"logs_empty": "Нет журналов, соответствующих этому фильтру.",
|
||||
"logs_upsnap_logs": "Журналы UpSnap",
|
||||
"logs_only": "Только",
|
||||
"logs_level_all": "Все уровни",
|
||||
"logs_next": "Следующая",
|
||||
"logs_off": "Выключено",
|
||||
"logs_page_size": "Строк на страницу",
|
||||
"logs_page_title": "Журналы",
|
||||
"logs_previous": "Предыдущая",
|
||||
"logs_refresh": "Обновить",
|
||||
"logs_refresh_failed": "Не удалось загрузить журналы: {message}",
|
||||
"logs_refreshed_at": "Обновлено {time}",
|
||||
"logs_search_placeholder": "Поиск журналов",
|
||||
"logs_seconds": "{seconds} секунд",
|
||||
"account_account_type_admin": "Администратор",
|
||||
"account_account_type_user": "Пользователь",
|
||||
"account_avatar_title": "Аватар",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Основное",
|
||||
"device_general_description": "Описание",
|
||||
"device_general_description_placeholder": "Некоторое описание устройства",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "MAC адрес",
|
||||
"device_general_name": "Имя",
|
||||
"device_general_netmask": "Сетевая маска",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Установить собственный фавикон. Поддерживаемые типы файлов:",
|
||||
"settings_icon_title": "Иконка",
|
||||
"settings_invalid_cron": "❌ Неверный синтаксис cron",
|
||||
"settings_invalid_fqdnip": "❌ Неверный FQDN/IPv4-адрес",
|
||||
"settings_lazy_ping_desc": "Если функция lazy ping (ленивый пинг) включена, UpSnap будет пинговать устройства только в том случае, если на сайте есть активный пользователь. Если функция отключена, UpSnap будет пинговать устройства всегда.",
|
||||
"settings_lazy_ping_enable": "Включить",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Фільтри",
|
||||
"logs_column_data": "Подробиці",
|
||||
"logs_column_level": "Рівень",
|
||||
"logs_column_message": "Повідомлення",
|
||||
"logs_column_time": "Час",
|
||||
"logs_empty": "Немає журналів, що відповідають цьому фільтру.",
|
||||
"logs_upsnap_logs": "Журнали UpSnap",
|
||||
"logs_only": "Лише",
|
||||
"logs_level_all": "Усі рівні",
|
||||
"logs_next": "Наступна",
|
||||
"logs_off": "Вимкнено",
|
||||
"logs_page_size": "Рядків на сторінку",
|
||||
"logs_page_title": "Журнали",
|
||||
"logs_previous": "Попередня",
|
||||
"logs_refresh": "Оновити",
|
||||
"logs_refresh_failed": "Не вдалося завантажити журнали: {message}",
|
||||
"logs_refreshed_at": "Оновлено {time}",
|
||||
"logs_search_placeholder": "Пошук у журналах",
|
||||
"logs_seconds": "{seconds} секунд",
|
||||
"account_account_type_admin": "Адміністратор",
|
||||
"account_account_type_user": "Користувач",
|
||||
"account_avatar_title": "Аватар",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Основні",
|
||||
"device_general_description": "Опис",
|
||||
"device_general_description_placeholder": "Опису пристрою",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "MAC адреса",
|
||||
"device_general_name": "Ім'я",
|
||||
"device_general_netmask": "Маска мережі",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Встановіть спеціальну піктограму. Підтримувані типи файлів:",
|
||||
"settings_icon_title": "Значок",
|
||||
"settings_invalid_cron": "❌ Недійсний синтаксис cron",
|
||||
"settings_invalid_fqdnip": "❌ Недійсна адреса FQDN/IPv4",
|
||||
"settings_lazy_ping_desc": "Коли ввімкнено відкладений пінг, UpSnap перевірятиме лише пристрої, якщо є активний користувач, який відвідує веб-сайт. Якщо його вимкнено, UpSnap завжди перевіряє пристрої.",
|
||||
"settings_lazy_ping_enable": "Увімкнути",
|
||||
"settings_lazy_ping_title": "Відкладений пінг",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "Bộ lọc",
|
||||
"logs_column_data": "Chi tiết",
|
||||
"logs_column_level": "Mức độ",
|
||||
"logs_column_message": "Thông báo",
|
||||
"logs_column_time": "Thời gian",
|
||||
"logs_empty": "Không có nhật ký nào khớp với bộ lọc này.",
|
||||
"logs_upsnap_logs": "Nhật ký UpSnap",
|
||||
"logs_only": "Chỉ",
|
||||
"logs_level_all": "Tất cả mức độ",
|
||||
"logs_next": "Tiếp theo",
|
||||
"logs_off": "Tắt",
|
||||
"logs_page_size": "Hàng mỗi trang",
|
||||
"logs_page_title": "Nhật ký",
|
||||
"logs_previous": "Trước",
|
||||
"logs_refresh": "Làm mới",
|
||||
"logs_refresh_failed": "Không thể tải nhật ký: {message}",
|
||||
"logs_refreshed_at": "Đã cập nhật {time}",
|
||||
"logs_search_placeholder": "Tìm kiếm nhật ký",
|
||||
"logs_seconds": "{seconds} giây",
|
||||
"account_account_type_admin": "Quản trị viên",
|
||||
"account_account_type_user": "Người dùng",
|
||||
"account_avatar_title": "Ảnh đại diện",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "Tổng quan",
|
||||
"device_general_description": "Mô tả",
|
||||
"device_general_description_placeholder": "Mô tả về thiết bị",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "Tên",
|
||||
"device_general_netmask": "Netmask",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "Đặt favicon tùy chỉnh. Hỗ trợ định dạng:",
|
||||
"settings_icon_title": "Biểu tượng",
|
||||
"settings_invalid_cron": "❌ Cú pháp cron không hợp lệ",
|
||||
"settings_invalid_fqdnip": "❌ Tên miền đầy đủ/Địa chỉ IPv4 không hợp lệ",
|
||||
"settings_lazy_ping_desc": "Khi bật lazy ping, UpSnap chỉ ping khi có người dùng truy cập web. Nếu tắt, UpSnap sẽ luôn ping.",
|
||||
"settings_lazy_ping_enable": "Bật",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "筛选",
|
||||
"logs_column_data": "详细信息",
|
||||
"logs_column_level": "级别",
|
||||
"logs_column_message": "消息",
|
||||
"logs_column_time": "时间",
|
||||
"logs_empty": "没有日志符合此筛选条件。",
|
||||
"logs_upsnap_logs": "UpSnap 日志",
|
||||
"logs_only": "仅",
|
||||
"logs_level_all": "所有级别",
|
||||
"logs_next": "下一页",
|
||||
"logs_off": "关闭",
|
||||
"logs_page_size": "每页行数",
|
||||
"logs_page_title": "日志",
|
||||
"logs_previous": "上一页",
|
||||
"logs_refresh": "刷新",
|
||||
"logs_refresh_failed": "无法加载日志:{message}",
|
||||
"logs_refreshed_at": "更新于 {time}",
|
||||
"logs_search_placeholder": "搜索日志",
|
||||
"logs_seconds": "{seconds} 秒",
|
||||
"account_account_type_admin": "管理员",
|
||||
"account_account_type_user": "普通用户",
|
||||
"account_avatar_title": "头像",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "通用",
|
||||
"device_general_description": "说明",
|
||||
"device_general_description_placeholder": "设备的一些说明",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "名称",
|
||||
"device_general_netmask": "子网掩码",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "设置一个自定义图标. 支持的文件类型:",
|
||||
"settings_icon_title": "图标",
|
||||
"settings_invalid_cron": "❌ 无效的 cron 语法",
|
||||
"settings_invalid_fqdnip": "❌ 无效的 FQDN/IPv4 地址",
|
||||
"settings_lazy_ping_desc": "当开关打开时, UpSnap 只会在用户访问网站期间进行 ping 操作.",
|
||||
"settings_lazy_ping_enable": "启用",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/inlang-message-format",
|
||||
"logs_filters": "篩選",
|
||||
"logs_column_data": "詳細資料",
|
||||
"logs_column_level": "層級",
|
||||
"logs_column_message": "訊息",
|
||||
"logs_column_time": "時間",
|
||||
"logs_empty": "沒有日誌符合此篩選條件。",
|
||||
"logs_upsnap_logs": "UpSnap 日誌",
|
||||
"logs_only": "僅",
|
||||
"logs_level_all": "所有層級",
|
||||
"logs_next": "下一頁",
|
||||
"logs_off": "關閉",
|
||||
"logs_page_size": "每頁列數",
|
||||
"logs_page_title": "日誌",
|
||||
"logs_previous": "上一頁",
|
||||
"logs_refresh": "重新整理",
|
||||
"logs_refresh_failed": "無法載入日誌:{message}",
|
||||
"logs_refreshed_at": "更新於 {time}",
|
||||
"logs_search_placeholder": "搜尋日誌",
|
||||
"logs_seconds": "{seconds} 秒",
|
||||
"account_account_type_admin": "管理員",
|
||||
"account_account_type_user": "普通使用者",
|
||||
"account_avatar_title": "頭像",
|
||||
@@ -35,7 +54,7 @@
|
||||
"device_general": "一般",
|
||||
"device_general_description": "描述",
|
||||
"device_general_description_placeholder": "關於這個裝置的描述",
|
||||
"device_general_ip": "IP",
|
||||
"device_general_ip": "IP/FQDN",
|
||||
"device_general_mac": "Mac",
|
||||
"device_general_name": "名稱",
|
||||
"device_general_netmask": "子網域遮罩",
|
||||
@@ -133,6 +152,7 @@
|
||||
"settings_icon_desc": "設定一個自訂義圖標。支援的檔案類型:",
|
||||
"settings_icon_title": "圖標",
|
||||
"settings_invalid_cron": "❌ 「無效的 Cron 語法」",
|
||||
"settings_invalid_fqdnip": "❌ 無效的 FQDN/IPv4 位址",
|
||||
"settings_lazy_ping_desc": "當開關打開時 UpSnap 只會在有使用者訪問網站時才對裝置進行 ping 測試。反之則 UpSnap 將持續對裝置進行 ping 測試。",
|
||||
"settings_lazy_ping_enable": "啟用",
|
||||
"settings_lazy_ping_title": "Lazy ping",
|
||||
|
||||
Reference in New Issue
Block a user