Compare commits

...

8 Commits

Author SHA1 Message Date
Maxi Quoß 3b9decd572 add container_name, fix health whitespace 2023-02-11 22:54:19 +01:00
Maxi Quoß 9a1a816f25 change error messages 2023-02-11 22:49:23 +01:00
Maxi Quoß 8d43554e0e check if To4() == nil 2023-02-11 22:48:16 +01:00
Maxi Quoß b88f567d9f move healthcheck to dockerfile 2023-02-11 22:24:50 +01:00
Maxi Quoß cb168f2f47 remove magicpacket log 2023-02-11 22:24:23 +01:00
Maxi Quoß 376220c557 natural sort devices by name
meaning, 1-2-10 instead of 1-10-2
2023-02-11 22:08:39 +01:00
Maxi Quoß ef064e9335 shutdown: print stderr to log 2023-02-11 21:53:57 +01:00
Maxi Quoß 67870d8114 add go version badge 2023-02-09 01:12:54 +01:00
6 changed files with 20 additions and 16 deletions
+2
View File
@@ -16,4 +16,6 @@ RUN apk update &&\
rm -rf /var/cache/apk/*
WORKDIR /app
COPY --from=downloader /app/upsnap upsnap
HEALTHCHECK --interval=10s \
CMD curl -fs "http://localhost:8090/api/health" || exit 1
ENTRYPOINT ["./upsnap", "serve", "--http=0.0.0.0:8090"]
+1
View File
@@ -7,6 +7,7 @@
<p>A simple wake on lan app written with SvelteKit, Go, PocketBase and nmap.</p>
<a target="_blank" href="https://github.com/seriousm4x/upsnap"><img src="https://img.shields.io/github/stars/seriousm4x/upsnap" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/downloads/seriousm4x/upsnap/total" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/go-mod/go-version/seriousm4x/UpSnap?filename=backend/go.mod" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/releases"><img src="https://img.shields.io/github/v/release/seriousm4x/upsnap?display_name=tag" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/actions"><img src="https://github.com/seriousm4x/upsnap/actions/workflows/deploy.yml/badge.svg?event=push" /></a>
<a target="_blank" href="https://github.com/seriousm4x/UpSnap/commits/master"><img src="https://img.shields.io/github/last-commit/seriousm4x/upsnap" /></a>
+12 -7
View File
@@ -7,7 +7,6 @@ import (
"github.com/mdlayher/wol"
"github.com/pocketbase/pocketbase/models"
"github.com/seriousm4x/upsnap/logger"
)
func SendMagicPacket(device *models.Record) error {
@@ -34,7 +33,6 @@ func SendMagicPacket(device *models.Record) error {
return err
}
targetAddr := fmt.Sprintf("%s:%d", broadcastIp, 9)
logger.Debug.Println(targetAddr)
// send wake via udp port 9
if err := wakeUDP(targetAddr, parsedMac, bytePassword); err != nil {
@@ -56,15 +54,22 @@ func wakeUDP(addr string, target net.HardwareAddr, password []byte) error {
func getBroadcastIp(ipStr, maskStr string) (string, error) {
ip := net.ParseIP(ipStr)
if ip == nil {
return "", errors.New("invalid IP address")
return "", errors.New("ip not a valid ipv4 address")
}
mask := net.ParseIP(maskStr)
if mask == nil {
return "", errors.New("invalid subnet mask")
ip = ip.To4()
if ip == nil {
return "", errors.New("ip not a valid ipv4 address")
}
ip = ip.To4()
mask := net.ParseIP(maskStr)
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 {
-3
View File
@@ -32,9 +32,6 @@ func ShutdownDevice(device *models.Record) error {
var stderr bytes.Buffer
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return err
}
if stderr.Len() > 0 {
return fmt.Errorf("%s", stderr.String())
}
+1 -5
View File
@@ -1,16 +1,12 @@
version: "3"
services:
upsnap:
container_name: upsnap
image: ghcr.io/seriousm4x/upsnap:3
network_mode: host
restart: unless-stopped
volumes:
- ./data:/app/pb_data
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
interval: 1m
timeout: 10s
retries: 3
# environment:
# - TZ=Europe/Berlin # Set container timezone for cron schedules
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
+4 -1
View File
@@ -1,5 +1,8 @@
export function sortDevices(a, b) {
return a.name > b.name;
return a.name.localeCompare(b.name, undefined, {
numeric: true,
sensitivity: 'base'
});
}
export function sortPorts(a, b) {