mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-10-14 03:23:47 +08:00
refactor: divide log to session and backend (#487)
* refactor: divide log to session and backend
This commit is contained in:
@@ -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{
|
||||
|
Reference in New Issue
Block a user