From ed635db87ed534e54980572b63e8636779c609d0 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Wed, 22 Dec 2021 20:12:31 +0100 Subject: [PATCH] print debug log message in case of non-critical authentication errors --- internal/core/path.go | 3 ++- internal/core/rtsp_conn.go | 2 ++ internal/core/rtsp_session.go | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/core/path.go b/internal/core/path.go index fb0508b2..068fb282 100644 --- a/internal/core/path.go +++ b/internal/core/path.go @@ -39,7 +39,8 @@ func (e pathErrNoOnePublishing) Error() string { } type pathErrAuthNotCritical struct { - *base.Response + Message string + Response *base.Response } // Error implements the error interface. diff --git a/internal/core/rtsp_conn.go b/internal/core/rtsp_conn.go index daede0d7..34092842 100644 --- a/internal/core/rtsp_conn.go +++ b/internal/core/rtsp_conn.go @@ -147,6 +147,7 @@ func (c *rtspConn) authenticate( v := "IPCAM" return pathErrAuthNotCritical{ + Message: "unauthorized: " + err.Error(), Response: &base.Response{ StatusCode: base.StatusUnauthorized, Header: base.Header{ @@ -253,6 +254,7 @@ func (c *rtspConn) onDescribe(ctx *gortsplib.ServerHandlerOnDescribeCtx, if res.Err != nil { switch terr := res.Err.(type) { case pathErrAuthNotCritical: + c.log(logger.Debug, "non-critical authentication error: %s", terr.Message) return terr.Response, nil, nil case pathErrAuthCritical: diff --git a/internal/core/rtsp_session.go b/internal/core/rtsp_session.go index c0c4e2c0..43f77a68 100644 --- a/internal/core/rtsp_session.go +++ b/internal/core/rtsp_session.go @@ -168,6 +168,7 @@ func (s *rtspSession) onAnnounce(c *rtspConn, ctx *gortsplib.ServerHandlerOnAnno if res.Err != nil { switch terr := res.Err.(type) { case pathErrAuthNotCritical: + s.log(logger.Debug, "non-critical authentication error: %s", terr.Message) return terr.Response, nil case pathErrAuthCritical: @@ -226,6 +227,7 @@ func (s *rtspSession) onSetup(c *rtspConn, ctx *gortsplib.ServerHandlerOnSetupCt if res.Err != nil { switch terr := res.Err.(type) { case pathErrAuthNotCritical: + s.log(logger.Debug, "non-critical authentication error: %s", terr.Message) return terr.Response, nil, nil case pathErrAuthCritical: