Bump version to 1.0.9
Fix Wake-on-LAN: set SO_BROADCAST on UDP socket, send 3 magic packets, expose broadcast_addr and wake timeout fields in UI, add Test Wake endpoint, surface send errors in job status, bump default wake timeout to 180s.
This commit is contained in:
+1
-22
@@ -4,13 +4,12 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
var ErrTimeout = fmt.Errorf("timeout waiting for machine to respond")
|
||||
|
||||
func WaitUntilReady(ctx context.Context, host string, sshPort int, maxWait, checkInterval time.Duration, usePing bool) error {
|
||||
func WaitUntilReady(ctx context.Context, host string, sshPort int, maxWait, checkInterval time.Duration) error {
|
||||
deadline := time.Now().Add(maxWait)
|
||||
interval := checkInterval
|
||||
|
||||
@@ -32,13 +31,6 @@ func WaitUntilReady(ctx context.Context, host string, sshPort int, maxWait, chec
|
||||
return nil
|
||||
}
|
||||
|
||||
if usePing {
|
||||
cmd := exec.CommandContext(ctx, "ping", "-c", "1", "-W", "1", host)
|
||||
if err := cmd.Run(); err == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if time.Now().After(deadline) {
|
||||
return ErrTimeout
|
||||
}
|
||||
@@ -53,16 +45,3 @@ func WaitUntilReady(ctx context.Context, host string, sshPort int, maxWait, chec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func IsHostReachable(host string, port int, timeout time.Duration) bool {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 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 {
|
||||
conn.Close()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user