fix version
This commit is contained in:
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.24.0
|
|||||||
require (
|
require (
|
||||||
github.com/creack/pty/v2 v2.0.1
|
github.com/creack/pty/v2 v2.0.1
|
||||||
golang.org/x/crypto v0.43.0
|
golang.org/x/crypto v0.43.0
|
||||||
golang.org/x/term v0.37.0
|
golang.org/x/term v0.36.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/sys v0.37.0 // indirect
|
require golang.org/x/sys v0.37.0 // indirect
|
||||||
|
|||||||
10
main.go
10
main.go
@@ -97,15 +97,15 @@ func handleChannel(channel ssh.Channel, requests <-chan *ssh.Request) {
|
|||||||
defer channel.Close()
|
defer channel.Close()
|
||||||
var ptmx *os.File
|
var ptmx *os.File
|
||||||
var termWidth, termHeight uint32 = 80, 24
|
var termWidth, termHeight uint32 = 80, 24
|
||||||
var term string
|
var clientTerm string
|
||||||
for req := range requests {
|
for req := range requests {
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
case "pty-req":
|
case "pty-req":
|
||||||
if len(req.Payload) >= 4 {
|
if len(req.Payload) >= 4 {
|
||||||
termLen := binary.BigEndian.Uint32(req.Payload[0:4])
|
termLen := binary.BigEndian.Uint32(req.Payload[0:4])
|
||||||
if len(req.Payload) >= int(4+termLen+16) {
|
if len(req.Payload) >= int(4+termLen+16) {
|
||||||
term = string(req.Payload[4 : 4+termLen])
|
clientTerm = string(req.Payload[4 : 4+termLen])
|
||||||
log.Println("Client TERM:", term)
|
log.Println("Client TERM:", clientTerm)
|
||||||
cols := binary.BigEndian.Uint32(req.Payload[4+termLen : 4+termLen+4])
|
cols := binary.BigEndian.Uint32(req.Payload[4+termLen : 4+termLen+4])
|
||||||
rows := binary.BigEndian.Uint32(req.Payload[4+termLen+4 : 4+termLen+8])
|
rows := binary.BigEndian.Uint32(req.Payload[4+termLen+4 : 4+termLen+8])
|
||||||
if cols > 0 {
|
if cols > 0 {
|
||||||
@@ -138,8 +138,8 @@ func handleChannel(channel ssh.Channel, requests <-chan *ssh.Request) {
|
|||||||
}
|
}
|
||||||
cmd := exec.Command(command)
|
cmd := exec.Command(command)
|
||||||
envTerm := "TERM=xterm-256color"
|
envTerm := "TERM=xterm-256color"
|
||||||
if term != "" {
|
if clientTerm != "" {
|
||||||
envTerm = "TERM=" + term
|
envTerm = "TERM=" + clientTerm
|
||||||
}
|
}
|
||||||
cmd.Env = []string{"PATH=/bin", envTerm}
|
cmd.Env = []string{"PATH=/bin", envTerm}
|
||||||
cmd.Dir = "/"
|
cmd.Dir = "/"
|
||||||
|
|||||||
Reference in New Issue
Block a user