mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-15 20:37:36 +02:00
Switch to slog, remove logrus (#1672)
This commit is contained in:
@@ -2,25 +2,25 @@ package sshd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/anmitsu/go-shlex"
|
||||
"github.com/armon/go-radix"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
type session struct {
|
||||
l *logrus.Entry
|
||||
l *slog.Logger
|
||||
c *ssh.ServerConn
|
||||
term *term.Terminal
|
||||
commands *radix.Tree
|
||||
cancel func()
|
||||
}
|
||||
|
||||
func NewSession(commands *radix.Tree, conn *ssh.ServerConn, chans <-chan ssh.NewChannel, cancel func(), l *logrus.Entry) *session {
|
||||
func NewSession(commands *radix.Tree, conn *ssh.ServerConn, chans <-chan ssh.NewChannel, cancel func(), l *slog.Logger) *session {
|
||||
s := &session{
|
||||
commands: radix.NewFromMap(commands.ToMap()),
|
||||
l: l,
|
||||
@@ -45,14 +45,14 @@ func (s *session) handleChannels(chans <-chan ssh.NewChannel) {
|
||||
defer s.Close()
|
||||
for newChannel := range chans {
|
||||
if newChannel.ChannelType() != "session" {
|
||||
s.l.WithField("sshChannelType", newChannel.ChannelType()).Error("unknown channel type")
|
||||
s.l.Error("unknown channel type", "sshChannelType", newChannel.ChannelType())
|
||||
newChannel.Reject(ssh.UnknownChannelType, "unknown channel type")
|
||||
continue
|
||||
}
|
||||
|
||||
channel, requests, err := newChannel.Accept()
|
||||
if err != nil {
|
||||
s.l.WithError(err).Warn("could not accept channel")
|
||||
s.l.Warn("could not accept channel", "error", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -95,12 +95,12 @@ func (s *session) handleRequests(in <-chan *ssh.Request, channel ssh.Channel) {
|
||||
return
|
||||
|
||||
default:
|
||||
s.l.WithField("sshRequest", req.Type).Debug("Rejected unknown request")
|
||||
s.l.Debug("Rejected unknown request", "sshRequest", req.Type)
|
||||
err = req.Reply(false, nil)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
s.l.WithError(err).Info("Error handling ssh session requests")
|
||||
s.l.Info("Error handling ssh session requests", "error", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user