22 lines
357 B
Go
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())
|
||
|
}
|
||
|
}
|
||
|
}
|