Allow clients to Close a Session, general tidy up
- Allow clients to call Close on a Session to clean up resources - Switch to the %w verb for error wrapping - Fix typo on Port struct after verifying the server does not have a typo
This commit is contained in:
parent
22433a57db
commit
57d04dc5f0
5 changed files with 29 additions and 18 deletions
8
ssh.go
8
ssh.go
|
|
@ -36,24 +36,24 @@ func (s *sshSession) connect(ctx context.Context) error {
|
|||
|
||||
sshClientConn, chans, reqs, err := ssh.NewClientConn(s.socket, "", &clientConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating ssh client connection: %v", err)
|
||||
return fmt.Errorf("error creating ssh client connection: %w", err)
|
||||
}
|
||||
s.conn = sshClientConn
|
||||
|
||||
sshClient := ssh.NewClient(sshClientConn, chans, reqs)
|
||||
s.Session, err = sshClient.NewSession()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating ssh client session: %v", err)
|
||||
return fmt.Errorf("error creating ssh client session: %w", err)
|
||||
}
|
||||
|
||||
s.reader, err = s.Session.StdoutPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating ssh session reader: %v", err)
|
||||
return fmt.Errorf("error creating ssh session reader: %w", err)
|
||||
}
|
||||
|
||||
s.writer, err = s.Session.StdinPipe()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating ssh session writer: %v", err)
|
||||
return fmt.Errorf("error creating ssh session writer: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue