happy lint
This commit is contained in:
parent
93da136a94
commit
bc9875c4b5
7 changed files with 39 additions and 27 deletions
|
|
@ -90,6 +90,8 @@ func createNetGrpcPlugin(args []string) (grpcPlugin *plugin.GrpcPlugin, err erro
|
|||
return err
|
||||
}
|
||||
|
||||
grpcPlugin.Name = fmt.Sprintf("grpc://%s", c.String("endpoint"))
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"net"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
|
@ -17,9 +16,11 @@ import (
|
|||
"github.com/tg123/sshpiper/libplugin/ioconn"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
type GrpcPlugin struct {
|
||||
Name string
|
||||
OnNextPlugin func(conn ssh.ChallengeContext, upstream *libplugin.UpstreamNextPluginAuth) error
|
||||
|
||||
grpcconn *grpc.ClientConn
|
||||
|
|
@ -249,7 +250,7 @@ func (g *GrpcPlugin) UpstreamAuthFailureCallbackRemote(conn ssh.ConnMetadata, me
|
|||
}
|
||||
}
|
||||
|
||||
g.client.UpstreamAuthFailureNotice(context.Background(), &libplugin.UpstreamAuthFailureNoticeRequest{
|
||||
_, _ = g.client.UpstreamAuthFailureNotice(context.Background(), &libplugin.UpstreamAuthFailureNoticeRequest{
|
||||
Meta: toMeta(challengeCtx, conn),
|
||||
Method: method,
|
||||
Error: err.Error(),
|
||||
|
|
@ -396,8 +397,9 @@ func (g *GrpcPlugin) KeyboardInteractiveCallback(conn ssh.ConnMetadata, client s
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer stream.CloseSend()
|
||||
defer func() {
|
||||
_ = stream.CloseSend()
|
||||
}()
|
||||
|
||||
for {
|
||||
msg, err := stream.Recv()
|
||||
|
|
@ -497,7 +499,9 @@ func DialCmd(cmd *exec.Cmd) (*CmdPlugin, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
go io.Copy(log.StandardLogger().Out, stderr)
|
||||
go func() {
|
||||
_, _ = io.Copy(log.StandardLogger().Out, stderr)
|
||||
}()
|
||||
|
||||
go func() {
|
||||
err := cmd.Wait()
|
||||
|
|
@ -506,7 +510,7 @@ func DialCmd(cmd *exec.Cmd) (*CmdPlugin, error) {
|
|||
}
|
||||
}()
|
||||
|
||||
conn, err := grpc.Dial("", grpc.WithInsecure(), grpc.WithDialer(func(_ string, _ time.Duration) (net.Conn, error) {
|
||||
conn, err := grpc.Dial("", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(func(_ context.Context, _ string) (net.Conn, error) {
|
||||
return cmdconn, nil
|
||||
}))
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ func createPlugin(args []string) (*plugin.GrpcPlugin, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
p.Name = exe
|
||||
|
||||
return &p.GrpcPlugin, nil
|
||||
}
|
||||
}
|
||||
|
|
@ -157,7 +159,11 @@ func main() {
|
|||
return err
|
||||
}
|
||||
|
||||
go p.RecvLogs(log.StandardLogger().Out)
|
||||
go func() {
|
||||
if err := p.RecvLogs(log.StandardLogger().Out); err != nil {
|
||||
log.Errorf("plugin %v recv logs error: %v", p.Name, err)
|
||||
}
|
||||
}()
|
||||
plugins = append(plugins, p)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue