48 lines
853 B
Go
48 lines
853 B
Go
package sshutil
|
|
|
|
import "golang.org/x/crypto/ssh"
|
|
|
|
type EnvRequest struct {
|
|
Key, Value string
|
|
}
|
|
|
|
func ParseEnvRequest(data []byte) (*EnvRequest, error) {
|
|
r := new(EnvRequest)
|
|
if err := ssh.Unmarshal(data, r); err != nil {
|
|
return nil, err
|
|
}
|
|
return r, nil
|
|
}
|
|
|
|
type PTYRequest struct {
|
|
Term string
|
|
Columns uint32
|
|
Rows uint32
|
|
Width uint32
|
|
Height uint32
|
|
ModeList []byte
|
|
}
|
|
|
|
func ParsePTYRequest(data []byte) (*PTYRequest, error) {
|
|
r := new(PTYRequest)
|
|
if err := ssh.Unmarshal(data, r); err != nil {
|
|
return nil, err
|
|
}
|
|
return r, nil
|
|
}
|
|
|
|
type WindowChangeRequest struct {
|
|
Columns uint32
|
|
Rows uint32
|
|
Width uint32
|
|
Height uint32
|
|
}
|
|
|
|
func ParseWindowChangeRequest(data []byte) (*WindowChangeRequest, error) {
|
|
r := new(WindowChangeRequest)
|
|
if err := ssh.Unmarshal(data, r); err != nil {
|
|
return nil, err
|
|
}
|
|
return r, nil
|
|
}
|