Skip to content

Conversation

@abakum
Copy link
Contributor

@abakum abakum commented Dec 10, 2023

Tests and examle works for me.
Congratulations on Programmer's Day!

Copy link
Member

@svanharmelen svanharmelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have two initials questions/suggestions... As for testing this myself, I should have access to a Windows machine later this week so I can play with it a little. Thanks so far!

func New() (agent.Agent, net.Conn, error) {
if pageantWindow() != 0 {
return agent.NewClient(&conn{}), nil, nil
return agent.NewClient(&conn{}), &conn{}, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of returning a fake net.Conn here instead of just returning nil to indicate to a user there is no underlying net.Conn connection to be managed/closed?

I think we should omit this and also remove the methods you added for similarity with net.Conn.

I think

}

func (c *conn) Close() {
func (c *conn) Close() error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is also done to mimic net.Conn? Inline with my other comment I suggest we do not mask this conn type so we can return it as some kind a fake net.Conn.

@abakum
Copy link
Contributor Author

abakum commented Dec 10, 2023

IMHO best:

func New() net.Conn{...}
...
conn:=sshagent.New()
if conn==nil{
 log.Fatalf(...
}
defer conn.Close()
ag:=agent.NewClient(conn)

where conn from:

  • &conn{} if pageant window present
  • winio.DialPipe(... if SSH_AUTH_SOCK or \.\pipe\openssh-ssh-agent is present
  • net.Dial("unix",... if SSH_AUTH_SOCK is present

Maybe conn.Close() not important for &conn{} , but it's important for the rest
Please look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants