sshpoke/internal/server/driver/ssh/sshtun/printer.go
2023-11-18 21:23:29 +03:00

22 lines
357 B
Go

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())
}
}
}