Browse Source

do not add an 'all' path automatically if not present in the configuration file

pull/707/head
aler9 4 years ago
parent
commit
08fa61e56d
  1. 8
      internal/conf/conf.go
  2. 27
      internal/core/api_test.go
  3. 3
      internal/core/core_test.go
  4. 3
      internal/core/hls_server_test.go
  5. 4
      internal/core/metrics_test.go
  6. 2
      internal/core/path_manager.go
  7. 8
      internal/core/rtmp_server_test.go
  8. 31
      internal/core/rtsp_server_test.go

8
internal/conf/conf.go

@ -338,10 +338,10 @@ func (conf *Conf) CheckAndFillMissing() error { @@ -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 "~^.*$"

27
internal/core/api_test.go

@ -230,12 +230,14 @@ func TestAPIList(t *testing.T) { @@ -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)
@ -348,10 +350,19 @@ func TestAPIKick(t *testing.T) { @@ -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()

3
internal/core/core_test.go

@ -155,7 +155,8 @@ func newInstance(conf string) (*Core, bool) { @@ -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()

3
internal/core/hls_server_test.go

@ -23,7 +23,8 @@ func TestHLSServerNotFound(t *testing.T) { @@ -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()

4
internal/core/metrics_test.go

@ -23,7 +23,9 @@ func TestMetrics(t *testing.T) { @@ -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()

2
internal/core/path_manager.go

@ -303,7 +303,7 @@ func (pm *pathManager) findPathConf(name string) (string, *conf.PathConf, error) @@ -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(

8
internal/core/rtmp_server_test.go

@ -13,7 +13,9 @@ func TestRTMPServerPublish(t *testing.T) { @@ -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()
@ -45,7 +47,9 @@ func TestRTMPServerPublish(t *testing.T) { @@ -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()

31
internal/core/rtsp_server_test.go

@ -43,7 +43,9 @@ func TestRTSPServerPublishRead(t *testing.T) { @@ -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 {
@ -64,7 +66,9 @@ func TestRTSPServerPublishRead(t *testing.T) { @@ -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()
}
@ -391,12 +395,14 @@ func TestRTSPServerPublisherOverride(t *testing.T) { @@ -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()
@ -463,9 +469,12 @@ func TestRTSPServerPublisherOverride(t *testing.T) { @@ -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()
@ -516,7 +525,9 @@ func TestRTSPServerNonCompliantFrameSize(t *testing.T) { @@ -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()

Loading…
Cancel
Save