add remote address to transfer and commands logs

This commit is contained in:
Nicola Murino
2021-06-01 22:28:43 +02:00
parent 969c992bfd
commit 575bcf1f03
22 changed files with 134 additions and 122 deletions

View File

@@ -237,10 +237,11 @@ func ErrorToConsole(format string, v ...interface{}) {
}
// TransferLog logs uploads or downloads
func TransferLog(operation string, path string, elapsed int64, size int64, user string, connectionID string, protocol string) {
func TransferLog(operation, path string, elapsed int64, size int64, user, connectionID, protocol, remoteAddr string) {
logger.Info().
Timestamp().
Str("sender", operation).
Str("remote_addr", remoteAddr).
Int64("elapsed_ms", elapsed).
Int64("size_bytes", size).
Str("username", user).
@@ -252,10 +253,11 @@ func TransferLog(operation string, path string, elapsed int64, size int64, user
// CommandLog logs an SFTP/SCP/SSH command
func CommandLog(command, path, target, user, fileMode, connectionID, protocol string, uid, gid int, atime, mtime,
sshCommand string, size int64) {
sshCommand string, size int64, remoteAddr string) {
logger.Info().
Timestamp().
Str("sender", command).
Str("remote_addr", remoteAddr).
Str("username", user).
Str("file_path", path).
Str("target_path", target).