change log level for server

tls
dingjun 6 years ago
parent 1a4351c626
commit db1a4f8605

@ -95,9 +95,9 @@ func main() {
AuthLogCallback: func(c ssh.ConnMetadata, method string, err error) { AuthLogCallback: func(c ssh.ConnMetadata, method string, err error) {
if err != nil { if err != nil {
log.Debugf("%s", err.Error()) 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 { } 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 return
} }
log.Debugf("accept tcp connection from %s", c.RemoteAddr()) log.Infof("accept tcp connection from %s", c.RemoteAddr())
go func(c net.Conn) { go func(c net.Conn) {
defer c.Close() defer c.Close()

@ -79,7 +79,7 @@ func (sc *Server) handleNewChannelRequest(ch <-chan ssh.NewChannel) {
continue continue
} }
log.Debugf("reject channel request %s", newch.ChannelType()) log.Errorf("reject channel request %s", newch.ChannelType())
newch.Reject(ssh.UnknownChannelType, "unknown channel type") newch.Reject(ssh.UnknownChannelType, "unknown channel type")
} }
@ -189,7 +189,7 @@ func (sc *Server) handleSession(newch ssh.NewChannel) {
case "exec": case "exec":
ret = true ret = true
if err = ssh.Unmarshal(r.Payload, &_cmd); err == nil { 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" { if runtime.GOOS == "windows" {
cmd = exec.Command("powershell", "-Command", _cmd.Arg) cmd = exec.Command("powershell", "-Command", _cmd.Arg)
} else { } else {
@ -234,7 +234,7 @@ func handleShell(cmd *exec.Cmd, ch ssh.Channel) {
var _pty io.ReadWriteCloser var _pty io.ReadWriteCloser
var err error var err error
log.Debugln("start shell") log.Infoln("start shell")
//_pty, err = pty.Start(cmd) //_pty, err = pty.Start(cmd)
if runtime.GOOS == "unix" || runtime.GOOS == "linux" { if runtime.GOOS == "unix" || runtime.GOOS == "linux" {
@ -321,7 +321,7 @@ func handleDirectTcpip(newch ssh.NewChannel) {
err := ssh.Unmarshal(data, &r) err := ssh.Unmarshal(data, &r)
if err != nil { if err != nil {
log.Debugf("invalid ssh parameter") log.Errorln("invalid ssh parameter")
newch.Reject(ssh.ConnectionFailed, "invalid argument") newch.Reject(ssh.ConnectionFailed, "invalid argument")
return return
} }
@ -426,7 +426,7 @@ func (sc *Server) handleTcpipForward(req *ssh.Request) {
} }
a1 := l.Addr() a1 := l.Addr()
log.Debugf("Listening port %s", a1) log.Infof("Listening port %s", a1)
p := struct { p := struct {
Port uint32 Port uint32
}{ }{
@ -445,7 +445,7 @@ func (sc *Server) handleTcpipForward(req *ssh.Request) {
log.Debugf("%s", err.Error()) log.Debugf("%s", err.Error())
return return
} }
log.Debugf("accept connection from %s", c.RemoteAddr()) log.Infof("accept connection from %s", c.RemoteAddr())
go func(c net.Conn) { go func(c net.Conn) {
laddr := c.LocalAddr() laddr := c.LocalAddr()
raddr := c.RemoteAddr() raddr := c.RemoteAddr()

Loading…
Cancel
Save