Skip to content

Commit

Permalink
do not add an 'all' path automatically if not present in the configur…
Browse files Browse the repository at this point in the history
…ation file
  • Loading branch information
aler9 committed Nov 6, 2021
1 parent 5f3ceb6 commit 08fa61e
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 28 deletions.
8 changes: 4 additions & 4 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ func (conf *Conf) CheckAndFillMissing() error {
conf.HLSAllowOrigin = "*"
}

if len(conf.Paths) == 0 {
conf.Paths = map[string]*PathConf{
"all": {},
}
// do not add automatically "all", since user may want to
// initialize all paths through API or hot reloading.
if conf.Paths == nil {
conf.Paths = make(map[string]*PathConf)
}

// "all" is an alias for "~^.*$"
Expand Down
27 changes: 19 additions & 8 deletions internal/core/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,14 @@ func TestAPIList(t *testing.T) {
conf := "api: yes\n"

if ca == "rtsps" {
conf += "protocols: [tcp]\n"
conf += "encryption: strict\n"
conf += "protocols: [tcp]\n" +
"encryption: strict\n" +
"serverCert: " + serverCertFpath + "\n" +
"serverKey: " + serverKeyFpath + "\n"
}

conf += "serverCert: " + serverCertFpath + "\n"
conf += "serverKey: " + serverKeyFpath + "\n"
conf += "paths:\n" +
" all:\n"

p, ok := newInstance(conf)
require.Equal(t, true, ok)
Expand Down Expand Up @@ -348,10 +350,19 @@ func TestAPIKick(t *testing.T) {
"rtmp",
} {
t.Run(ca, func(t *testing.T) {
p, ok := newInstance("api: yes\n" +
"encryption: optional\n" +
"serverCert: " + serverCertFpath + "\n" +
"serverKey: " + serverKeyFpath + "\n")
conf := "api: yes\n"

if ca == "rtsps" {
conf += "protocols: [tcp]\n" +
"encryption: strict\n" +
"serverCert: " + serverCertFpath + "\n" +
"serverKey: " + serverKeyFpath + "\n"
}

conf += "paths:\n" +
" all:\n"

p, ok := newInstance(conf)
require.Equal(t, true, ok)
defer p.close()

Expand Down
3 changes: 2 additions & 1 deletion internal/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ func newInstance(conf string) (*Core, bool) {
func TestCorePathAutoDeletion(t *testing.T) {
for _, ca := range []string{"describe", "setup"} {
t.Run(ca, func(t *testing.T) {
p, ok := New([]string{})
p, ok := newInstance("paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()

Expand Down
3 changes: 2 additions & 1 deletion internal/core/hls_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ func TestHLSServerNotFound(t *testing.T) {
}

func TestHLSServerRead(t *testing.T) {
p, ok := newInstance("")
p, ok := newInstance("paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()

Expand Down
4 changes: 3 additions & 1 deletion internal/core/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ func TestMetrics(t *testing.T) {
p, ok := newInstance("metrics: yes\n" +
"encryption: optional\n" +
"serverCert: " + serverCertFpath + "\n" +
"serverKey: " + serverKeyFpath + "\n")
"serverKey: " + serverKeyFpath + "\n" +
"paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()

Expand Down
2 changes: 1 addition & 1 deletion internal/core/path_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (pm *pathManager) findPathConf(name string) (string, *conf.PathConf, error)
}
}

return "", nil, fmt.Errorf("unable to find a valid configuration for path '%s'", name)
return "", nil, fmt.Errorf("path '%s' is not configured", name)
}

func (pm *pathManager) authenticate(
Expand Down
8 changes: 6 additions & 2 deletions internal/core/rtmp_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ func TestRTMPServerPublish(t *testing.T) {
"video",
} {
t.Run(source, func(t *testing.T) {
p, ok := newInstance("hlsDisable: yes\n")
p, ok := newInstance("hlsDisable: yes\n" +
"paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()

Expand Down Expand Up @@ -45,7 +47,9 @@ func TestRTMPServerPublish(t *testing.T) {
}

func TestRTMPServerRead(t *testing.T) {
p, ok := newInstance("hlsDisable: yes\n")
p, ok := newInstance("hlsDisable: yes\n" +
"paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()

Expand Down
31 changes: 21 additions & 10 deletions internal/core/rtsp_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func TestRTSPServerPublishRead(t *testing.T) {

p, ok := newInstance("rtmpDisable: yes\n" +
"hlsDisable: yes\n" +
"readTimeout: 20s\n")
"readTimeout: 20s\n" +
"paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()
} else {
Expand All @@ -64,7 +66,9 @@ func TestRTSPServerPublishRead(t *testing.T) {
"protocols: [tcp]\n" +
"encryption: \"yes\"\n" +
"serverCert: " + serverCertFpath + "\n" +
"serverKey: " + serverKeyFpath + "\n")
"serverKey: " + serverKeyFpath + "\n" +
"paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()
}
Expand Down Expand Up @@ -391,12 +395,14 @@ func TestRTSPServerPublisherOverride(t *testing.T) {
} {
t.Run(ca, func(t *testing.T) {
conf := "rtmpDisable: yes\n" +
"protocols: [tcp]\n"
"protocols: [tcp]\n" +
"paths:\n" +
" all:\n"

if ca == "disabled" {
conf += "paths:\n" +
" all:\n" +
" disablePublisherOverride: yes\n"
conf += " disablePublisherOverride: yes\n"
}

p, ok := newInstance(conf)
require.Equal(t, true, ok)
defer p.close()
Expand Down Expand Up @@ -463,9 +469,12 @@ func TestRTSPServerPublisherOverride(t *testing.T) {

func TestRTSPServerNonCompliantFrameSize(t *testing.T) {
t.Run("publish", func(t *testing.T) {
p, ok := newInstance("rtmpDisable: yes\n" +
"hlsDisable: yes\n" +
"readBufferSize: 4500\n")
p, ok := newInstance(
"rtmpDisable: yes\n" +
"hlsDisable: yes\n" +
"readBufferSize: 4500\n" +
"paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p.close()

Expand Down Expand Up @@ -516,7 +525,9 @@ func TestRTSPServerNonCompliantFrameSize(t *testing.T) {
p1, ok := newInstance("rtmpDisable: yes\n" +
"hlsDisable: yes\n" +
"protocols: [tcp]\n" +
"readBufferSize: 4500\n")
"readBufferSize: 4500\n" +
"paths:\n" +
" all:\n")
require.Equal(t, true, ok)
defer p1.close()

Expand Down

0 comments on commit 08fa61e

Please sign in to comment.