1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-25 19:45:38 -05:00

Add subscription manager

This commit is contained in:
Shelikhoo
2023-11-21 23:03:20 +00:00
committed by Xiaokang Wang (Shelikhoo)
parent b91354901c
commit cc77e90254
54 changed files with 1959 additions and 45 deletions

View File

@@ -0,0 +1,32 @@
package documentfetcher
import (
"context"
"github.com/v2fly/v2ray-core/v5/app/subscription"
)
//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen
type FetcherOptions interface{}
type Fetcher interface {
DownloadDocument(ctx context.Context, source *subscription.ImportSource, opts ...FetcherOptions) ([]byte, error)
}
var knownFetcher = make(map[string]Fetcher)
func RegisterFetcher(name string, fetcher Fetcher) error {
if _, found := knownFetcher[name]; found {
return newError("fetcher ", name, " already registered")
}
knownFetcher[name] = fetcher
return nil
}
func GetFetcher(name string) (Fetcher, error) {
if fetcher, found := knownFetcher[name]; found {
return fetcher, nil
}
return nil, newError("fetcher ", name, " not found")
}