github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/app/subscription/containers/tryall.go (about)

     1  package containers
     2  
     3  func TryAllParsers(rawConfig []byte, prioritizedParser string) (*Container, error) {
     4  	if prioritizedParser != "" {
     5  		if parser, found := knownParsers[prioritizedParser]; found {
     6  			container, err := parser.ParseSubscriptionContainerDocument(rawConfig)
     7  			if err == nil {
     8  				return container, nil
     9  			}
    10  		}
    11  	}
    12  
    13  	for _, parser := range knownParsers {
    14  		container, err := parser.ParseSubscriptionContainerDocument(rawConfig)
    15  		if err == nil {
    16  			return container, nil
    17  		}
    18  	}
    19  	return nil, newError("no parser found for config")
    20  }