Skip to content

Commit 3ec328e

Browse files
committed
perf: update go version and deps
1 parent fe2d8f5 commit 3ec328e

File tree

3 files changed

+103
-196
lines changed

3 files changed

+103
-196
lines changed

cmd/ssh.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,7 +18,6 @@ package cmd
1818
import (
1919
"fmt"
2020
"io"
21-
"io/ioutil"
2221
"log"
2322
"net"
2423
"os"
@@ -27,7 +26,7 @@ import (
2726

2827
"github.com/spf13/cobra"
2928
gossh "golang.org/x/crypto/ssh"
30-
"golang.org/x/crypto/ssh/terminal"
29+
"golang.org/x/term"
3130
)
3231

3332
var (
@@ -95,20 +94,19 @@ jmstool ssh root@127.0.0.1 -p 2222
9594
auths = append(auths, gossh.Password(password))
9695
}
9796

98-
9997
if password == "" && privateFile == "" {
10098
if _, err := fmt.Fprintf(os.Stdout, "%s@%s password: ", username, host); err != nil {
10199
log.Fatal(err)
102100
}
103-
if result, err := terminal.ReadPassword(int(os.Stdout.Fd())); err != nil {
101+
if result, err := term.ReadPassword(int(os.Stdout.Fd())); err != nil {
104102
log.Fatal(err)
105103
} else {
106104
auths = append(auths, gossh.Password(string(result)))
107105
}
108106

109107
}
110108
if privateFile != "" {
111-
raw, err := ioutil.ReadFile(privateFile)
109+
raw, err := os.ReadFile(privateFile)
112110
if err != nil {
113111
log.Fatal(err)
114112
}
@@ -147,7 +145,7 @@ jmstool ssh root@127.0.0.1 -p 2222
147145
xterm = "xterm-256color"
148146
}
149147
fd := int(os.Stdin.Fd())
150-
w, h, _ := terminal.GetSize(fd)
148+
w, h, _ := term.GetSize(fd)
151149
err = sess.RequestPty(xterm, h, w, modes)
152150
if err != nil {
153151
log.Fatalf("RequestPty err: %s", err)
@@ -160,11 +158,11 @@ jmstool ssh root@127.0.0.1 -p 2222
160158
if err != nil {
161159
log.Fatalf("StdoutPipe err: %s", err)
162160
}
163-
state, err := terminal.MakeRaw(fd)
161+
state, err := term.MakeRaw(fd)
164162
if err != nil {
165163
log.Fatalf("MakeRaw err: %s", err)
166164
}
167-
defer terminal.Restore(fd, state)
165+
defer term.Restore(fd, state)
168166

169167
go io.Copy(in, os.Stdin)
170168
go io.Copy(os.Stdout, out)
@@ -186,7 +184,7 @@ jmstool ssh root@127.0.0.1 -p 2222
186184
if sigwinch == nil {
187185
return
188186
}
189-
w, h, err := terminal.GetSize(fd)
187+
w, h, err := term.GetSize(fd)
190188
if err != nil {
191189
log.Printf("Unable to send window-change reqest: %s. \n", err)
192190
continue
@@ -210,6 +208,7 @@ func init() {
210208
sshCmd.PersistentFlags().StringP("port", "p", "22", "ssh port")
211209
sshCmd.PersistentFlags().StringP("password", "P", "", "ssh password")
212210
sshCmd.PersistentFlags().StringP("identity", "i", "", "identity_file")
211+
sshCmd.PersistentFlags().StringP("config", "c", "", "config file for cipher, kex, hostkey")
213212
// Here you will define your flags and configuration settings.
214213

215214
// Cobra supports Persistent Flags which will work for this command

go.mod

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
module github.com/LeeEirc/jmstool
22

3-
go 1.15
3+
go 1.23
44

55
require (
6-
github.com/LeeEirc/tclientlib v0.0.0-20210426030239-9601a77132d6
6+
github.com/LeeEirc/tclientlib v0.0.2
77
github.com/mitchellh/go-homedir v1.1.0
8-
github.com/spf13/cobra v1.0.0
9-
github.com/spf13/viper v1.6.3
10-
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
11-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
8+
github.com/spf13/cobra v1.8.1
9+
github.com/spf13/viper v1.19.0
10+
golang.org/x/crypto v0.31.0
11+
golang.org/x/term v0.27.0
12+
)
13+
14+
require (
15+
github.com/fsnotify/fsnotify v1.8.0 // indirect
16+
github.com/hashicorp/hcl v1.0.0 // indirect
17+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
18+
github.com/magiconair/properties v1.8.9 // indirect
19+
github.com/mitchellh/mapstructure v1.5.0 // indirect
20+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
21+
github.com/sagikazarmark/locafero v0.6.0 // indirect
22+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
23+
github.com/sourcegraph/conc v0.3.0 // indirect
24+
github.com/spf13/afero v1.11.0 // indirect
25+
github.com/spf13/cast v1.7.1 // indirect
26+
github.com/spf13/pflag v1.0.5 // indirect
27+
github.com/subosito/gotenv v1.6.0 // indirect
28+
go.uber.org/multierr v1.11.0 // indirect
29+
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
30+
golang.org/x/sys v0.28.0 // indirect
31+
golang.org/x/text v0.21.0 // indirect
32+
gopkg.in/ini.v1 v1.67.0 // indirect
33+
gopkg.in/yaml.v3 v3.0.1 // indirect
1234
)

0 commit comments

Comments
 (0)