Fix output address validation for tee outputs
This commit is contained in:
parent
1cf1b7772f
commit
1931782638
3 changed files with 26 additions and 17 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#### Core v16.8.0 > ?
|
#### Core v16.8.0 > ?
|
||||||
|
|
||||||
|
- Fix output address validation for tee outputs
|
||||||
- Fix updating process config
|
- Fix updating process config
|
||||||
- Add experimental SRT connection stats and logs
|
- Add experimental SRT connection stats and logs
|
||||||
- Hide /config/reload endpoint in reade-only mode
|
- Hide /config/reload endpoint in reade-only mode
|
||||||
|
|
|
||||||
|
|
@ -725,24 +725,30 @@ func (r *restream) validateInputAddress(address, basedir string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *restream) validateOutputAddress(address, basedir string) (string, bool, error) {
|
func (r *restream) validateOutputAddress(address, basedir string) (string, bool, error) {
|
||||||
if strings.HasPrefix(address, "tee:") {
|
if strings.Contains(address, "|") {
|
||||||
address = strings.TrimPrefix(address, "tee:")
|
|
||||||
addresses := strings.Split(address, "|")
|
addresses := strings.Split(address, "|")
|
||||||
|
|
||||||
isFile := false
|
isFile := false
|
||||||
|
|
||||||
for _, a := range addresses {
|
teeOptions := regexp.MustCompile(`^\[[^\]]*\]`)
|
||||||
_, file, err := r.validateOutputAddress(a, basedir)
|
|
||||||
|
for i, a := range addresses {
|
||||||
|
options := teeOptions.FindString(a)
|
||||||
|
a = teeOptions.ReplaceAllString(a, "")
|
||||||
|
|
||||||
|
va, file, err := r.validateOutputAddress(a, basedir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "tee:" + address, false, err
|
return address, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if file {
|
if file {
|
||||||
isFile = true
|
isFile = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addresses[i] = options + va
|
||||||
}
|
}
|
||||||
|
|
||||||
return "tee:" + address, isFile, nil
|
return strings.Join(addresses, "|"), isFile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
address = strings.TrimPrefix(address, "file:")
|
address = strings.TrimPrefix(address, "file:")
|
||||||
|
|
|
||||||
|
|
@ -467,8 +467,10 @@ func TestOutputAddressValidation(t *testing.T) {
|
||||||
"file:/core/data/foobar": {"file:/core/data/foobar", false},
|
"file:/core/data/foobar": {"file:/core/data/foobar", false},
|
||||||
"http://example.com": {"http://example.com", false},
|
"http://example.com": {"http://example.com", false},
|
||||||
"-": {"pipe:", false},
|
"-": {"pipe:", false},
|
||||||
"tee:/core/data/foobar|http://example.com": {"tee:/core/data/foobar|http://example.com", false},
|
"/core/data/foobar|http://example.com": {"file:/core/data/foobar|http://example.com", false},
|
||||||
"tee:/core/data/foobar|/etc/passwd": {"tee:/core/data/foobar|/etc/passwd", true},
|
"/core/data/foobar|/etc/passwd": {"/core/data/foobar|/etc/passwd", true},
|
||||||
|
"[f=null]-|[f=null]-": {"[f=null]pipe:|[f=null]pipe:", false},
|
||||||
|
"[onfail=ignore]/core/data/archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/": {"[onfail=ignore]file:/core/data/archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/", false},
|
||||||
}
|
}
|
||||||
|
|
||||||
for path, r := range paths {
|
for path, r := range paths {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue