mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 12:44:08 +01:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj
34 lines
774 B
Go
34 lines
774 B
Go
//go:build windows
|
|
|
|
package sshx
|
|
|
|
import (
|
|
"net"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/Microsoft/go-winio"
|
|
)
|
|
|
|
// Unter Windows lauscht der mitgelieferte OpenSSH-Agent (Dienst "ssh-agent")
|
|
// auf einer Named Pipe. Neuere Pageant-Versionen und 1Password/KeePassXC
|
|
// bieten dieselbe Pipe an. SSH_AUTH_SOCK darf auf eine andere Pipe zeigen.
|
|
func dialAgent() (net.Conn, error) {
|
|
pipe := `\\.\pipe\openssh-ssh-agent`
|
|
if p := os.Getenv("SSH_AUTH_SOCK"); p != "" && len(p) > 2 && p[:2] == `\\` {
|
|
pipe = p
|
|
}
|
|
t := 3 * time.Second
|
|
return winio.DialPipe(pipe, &t)
|
|
}
|
|
|
|
// AgentReachable: läuft ein SSH-Agent (Pageant oder OpenSSH-Dienst), den
|
|
// sshTermy erreicht (Selbstprüfung)?
|
|
func AgentReachable() error {
|
|
c, err := dialAgent()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return c.Close()
|
|
}
|