mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-11-29 13:14:12 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b9decd572 | |||
| 9a1a816f25 | |||
| 8d43554e0e | |||
| b88f567d9f | |||
| cb168f2f47 |
@@ -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"]
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user