aboutsummaryrefslogtreecommitdiff
path: root/lib/ssh
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-12-22 14:07:03 +0700
committerShulhan <ms@kilabit.info>2023-12-22 15:21:40 +0700
commit8932e7ab20fcc78caeabcdaab5c01e9dbbbd7a17 (patch)
tree30f586e39a71ec064bf7a9a1124b7d53968742ab /lib/ssh
parent7a63c70fb199eda55b512bd92163d7d51d39a2a3 (diff)
downloadpakakeh.go-8932e7ab20fcc78caeabcdaab5c01e9dbbbd7a17.tar.xz
lib/ssh: add parameter context to Execute method
This changes require the fork of our golang.org/x/crypto.
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/client.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/ssh/client.go b/lib/ssh/client.go
index 06243db0..d1ead996 100644
--- a/lib/ssh/client.go
+++ b/lib/ssh/client.go
@@ -6,6 +6,7 @@ package ssh
import (
"bytes"
+ "context"
"fmt"
"io"
"log"
@@ -291,7 +292,7 @@ func (cl *Client) Close() (err error) {
}
// Execute a command on remote server.
-func (cl *Client) Execute(cmd string) (err error) {
+func (cl *Client) Execute(ctx context.Context, cmd string) (err error) {
sess, err := cl.Client.NewSession()
if err != nil {
return fmt.Errorf("ssh: NewSession: " + err.Error())
@@ -307,7 +308,7 @@ func (cl *Client) Execute(cmd string) (err error) {
}
}
- err = sess.Run(cmd)
+ err = sess.RunWithContext(ctx, cmd)
if err != nil {
err = fmt.Errorf("ssh: Run %q: %s", cmd, err.Error())
}