forked from External/mediamtx
parent
048280f4e2
commit
37586b2300
7 changed files with 63 additions and 67 deletions
|
|
@ -77,6 +77,15 @@ func loadFromFile(fpath string, conf *Conf) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func contains(list []headers.AuthMethod, item headers.AuthMethod) bool {
|
||||
for _, i := range list {
|
||||
if i == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Conf is a configuration.
|
||||
type Conf struct {
|
||||
// general
|
||||
|
|
@ -197,15 +206,6 @@ func (conf Conf) Clone() *Conf {
|
|||
return &dest
|
||||
}
|
||||
|
||||
func contains(list []headers.AuthMethod, item headers.AuthMethod) bool {
|
||||
for _, i := range list {
|
||||
if i == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Check checks the configuration for errors.
|
||||
func (conf *Conf) Check() error {
|
||||
// general
|
||||
|
|
@ -266,12 +266,6 @@ func (conf *Conf) Check() error {
|
|||
conf.Paths = make(map[string]*PathConf)
|
||||
}
|
||||
|
||||
// "all" is an alias for "~^.*$"
|
||||
if _, ok := conf.Paths["all"]; ok {
|
||||
conf.Paths["~^.*$"] = conf.Paths["all"]
|
||||
delete(conf.Paths, "all")
|
||||
}
|
||||
|
||||
for _, name := range getSortedKeys(conf.Paths) {
|
||||
pconf := conf.Paths[name]
|
||||
if pconf == nil {
|
||||
|
|
|
|||
|
|
@ -119,15 +119,17 @@ type PathConf struct {
|
|||
}
|
||||
|
||||
func (pconf *PathConf) check(conf *Conf, name string) error {
|
||||
// normal path
|
||||
if name == "" || name[0] != '~' {
|
||||
switch {
|
||||
case name == "all":
|
||||
pconf.Regexp = regexp.MustCompile("^.*$")
|
||||
|
||||
case name == "" || name[0] != '~': // normal path
|
||||
err := IsValidPathName(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid path name '%s': %s", name, err)
|
||||
}
|
||||
|
||||
// regular expression path
|
||||
} else {
|
||||
default: // regular expression-based path
|
||||
pathRegexp, err := regexp.Compile(name[1:])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid regular expression: %s", name[1:])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue