refactor: divide log to session and backend (#487)

* refactor: divide log to session and backend
This commit is contained in:
naison
2025-03-23 13:59:10 +08:00
committed by GitHub
parent a5622b9439
commit b46f7a9877
107 changed files with 873 additions and 871 deletions

View File

@@ -8,8 +8,9 @@ import (
"net"
"github.com/gliderlabs/ssh"
log "github.com/sirupsen/logrus"
gossh "golang.org/x/crypto/ssh"
plog "github.com/wencaiwulue/kubevpn/v2/pkg/log"
)
func SSHListener(addr string) (net.Listener, error) {
@@ -17,7 +18,7 @@ func SSHListener(addr string) (net.Listener, error) {
if err != nil {
return nil, err
}
log.Debugf("starting ssh server on port %s...", addr)
plog.G(context.Background()).Debugf("starting ssh server on port %s...", addr)
return ln, err
}
@@ -32,7 +33,7 @@ func (s *sshHandler) Handle(ctx context.Context, conn net.Conn) {
forwardHandler := &ssh.ForwardedTCPHandler{}
server := ssh.Server{
LocalPortForwardingCallback: ssh.LocalPortForwardingCallback(func(ctx ssh.Context, dhost string, dport uint32) bool {
log.Println("Accepted forward", dhost, dport)
plog.G(ctx).Infoln("Accepted forward", dhost, dport)
return true
}),
Handler: ssh.Handler(func(s ssh.Session) {
@@ -40,7 +41,7 @@ func (s *sshHandler) Handle(ctx context.Context, conn net.Conn) {
select {}
}),
ReversePortForwardingCallback: ssh.ReversePortForwardingCallback(func(ctx ssh.Context, host string, port uint32) bool {
log.Println("attempt to bind", host, port, "granted")
plog.G(ctx).Infoln("attempt to bind", host, port, "granted")
return true
}),
RequestHandlers: map[string]ssh.RequestHandler{