forked from forgejo/forgejo
go1.16 (#14783)
This commit is contained in:
parent
030646eea4
commit
47f6a4ec3f
947 changed files with 26119 additions and 7062 deletions
31
vendor/github.com/xanzy/ssh-agent/sshagent_windows.go
generated
vendored
31
vendor/github.com/xanzy/ssh-agent/sshagent_windows.go
generated
vendored
|
@ -27,17 +27,40 @@ import (
|
|||
"net"
|
||||
"sync"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
"golang.org/x/crypto/ssh/agent"
|
||||
)
|
||||
|
||||
const (
|
||||
sshAgentPipe = `\\.\pipe\openssh-ssh-agent`
|
||||
)
|
||||
|
||||
// Available returns true if Pageant is running
|
||||
func Available() bool {
|
||||
if pageantWindow() != 0 {
|
||||
return true
|
||||
}
|
||||
conn, err := winio.DialPipe(sshAgentPipe, nil)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
conn.Close()
|
||||
return true
|
||||
}
|
||||
|
||||
// New returns a new agent.Agent and the (custom) connection it uses
|
||||
// to communicate with a running pagent.exe instance (see README.md)
|
||||
func New() (agent.Agent, net.Conn, error) {
|
||||
if !Available() {
|
||||
return nil, nil, errors.New("SSH agent requested but Pageant not running")
|
||||
if pageantWindow() != 0 {
|
||||
return agent.NewClient(&conn{}), nil, nil
|
||||
}
|
||||
|
||||
return agent.NewClient(&conn{}), nil, nil
|
||||
conn, err := winio.DialPipe(sshAgentPipe, nil)
|
||||
if err != nil {
|
||||
return nil, nil, errors.New(
|
||||
"SSH agent requested, but could not detect Pageant or Windows native SSH agent",
|
||||
)
|
||||
}
|
||||
return agent.NewClient(conn), nil, nil
|
||||
}
|
||||
|
||||
type conn struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue