Bump version to 1.0.10
Smart WoL: TCP pre-check before sending magic packet (3s timeout). Machine status updates via SSE: online/offline tracked in DB and broadcast to all connected browser tabs in real-time. - Pre-check: if machine already reachable, skip WoL and mark online - WoL path: send 3 magic packets, wait for SSH, mark online/offline - Backend: setMachineStatus() helper + machine_status SSE event - Frontend: subscribeMachineStatus() SSE helper for Machines + Dashboard - IsReachable() helper in wol package for TCP reachability checks
This commit is contained in:
@@ -45,3 +45,16 @@ func WaitUntilReady(ctx context.Context, host string, sshPort int, maxWait, chec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func IsReachable(ctx context.Context, host string, port int, timeout time.Duration) bool {
|
||||
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
addr := fmt.Sprintf("%s:%d", host, port)
|
||||
dialer := net.Dialer{Timeout: timeout}
|
||||
conn, err := dialer.DialContext(ctx, "tcp", addr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
conn.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user