Compare commits

..

5 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
3 changed files with 15 additions and 12 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"]
+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 {
+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