1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/app/subscription/containers/tryall.go

21 lines
546 B
Go
Raw Normal View History

2023-11-21 18:03:20 -05:00
package containers
func TryAllParsers(rawConfig []byte, prioritizedParser string) (*Container, error) {
if prioritizedParser != "" {
if parser, found := knownParsers[prioritizedParser]; found {
container, err := parser.ParseSubscriptionContainerDocument(rawConfig)
if err == nil {
return container, nil
}
}
}
for _, parser := range knownParsers {
container, err := parser.ParseSubscriptionContainerDocument(rawConfig)
if err == nil {
return container, nil
}
}
return nil, newError("no parser found for config")
}