mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-06 09:15:37 -05:00
Add data URL Link support to subscription
This commit is contained in:
committed by
Xiaokang Wang (Shelikhoo)
parent
c61820c7cd
commit
f112667190
@@ -2,6 +2,10 @@ package dataurlfetcher
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/vincent-petithory/dataurl"
|
||||
|
||||
"github.com/v2fly/v2ray-core/v5/app/subscription"
|
||||
"github.com/v2fly/v2ray-core/v5/app/subscription/documentfetcher"
|
||||
"github.com/v2fly/v2ray-core/v5/common"
|
||||
@@ -20,5 +24,15 @@ func init() {
|
||||
type dataURLFetcher struct{}
|
||||
|
||||
func (d *dataURLFetcher) DownloadDocument(ctx context.Context, source *subscription.ImportSource, opts ...documentfetcher.FetcherOptions) ([]byte, error) {
|
||||
panic("implement me")
|
||||
dataURL, err := dataurl.DecodeString(source.Url)
|
||||
if err != nil {
|
||||
return nil, newError("unable to decode dataURL").Base(err)
|
||||
}
|
||||
if dataURL.MediaType.Type != "application" {
|
||||
return nil, newError("unsupported media type: ", dataURL.MediaType.Type)
|
||||
}
|
||||
if !strings.HasPrefix(dataURL.MediaType.Subtype, "vnd.v2ray.subscription") {
|
||||
return nil, newError("unsupported media subtype: ", dataURL.MediaType.Subtype)
|
||||
}
|
||||
return []byte(source.Url), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user