aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--go.mod2
-rw-r--r--go.sum6
-rw-r--r--lib/ssh/client.go5
3 files changed, 7 insertions, 6 deletions
diff --git a/go.mod b/go.mod
index 9cbbf390..15c52d33 100644
--- a/go.mod
+++ b/go.mod
@@ -9,4 +9,6 @@ require (
golang.org/x/term v0.15.0
)
+replace golang.org/x/crypto => git.sr.ht/~shulhan/go-x-crypto v0.17.1-0.20231222080754-445dd75cd339
+
//replace golang.org/x/term => ../../../golang.org/x/term
diff --git a/go.sum b/go.sum
index ce3541d0..f688c057 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,5 @@
-golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
-golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
-golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
-golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
+git.sr.ht/~shulhan/go-x-crypto v0.17.1-0.20231222080754-445dd75cd339 h1:iq2/NVwTZvvs4QWBJaBt1r+ZNaXf/cAOAO5k8Eplqtg=
+git.sr.ht/~shulhan/go-x-crypto v0.17.1-0.20231222080754-445dd75cd339/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
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())
}