Commit 8fe24042 authored by Eric's avatar Eric

[Update] add current UTC time

parent c62f77b1
......@@ -59,3 +59,7 @@ func Abs(x int) int {
}
return x
}
func CurrentUTCTime()string{
return time.Now().UTC().Format("2006-01-02 15:04:05 +0000")
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import (
gossh "golang.org/x/crypto/ssh"
"github.com/jumpserver/koko/pkg/cctx"
"github.com/jumpserver/koko/pkg/common"
"github.com/jumpserver/koko/pkg/config"
"github.com/jumpserver/koko/pkg/logger"
"github.com/jumpserver/koko/pkg/model"
......@@ -182,7 +183,7 @@ func (fs *sftpHandler) Filecmd(r *sftp.Request) (err error) {
RemoteAddr: fs.addr,
Operate: r.Method,
Path: realPathName,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer fs.CreateFTPLog(logData)
......@@ -242,7 +243,7 @@ func (fs *sftpHandler) Filewrite(r *sftp.Request) (io.WriterAt, error) {
RemoteAddr: fs.addr,
Operate: "Upload",
Path: realPathName,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer fs.CreateFTPLog(logData)
......@@ -281,7 +282,7 @@ func (fs *sftpHandler) Fileread(r *sftp.Request) (io.ReaderAt, error) {
RemoteAddr: fs.addr,
Operate: "Download",
Path: realPathName,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer fs.CreateFTPLog(logData)
......
......@@ -287,7 +287,7 @@ func (u *UserVolume) GetFile(path string) (reader io.ReadCloser, err error) {
RemoteAddr: u.Addr,
Operate: "Download",
Path: realPath,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......@@ -363,7 +363,7 @@ func (u *UserVolume) UploadFile(dir, filename string, reader io.Reader) (elfinde
RemoteAddr: u.Addr,
Operate: "Upload",
Path: realFilenamePath,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......@@ -456,7 +456,7 @@ func (u *UserVolume) MergeChunk(cid, total int, dirPath, filename string) (elfin
RemoteAddr: u.Addr,
Operate: "Upload",
Path: filenamePath,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......@@ -556,7 +556,7 @@ func (u *UserVolume) MakeDir(dir, newDirname string) (elfinder.FileDir, error) {
RemoteAddr: u.Addr,
Operate: "Mkdir",
Path: realDirPath,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......@@ -625,7 +625,7 @@ func (u *UserVolume) MakeFile(dir, newFilename string) (elfinder.FileDir, error)
RemoteAddr: u.Addr,
Operate: "Append",
Path: realFilePath,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......@@ -690,7 +690,7 @@ func (u *UserVolume) Rename(oldNamePath, newName string) (elfinder.FileDir, erro
RemoteAddr: u.Addr,
Operate: "Rename",
Path: fmt.Sprintf("%s=>%s", oldNamePath, newFilePath),
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......@@ -756,7 +756,7 @@ func (u *UserVolume) Remove(path string) error {
RemoteAddr: u.Addr,
Operate: "Delete",
Path: realPath,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......@@ -827,7 +827,7 @@ func (u *UserVolume) Paste(dir, filename, suffix string, reader io.ReadCloser) (
RemoteAddr: u.Addr,
Operate: "Append",
Path: realFilePath,
DataStart: time.Now().UTC().Format("2006-01-02 15:04:05 +0000"),
DataStart: common.CurrentUTCTime(),
IsSuccess: false,
}
defer u.CreateFTPLog(logData)
......
......@@ -8,6 +8,7 @@ import (
uuid "github.com/satori/go.uuid"
"github.com/jumpserver/koko/pkg/common"
"github.com/jumpserver/koko/pkg/config"
"github.com/jumpserver/koko/pkg/i18n"
"github.com/jumpserver/koko/pkg/logger"
......@@ -46,7 +47,7 @@ type SwitchSession struct {
func (s *SwitchSession) Initial() {
s.ID = uuid.NewV4().String()
s.DateStart = time.Now().UTC().Format("2006-01-02 15:04:05 +0000")
s.DateStart = common.CurrentUTCTime()
s.MaxIdleTime = config.GetConf().MaxIdleTime
s.cmdRecorder = NewCommandRecorder(s.ID)
s.replayRecorder = NewReplyRecord(s.ID)
......@@ -105,7 +106,7 @@ func (s *SwitchSession) generateCommandResult(command [2]string) *model.Command
// postBridge 桥接结束以后执行操作
func (s *SwitchSession) postBridge() {
s.DateEnd = time.Now().UTC().Format("2006-01-02 15:04:05 +0000")
s.DateEnd = common.CurrentUTCTime()
s.finished = true
s.parser.Close()
s.replayRecorder.End()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment