mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-11-27 20:32:04 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b7d68b866 | |||
| e13e9dfce0 | |||
| 12b3b782cd | |||
| 98f222bfb9 | |||
| de66c39191 | |||
| 69acc57ed2 | |||
| c9bc0c8f38 | |||
| fee9d605f1 | |||
| 8bedcbf88a | |||
| 95946d7cc2 | |||
| c125afdfc7 | |||
| 80fb1a6127 | |||
| 92a66fc8a4 | |||
| 8c52952a1e | |||
| ac16e982ea |
+3
-3
@@ -5,7 +5,7 @@ go 1.24
|
||||
require (
|
||||
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a
|
||||
github.com/pocketbase/dbx v1.11.0
|
||||
github.com/pocketbase/pocketbase v0.26.1
|
||||
github.com/pocketbase/pocketbase v0.26.3
|
||||
github.com/prometheus-community/pro-bing v0.6.1
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
golang.org/x/sys v0.31.0
|
||||
@@ -21,7 +21,7 @@ require (
|
||||
github.com/ganigeorgiev/fexpr v0.4.1 // indirect
|
||||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
@@ -46,6 +46,6 @@ require (
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
modernc.org/libc v1.61.13 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.8.2 // indirect
|
||||
modernc.org/memory v1.9.1 // indirect
|
||||
modernc.org/sqlite v1.36.1 // indirect
|
||||
)
|
||||
|
||||
+6
-6
@@ -26,8 +26,8 @@ github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRi
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
@@ -69,8 +69,8 @@ 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.11.0 h1:LpZezioMfT3K4tLrqA55wWFw1EtH1pM4tzSVa7kgszU=
|
||||
github.com/pocketbase/dbx v1.11.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
|
||||
github.com/pocketbase/pocketbase v0.26.1 h1:0WBqIRKKPCqp+xHPVLB4fevkoT9HVlR4BSuNwAt5oJ0=
|
||||
github.com/pocketbase/pocketbase v0.26.1/go.mod h1:t5y5pfnhrEg//RuSzSg0a926OLZ0oQj66jYs3BzDJwA=
|
||||
github.com/pocketbase/pocketbase v0.26.3 h1:S3YP00uUQwTVMqt4wyuAZv43xJVWH72yNq5tJ8J9lgM=
|
||||
github.com/pocketbase/pocketbase v0.26.3/go.mod h1:npsaOtraBSCk04mNCbl0SE/ZIsIkvUjJYTt3LHD1gC0=
|
||||
github.com/prometheus-community/pro-bing v0.6.1 h1:EQukUOma9YFZRPe4DGSscxUf9LH07rpqwisNWjSZrgU=
|
||||
github.com/prometheus-community/pro-bing v0.6.1/go.mod h1:jNCOI3D7pmTCeaoF41cNS6uaxeFY/Gmc3ffwbuJVzAQ=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
@@ -147,8 +147,8 @@ modernc.org/libc v1.61.13 h1:3LRd6ZO1ezsFiX1y+bHd1ipyEHIJKvuprv0sLTBwLW8=
|
||||
modernc.org/libc v1.61.13/go.mod h1:8F/uJWL/3nNil0Lgt1Dpz+GgkApWh04N3el3hxJcA6E=
|
||||
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.8.2 h1:cL9L4bcoAObu4NkxOlKWBWtNHIsnnACGF/TbqQ6sbcI=
|
||||
modernc.org/memory v1.8.2/go.mod h1:ZbjSvMO5NQ1A2i3bWeDiVMxIorXwdClKE/0SZ+BMotU=
|
||||
modernc.org/memory v1.9.1 h1:V/Z1solwAVmMW1yttq3nDdZPJqV1rM05Ccq6KMSZ34g=
|
||||
modernc.org/memory v1.9.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
|
||||
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -76,6 +77,15 @@ func CheckPort(host string, port string) (bool, error) {
|
||||
timeout := 500 * time.Millisecond
|
||||
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), timeout)
|
||||
if err != nil {
|
||||
// treat "host unreachable", "connection refused" and "timeout" as no error
|
||||
var netErr *net.OpError
|
||||
if errors.As(err, &netErr) {
|
||||
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) ||
|
||||
errors.Is(netErr.Err, syscall.ECONNREFUSED) ||
|
||||
netErr.Timeout() {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestCheckPort(t *testing.T) {
|
||||
name: "Port Zero",
|
||||
host: "8.8.8.8",
|
||||
port: "0",
|
||||
wantError: true,
|
||||
wantError: false,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ services:
|
||||
# user: 1000:1000
|
||||
# environment:
|
||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
||||
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
|
||||
# # dns is used for name resolution during network scan
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
services:
|
||||
upsnap:
|
||||
container_name: upsnap
|
||||
image: ghcr.io/seriousm4x/upsnap:4 # images are also available on docker hub: seriousm4x/upsnap:4
|
||||
image: ghcr.io/seriousm4x/upsnap:5 # images are also available on docker hub: seriousm4x/upsnap:5
|
||||
network_mode: host
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
@@ -10,7 +10,7 @@ services:
|
||||
# user: 1000:1000
|
||||
# environment:
|
||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
||||
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||
# - UPSNAP_SCAN_TIMEOUT=500ms # Scan timeout is nmap's --host-timeout value to wait for devices (https://nmap.org/book/man-performance.html)
|
||||
# - UPSNAP_PING_PRIVILEGED=true # Set to false if you don't have root user permissions
|
||||
|
||||
+12
-12
@@ -11,19 +11,19 @@
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "eslint --fix --cache .",
|
||||
"format": "prettier --write --cache --cache-strategy content --ignore-path ../.gitignore .",
|
||||
"prepare": "cd .. && husky frontend/.husky",
|
||||
"prepare": "svelte-kit sync && cd .. && husky frontend/.husky",
|
||||
"machine-translate": "inlang machine translate --project project.inlang"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.7",
|
||||
"@eslint/js": "^9.22.0",
|
||||
"@inlang/cli": "^3.0.3",
|
||||
"@inlang/paraglide-js": "2.0.0-beta.26",
|
||||
"@eslint/js": "^9.23.0",
|
||||
"@inlang/cli": "^3.0.7",
|
||||
"@inlang/paraglide-js": "2.0.5",
|
||||
"@sveltejs/adapter-static": "^3.0.8",
|
||||
"@sveltejs/kit": "^2.19.2",
|
||||
"@sveltejs/kit": "^2.20.2",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"daisyui": "5.0.0",
|
||||
"eslint": "^9.22.0",
|
||||
"daisyui": "^5.0.9",
|
||||
"eslint": "^9.23.0",
|
||||
"eslint-config-prettier": "^10.1.1",
|
||||
"eslint-plugin-svelte": "^2.46.1",
|
||||
"globals": "^15.15.0",
|
||||
@@ -31,13 +31,13 @@
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-svelte": "^3.3.3",
|
||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||
"svelte": "^5.23.0",
|
||||
"svelte": "^5.25.3",
|
||||
"svelte-check": "^4.1.5",
|
||||
"tailwindcss": "^4.0.14",
|
||||
"tailwindcss": "^4.0.15",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.8.2",
|
||||
"typescript-eslint": "^8.26.1",
|
||||
"vite": "^6.2.2"
|
||||
"typescript-eslint": "^8.28.0",
|
||||
"vite": "^6.2.3"
|
||||
},
|
||||
"type": "module",
|
||||
"lint-staged": {
|
||||
@@ -46,7 +46,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
||||
"@tailwindcss/postcss": "^4.0.14",
|
||||
"@tailwindcss/postcss": "^4.0.15",
|
||||
"cron-parser": "^4.9.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"pocketbase": "^0.25.2",
|
||||
|
||||
Generated
+353
-333
File diff suppressed because it is too large
Load Diff
@@ -5,20 +5,9 @@ import cronParser from 'cron-parser';
|
||||
import { formatDate, type Locale } from 'date-fns';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export const cronRegex = new RegExp(/((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,6})/);
|
||||
|
||||
export function nextCronDate(expression: string) {
|
||||
try {
|
||||
if (
|
||||
expression === '' ||
|
||||
!cronRegex.test(expression) ||
|
||||
Object.keys(cronParser.parseString(expression).errors).length > 0
|
||||
) {
|
||||
throw new Error('cron-parser failed to parse string');
|
||||
}
|
||||
|
||||
const cron = cronParser.parseExpression(expression, {});
|
||||
|
||||
return formatDate(cron.next().toISOString(), 'PPpp', {
|
||||
locale: get(dateFnsLocale) as unknown as Locale
|
||||
});
|
||||
|
||||
@@ -5,16 +5,43 @@
|
||||
import NetworkScan from '$lib/components/NetworkScan.svelte';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { permission, pocketbase } from '$lib/stores/pocketbase';
|
||||
import type { Device, Port } from '$lib/types/device';
|
||||
import type { Device, Group, Port } from '$lib/types/device';
|
||||
import { faBinoculars, faWrench } from '@fortawesome/free-solid-svg-icons';
|
||||
import Fa from 'svelte-fa';
|
||||
import toast from 'svelte-french-toast';
|
||||
|
||||
let device: Device = {
|
||||
name: '',
|
||||
ip: '',
|
||||
mac: '',
|
||||
netmask: '',
|
||||
description: '',
|
||||
status: '',
|
||||
ports: [] as string[],
|
||||
link_open: '',
|
||||
ping_cmd: '',
|
||||
wake_cron: '',
|
||||
wake_cron_enabled: false,
|
||||
wake_cmd: '',
|
||||
wake_confirm: false,
|
||||
wake_timeout: 0,
|
||||
shutdown_cron: '',
|
||||
shutdown_cron_enabled: false,
|
||||
shutdown_cmd: '',
|
||||
shutdown_confirm: false,
|
||||
shutdown_timeout: 0,
|
||||
password: '',
|
||||
groups: [] as string[],
|
||||
expand: {
|
||||
ports: [] as Port[]
|
||||
ports: [] as Port[],
|
||||
groups: [] as Group[]
|
||||
},
|
||||
groups: [] as string[]
|
||||
created_by: '',
|
||||
sol_enabled: false,
|
||||
sol_auth: false,
|
||||
sol_user: '',
|
||||
sol_password: '',
|
||||
sol_port: 0
|
||||
} as Device;
|
||||
|
||||
$: if (Object.hasOwn($permission, 'create')) {
|
||||
|
||||
Reference in New Issue
Block a user