From 0c1b13fa828ebb189c07eeb48a58d3db389f540e Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Thu, 29 Oct 2020 23:01:04 +0100 Subject: [PATCH] require sourceRedirect if source is redirect --- conf/pathconf.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/conf/pathconf.go b/conf/pathconf.go index b284f3ff..d7fe5a0d 100644 --- a/conf/pathconf.go +++ b/conf/pathconf.go @@ -63,7 +63,7 @@ func (pconf *PathConf) fillAndCheck(name string) error { u, err := url.Parse(pconf.Source) if err != nil { - return fmt.Errorf("'%s' is not a valid url", pconf.Source) + return fmt.Errorf("'%s' is not a valid rtsp url", pconf.Source) } if u.User != nil { @@ -97,7 +97,7 @@ func (pconf *PathConf) fillAndCheck(name string) error { u, err := url.Parse(pconf.Source) if err != nil { - return fmt.Errorf("'%s' is not a valid url", pconf.Source) + return fmt.Errorf("'%s' is not a valid rtmp url", pconf.Source) } if u.User != nil { @@ -112,16 +112,21 @@ func (pconf *PathConf) fillAndCheck(name string) error { } else if pconf.Source == "record" { } else if pconf.Source == "redirect" { + if pconf.SourceRedirect == "" { + return fmt.Errorf("source redirect must be filled") + } - } else { - return fmt.Errorf("unsupported source: '%s'", pconf.Source) - } - - if pconf.SourceRedirect != "" { _, err := url.Parse(pconf.SourceRedirect) if err != nil { - return fmt.Errorf("'%s' is not a valid url", pconf.SourceRedirect) + return fmt.Errorf("'%s' is not a valid rtsp url", pconf.SourceRedirect) } + + if u.Scheme != "rtsp" { + return fmt.Errorf("'%s' is not a valid rtsp url", pconf.SourceRedirect) + } + + } else { + return fmt.Errorf("unsupported source: '%s'", pconf.Source) } if pconf.PublishUser != "" {