add buildtime to initpacket

This commit is contained in:
sawka
2023-04-12 21:45:45 -07:00
parent a4a4d53eb0
commit bab095d701
4 changed files with 10 additions and 2 deletions
+3 -2
View File
@@ -22,7 +22,7 @@ import (
"golang.org/x/sys/unix"
)
var BuildTime = "-"
var BuildTime = "0"
// func doMainRun(pk *packet.RunPacketType, sender *packet.PacketSender) {
// err := shexec.ValidateRunPacket(pk)
@@ -533,6 +533,7 @@ Examples:
}
func main() {
base.SetBuildTime(BuildTime)
if len(os.Args) == 1 {
handleUsage()
return
@@ -542,7 +543,7 @@ func main() {
handleUsage()
return
} else if firstArg == "--version" {
fmt.Printf("mshell %s\n", base.MShellVersion)
fmt.Printf("mshell %s+%s\n", base.MShellVersion, base.BuildTime)
return
} else if firstArg == "--test-env" {
state, err := shexec.GetShellState()
+5
View File
@@ -41,6 +41,7 @@ var sessionDirCache = make(map[string]string)
var baseLock = &sync.Mutex{}
var DebugLogEnabled = false
var DebugLogger *log.Logger
var BuildTime string = "0"
type CommandFileNames struct {
PtyOutFile string
@@ -50,6 +51,10 @@ type CommandFileNames struct {
type CommandKey string
func SetBuildTime(build string) {
BuildTime = build
}
func MakeCommandKey(sessionId string, cmdId string) CommandKey {
if sessionId == "" && cmdId == "" {
return CommandKey("")
+1
View File
@@ -461,6 +461,7 @@ type InitPacketType struct {
Type string `json:"type"`
RespId string `json:"respid,omitempty"`
Version string `json:"version"`
BuildTime string `json:"buildtime,omitempty"`
MShellHomeDir string `json:"mshellhomedir,omitempty"`
HomeDir string `json:"homedir,omitempty"`
State *ShellState `json:"state,omitempty"`
+1
View File
@@ -1405,6 +1405,7 @@ func (c *ShExecType) WaitForCommand() *packet.CmdDonePacketType {
func MakeInitPacket() *packet.InitPacketType {
initPacket := packet.MakeInitPacket()
initPacket.Version = base.MShellVersion
initPacket.BuildTime = base.BuildTime
initPacket.HomeDir = base.GetHomeDir()
initPacket.MShellHomeDir = base.GetMShellHomeDir()
if user, _ := user.Current(); user != nil {