Commit 8fe24042 authored by Eric's avatar Eric

[Update] add current UTC time

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