github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/app/subscription/containers/containers.go (about) 1 package containers 2 3 //go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen 4 5 type UnparsedServerConf struct { 6 KindHint string 7 Content []byte 8 } 9 10 type Container struct { 11 Kind string 12 Metadata map[string]string 13 ServerSpecs []UnparsedServerConf 14 } 15 16 type SubscriptionContainerDocumentParser interface { 17 ParseSubscriptionContainerDocument(rawConfig []byte) (*Container, error) 18 } 19 20 var knownParsers = make(map[string]SubscriptionContainerDocumentParser) 21 22 func RegisterParser(kind string, parser SubscriptionContainerDocumentParser) error { 23 if _, found := knownParsers[kind]; found { 24 return newError("parser already registered for kind ", kind) 25 } 26 knownParsers[kind] = parser 27 return nil 28 }