align log level across plugins
happy lint happy lint
This commit is contained in:
parent
d3ec47f4ec
commit
319824e564
13 changed files with 286 additions and 230 deletions
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
|
|
@ -39,7 +38,7 @@ func newDaemon(ctx *cli.Context) (*daemon, error) {
|
|||
log.Infof("found host keys %v", privateKeys)
|
||||
for _, privateKey := range privateKeys {
|
||||
log.Infof("loading host key %v", privateKey)
|
||||
privateBytes, err := ioutil.ReadFile(privateKey)
|
||||
privateBytes, err := os.ReadFile(privateKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import (
|
|||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/tg123/sshpiper/cmd/sshpiperd/internal/plugin"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
|
@ -65,7 +65,7 @@ func createNetGrpcPlugin(args []string) (grpcPlugin *plugin.GrpcPlugin, err erro
|
|||
|
||||
cacert := c.String("cacert")
|
||||
if cacert != "" {
|
||||
ca, err := ioutil.ReadFile(cacert)
|
||||
ca, err := os.ReadFile(cacert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -475,7 +475,16 @@ func (g *GrpcPlugin) BannerCallback(conn ssh.ConnMetadata, challengeCtx ssh.Chal
|
|||
}
|
||||
|
||||
func (g *GrpcPlugin) RecvLogs(writer io.Writer) error {
|
||||
stream, err := g.client.Logs(context.Background(), &libplugin.StartLogRequest{})
|
||||
uid, err := uuid.NewRandom()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stream, err := g.client.Logs(context.Background(), &libplugin.StartLogRequest{
|
||||
UniqId: uid.String(),
|
||||
Level: log.GetLevel().String(),
|
||||
Tty: checkIfTerminal(log.StandardLogger().Out),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
25
cmd/sshpiperd/internal/plugin/tty.go
Normal file
25
cmd/sshpiperd/internal/plugin/tty.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const ioctlReadTermios = unix.TCGETS
|
||||
|
||||
func isTerminal(fd int) bool {
|
||||
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// code from logrus
|
||||
func checkIfTerminal(w io.Writer) bool {
|
||||
switch v := w.(type) {
|
||||
case *os.File:
|
||||
return isTerminal(int(v.Fd()))
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue