-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net.Conn for pageant with example and tests #16
base: feat/ssh-auth-sock
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
} | ||
|
||
type conn struct { | ||
sync.Mutex | ||
buf []byte | ||
} | ||
|
||
func (c *conn) Close() { | ||
func (c *conn) Close() error { |
There was a problem hiding this comment.
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
.
IMHO best: func New() net.Conn{...}
...
conn:=sshagent.New()
if conn==nil{
log.Fatalf(...
}
defer conn.Close()
ag:=agent.NewClient(conn) where conn from:
Maybe conn.Close() not important for &conn{} , but it's important for the rest |
Tests and examle works for me.
Congratulations on Programmer's Day!