From db1a4f8605991717b9bb72ea91353604a633f94f Mon Sep 17 00:00:00 2001 From: dingjun Date: Sat, 13 Apr 2019 16:11:11 +0800 Subject: [PATCH] change log level for server --- obfsshd/server.go | 6 +++--- server.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/obfsshd/server.go b/obfsshd/server.go index ad4168a..b2b8605 100644 --- a/obfsshd/server.go +++ b/obfsshd/server.go @@ -95,9 +95,9 @@ func main() { AuthLogCallback: func(c ssh.ConnMetadata, method string, err error) { if err != nil { log.Debugf("%s", err.Error()) - log.Debugf("%s auth failed for %s from %s", method, c.User(), c.RemoteAddr()) + log.Errorf("%s auth failed for %s from %s", method, c.User(), c.RemoteAddr()) } else { - log.Debugf("Accepted %s for user %s from %s", method, c.User(), c.RemoteAddr()) + log.Printf("Accepted %s for user %s from %s", method, c.User(), c.RemoteAddr()) } }, } @@ -141,7 +141,7 @@ func main() { return } - log.Debugf("accept tcp connection from %s", c.RemoteAddr()) + log.Infof("accept tcp connection from %s", c.RemoteAddr()) go func(c net.Conn) { defer c.Close() diff --git a/server.go b/server.go index fdc0511..a278d59 100644 --- a/server.go +++ b/server.go @@ -79,7 +79,7 @@ func (sc *Server) handleNewChannelRequest(ch <-chan ssh.NewChannel) { continue } - log.Debugf("reject channel request %s", newch.ChannelType()) + log.Errorf("reject channel request %s", newch.ChannelType()) newch.Reject(ssh.UnknownChannelType, "unknown channel type") } @@ -189,7 +189,7 @@ func (sc *Server) handleSession(newch ssh.NewChannel) { case "exec": ret = true if err = ssh.Unmarshal(r.Payload, &_cmd); err == nil { - log.Debugln("execute command", _cmd.Arg) + log.Infoln("execute command", _cmd.Arg) if runtime.GOOS == "windows" { cmd = exec.Command("powershell", "-Command", _cmd.Arg) } else { @@ -234,7 +234,7 @@ func handleShell(cmd *exec.Cmd, ch ssh.Channel) { var _pty io.ReadWriteCloser var err error - log.Debugln("start shell") + log.Infoln("start shell") //_pty, err = pty.Start(cmd) if runtime.GOOS == "unix" || runtime.GOOS == "linux" { @@ -321,7 +321,7 @@ func handleDirectTcpip(newch ssh.NewChannel) { err := ssh.Unmarshal(data, &r) if err != nil { - log.Debugf("invalid ssh parameter") + log.Errorln("invalid ssh parameter") newch.Reject(ssh.ConnectionFailed, "invalid argument") return } @@ -426,7 +426,7 @@ func (sc *Server) handleTcpipForward(req *ssh.Request) { } a1 := l.Addr() - log.Debugf("Listening port %s", a1) + log.Infof("Listening port %s", a1) p := struct { Port uint32 }{ @@ -445,7 +445,7 @@ func (sc *Server) handleTcpipForward(req *ssh.Request) { log.Debugf("%s", err.Error()) return } - log.Debugf("accept connection from %s", c.RemoteAddr()) + log.Infof("accept connection from %s", c.RemoteAddr()) go func(c net.Conn) { laddr := c.LocalAddr() raddr := c.RemoteAddr()