Преглед изворни кода

Fixes: fail2ban message wasn't output; suppress noise SSH auth log

Rod Hynes пре 9 година
родитељ
комит
d24f918c5a
1 измењених фајлова са 10 додато и 1 уклоњено
  1. 10 1
      psiphon/server/tunnelServer.go

+ 10 - 1
psiphon/server/tunnelServer.go

@@ -566,7 +566,14 @@ func (sshClient *sshClient) passwordCallback(conn ssh.ConnMetadata, password []b
 }
 
 func (sshClient *sshClient) authLogCallback(conn ssh.ConnMetadata, method string, err error) {
+
 	if err != nil {
+
+		if method == "none" && err.Error() == "no auth passed yet" {
+			// In this case, the callback invocation is noise from auth negotiation
+			return
+		}
+
 		logFields := LogFields{"error": err, "method": method}
 		if sshClient.sshServer.support.Config.UseFail2Ban() {
 			clientIPAddress := psiphon.IPAddressFromAddr(conn.RemoteAddr())
@@ -575,8 +582,10 @@ func (sshClient *sshClient) authLogCallback(conn ssh.ConnMetadata, method string
 					sshClient.sshServer.support.Config.Fail2BanFormat, clientIPAddress)
 			}
 		}
-		log.WithContextFields(LogFields{"error": err, "method": method}).Error("authentication failed")
+		log.WithContextFields(logFields).Error("authentication failed")
+
 	} else {
+
 		log.WithContextFields(LogFields{"error": err, "method": method}).Debug("authentication success")
 	}
 }