From b0fa5abe31c3952da9e47951d7b8ec673a394b43 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 25 Apr 2020 11:49:21 -0700 Subject: [PATCH] Less error spam for things not actually broken --- api/sftp_endpoints.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/sftp_endpoints.go b/api/sftp_endpoints.go index a755373..f0f7df8 100644 --- a/api/sftp_endpoints.go +++ b/api/sftp_endpoints.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/pkg/errors" "github.com/pterodactyl/sftp-server" + "go.uber.org/zap" ) func (r *PanelRequest) ValidateSftpCredentials(request sftp_server.AuthenticationRequest) (*sftp_server.AuthenticationResponse, error) { @@ -21,11 +22,16 @@ func (r *PanelRequest) ValidateSftpCredentials(request sftp_server.Authenticatio r.Response = resp if r.HasError() { - if r.HttpResponseCode() == 403 { - return nil, sftp_server.InvalidCredentialsError{} + if r.HttpResponseCode() >= 400 && r.HttpResponseCode() < 500 { + zap.S().Debugw("failed to validate server credentials for SFTP", zap.String("error", r.Error().String())) + + return nil, new(sftp_server.InvalidCredentialsError) } - return nil, errors.WithStack(errors.New(r.Error().String())) + rerr := errors.New(r.Error().String()) + zap.S().Warnw("error validating SFTP credentials", zap.Error(rerr)) + + return nil, rerr } response := new(sftp_server.AuthenticationResponse)