minor fix while doing docs

This commit is contained in:
Boshi Lian 2022-07-05 20:31:14 +00:00
parent e1aa1c9823
commit 5e0572a43f
7 changed files with 43 additions and 30 deletions

View file

@ -4,6 +4,8 @@ import (
"fmt"
"io/ioutil"
"net"
"os"
"path"
"path/filepath"
"time"
@ -18,7 +20,7 @@ type daemon struct {
lis net.Listener
loginGraceTime time.Duration
uphook, downhook func(msg []byte) ([]byte, error)
recorddir string
}
func newDaemon(ctx *cli.Context) (*daemon, error) {
@ -128,7 +130,25 @@ func (d *daemon) run() error {
log.Infof("ssh connection pipe created %v -> %v", p.DownstreamConnMeta().RemoteAddr(), p.UpstreamConnMeta().RemoteAddr().String())
err = p.WaitWithHook(d.uphook, d.downhook)
var uphook func([]byte) ([]byte, error)
if d.recorddir != "" {
recorddir := path.Join(d.recorddir, p.DownstreamConnMeta().User())
err = os.MkdirAll(recorddir, 0700)
if err != nil {
log.Errorf("cannot create screen recording dir %v: %v", recorddir, err)
return
}
recorder, err := newFilePtyLogger(recorddir)
if err != nil {
log.Errorf("cannot create screen recording logger: %v", err)
return
}
uphook = recorder.loggingTty
}
err = p.WaitWithHook(uphook, nil)
log.Infof("connection from %v closed reason: %v", c.RemoteAddr(), err)
}(conn)

View file

@ -78,7 +78,7 @@ func (g *GrpcPlugin) InstallPiperConfig(config *ssh.PiperConfig) error {
log.Debugf("downstream %v is sending none auth", conn.RemoteAddr().String())
u, err := g.NoneAuthCallback(conn, challengeCtx)
if err != nil {
log.Debugf("cannot create upstream for %v with none auth: %v", conn.RemoteAddr().String(), err)
log.Errorf("cannot create upstream for %v with none auth: %v", conn.RemoteAddr().String(), err)
}
return u, err
}
@ -87,7 +87,7 @@ func (g *GrpcPlugin) InstallPiperConfig(config *ssh.PiperConfig) error {
log.Debugf("downstream %v is sending password auth", conn.RemoteAddr().String())
u, err := g.PasswordCallback(conn, password, challengeCtx)
if err != nil {
log.Debugf("cannot create upstream for %v with password auth: %v", conn.RemoteAddr().String(), err)
log.Errorf("cannot create upstream for %v with password auth: %v", conn.RemoteAddr().String(), err)
}
return u, err
}
@ -96,7 +96,7 @@ func (g *GrpcPlugin) InstallPiperConfig(config *ssh.PiperConfig) error {
log.Debugf("downstream %v is sending public key auth", conn.RemoteAddr().String())
u, err := g.PublicKeyCallback(conn, key, challengeCtx)
if err != nil {
log.Debugf("cannot create upstream for %v with public key auth: %v", conn.RemoteAddr().String(), err)
log.Errorf("cannot create upstream for %v with public key auth: %v", conn.RemoteAddr().String(), err)
}
return u, err
}
@ -105,7 +105,7 @@ func (g *GrpcPlugin) InstallPiperConfig(config *ssh.PiperConfig) error {
log.Debugf("downstream %v is sending keyboard interactive auth", conn.RemoteAddr().String())
u, err := g.KeyboardInteractiveCallback(conn, challenge, challengeCtx)
if err != nil {
log.Debugf("cannot create upstream for %v with keyboard interactive auth: %v", conn.RemoteAddr().String(), err)
log.Errorf("cannot create upstream for %v with keyboard interactive auth: %v", conn.RemoteAddr().String(), err)
}
return u, err
}
@ -418,7 +418,7 @@ func (g *GrpcPlugin) KeyboardInteractiveCallback(conn ssh.ConnMetadata, client s
echo = append(echo, q.GetEcho())
}
ans, err := client(conn.User(), r.GetInstruction(), questions, echo)
ans, err := client(r.GetName(), r.GetInstruction(), questions, echo)
if err != nil {
return nil, err
}

View file

@ -164,15 +164,7 @@ func main() {
return err
}
recorddir := ctx.String("typescript-log-dir")
if recorddir != "" {
recorder, err := newFilePtyLogger(recorddir)
if err != nil {
return err
}
d.uphook = recorder.loggingTty
}
d.recorddir = ctx.String("typescript-log-dir")
return d.run()
},