sshpoke/internal/server/driver/ssh/sshtun/printer.go

22 lines
357 B
Go
Raw Normal View History

2023-11-18 21:23:29 +03:00
package sshtun
import (
"bufio"
"go.uber.org/zap"
"golang.org/x/crypto/ssh"
)
func StdoutPrinterSessionCallback(log *zap.SugaredLogger) SessionCallback {
return func(session *ssh.Session) {
stdout, err := session.StdoutPipe()
if err != nil {
return
}
scan := bufio.NewScanner(stdout)
for scan.Scan() {
log.Debug(scan.Text())
}
}
}