Merge pull request #19 from burakgizlice/fix/ydotool-socket-type

fix: use SOCK_DGRAM for ydotoold socket (v1.0.4+)
This commit is contained in:
Leonardo Trapani
2026-02-15 16:53:25 +01:00
committed by GitHub
+9 -1
View File
@@ -32,7 +32,15 @@ func (y *ydotoolBackend) Available() error {
return fmt.Errorf("ydotoold socket not found - ensure ydotoold is running") return fmt.Errorf("ydotoold socket not found - ensure ydotoold is running")
} }
conn, err := net.DialTimeout("unix", socketPath, 500*time.Millisecond) // ydotoold v1.0.4+ uses SOCK_DGRAM (unixgram) sockets.
// Try unixgram first, then fall back to stream for older versions.
// Note: unixgram dials are effectively instant (no handshake), but we
// use a dialer with a deadline to stay consistent and guard against edge cases.
dialer := net.Dialer{Timeout: 500 * time.Millisecond}
conn, err := dialer.Dial("unixgram", socketPath)
if err != nil {
conn, err = net.DialTimeout("unix", socketPath, 500*time.Millisecond)
}
if err != nil { if err != nil {
return fmt.Errorf("ydotoold not responding at %s: %w", socketPath, err) return fmt.Errorf("ydotoold not responding at %s: %w", socketPath, err)
} }