mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 20:54:09 +01:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUkBzZ657Au6Rz4BPXj
31 lines
617 B
Go
31 lines
617 B
Go
//go:build !windows
|
|
|
|
package sshx
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
"os"
|
|
|
|
"github.com/db9979/sshtermy/internal/i18n"
|
|
)
|
|
|
|
// macOS/Linux: der Agent lauscht auf dem Unix-Socket aus SSH_AUTH_SOCK
|
|
// (macOS startet ihn per launchd automatisch).
|
|
func dialAgent() (net.Conn, error) {
|
|
sock := os.Getenv("SSH_AUTH_SOCK")
|
|
if sock == "" {
|
|
return nil, errors.New(i18n.T("SSH_AUTH_SOCK ist nicht gesetzt"))
|
|
}
|
|
return net.Dial("unix", sock)
|
|
}
|
|
|
|
// AgentReachable: läuft ein SSH-Agent, den sshTermy erreicht (Selbstprüfung)?
|
|
func AgentReachable() error {
|
|
c, err := dialAgent()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return c.Close()
|
|
}
|