From c61820c7cd68885ff7d834d467c9f83692429673 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sat, 25 Nov 2023 15:44:31 +0000 Subject: [PATCH] rename import dialing tag in subscription thanks mzz --- app/subscription/config.pb.go | 70 +++++++++---------- app/subscription/config.proto | 2 +- .../documentfetcher/dataurlfetcher/dataurl.go | 24 +++++++ .../documentfetcher/httpfetcher/http.go | 2 +- .../subscriptionmanager/subdocupdater.go | 2 +- 5 files changed, 62 insertions(+), 38 deletions(-) create mode 100644 app/subscription/documentfetcher/dataurlfetcher/dataurl.go diff --git a/app/subscription/config.pb.go b/app/subscription/config.pb.go index a1dfff4fe..14e66cb75 100644 --- a/app/subscription/config.pb.go +++ b/app/subscription/config.pb.go @@ -23,7 +23,7 @@ type ImportSource struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` TagPrefix string `protobuf:"bytes,3,opt,name=tag_prefix,json=tagPrefix,proto3" json:"tag_prefix,omitempty"` - ImportNetworkTag string `protobuf:"bytes,4,opt,name=import_network_tag,json=importNetworkTag,proto3" json:"import_network_tag,omitempty"` + ImportUsingTag string `protobuf:"bytes,4,opt,name=import_using_tag,json=importUsingTag,proto3" json:"import_using_tag,omitempty"` DefaultExpireSeconds uint64 `protobuf:"varint,5,opt,name=default_expire_seconds,json=defaultExpireSeconds,proto3" json:"default_expire_seconds,omitempty"` } @@ -80,9 +80,9 @@ func (x *ImportSource) GetTagPrefix() string { return "" } -func (x *ImportSource) GetImportNetworkTag() string { +func (x *ImportSource) GetImportUsingTag() string { if x != nil { - return x.ImportNetworkTag + return x.ImportUsingTag } return "" } @@ -166,44 +166,44 @@ var file_app_subscription_config_proto_rawDesc = []byte{ 0x1b, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x65, 0x78, 0x74, 0x2f, 0x65, 0x78, - 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb7, + 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x01, 0x0a, 0x0c, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x67, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x67, 0x50, 0x72, - 0x65, 0x66, 0x69, 0x78, 0x12, 0x2c, 0x0a, 0x12, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x10, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x54, - 0x61, 0x67, 0x12, 0x34, 0x0a, 0x16, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x65, 0x78, - 0x70, 0x69, 0x72, 0x65, 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x14, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x45, 0x78, 0x70, 0x69, 0x72, - 0x65, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x98, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x43, 0x0a, 0x07, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, + 0x65, 0x66, 0x69, 0x78, 0x12, 0x28, 0x0a, 0x10, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x75, + 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, + 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x55, 0x73, 0x69, 0x6e, 0x67, 0x54, 0x61, 0x67, 0x12, 0x34, + 0x0a, 0x16, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, + 0x5f, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, + 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x53, 0x65, 0x63, + 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x98, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x43, 0x0a, 0x07, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x29, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x49, + 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x07, 0x69, 0x6d, 0x70, + 0x6f, 0x72, 0x74, 0x73, 0x12, 0x3e, 0x0a, 0x1b, 0x6e, 0x6f, 0x6e, 0x6e, 0x61, 0x74, 0x69, 0x76, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x6f, 0x76, 0x65, 0x72, + 0x6c, 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x19, 0x6e, 0x6f, 0x6e, 0x6e, 0x61, + 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x4f, 0x76, 0x65, + 0x72, 0x6c, 0x61, 0x79, 0x12, 0x6c, 0x0a, 0x20, 0x6e, 0x6f, 0x6e, 0x6e, 0x61, 0x74, 0x69, 0x76, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x6f, 0x76, 0x65, 0x72, + 0x6c, 0x61, 0x79, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x82, 0xee, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x21, 0x82, 0xb5, 0x18, 0x1d, 0x22, 0x1b, 0x6e, 0x6f, 0x6e, 0x6e, 0x61, 0x74, 0x69, 0x76, + 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x6f, 0x76, 0x65, 0x72, + 0x6c, 0x61, 0x79, 0x52, 0x1d, 0x6e, 0x6f, 0x6e, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, + 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x46, 0x69, + 0x6c, 0x65, 0x3a, 0x1b, 0x82, 0xb5, 0x18, 0x17, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, + 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x2e, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, - 0x07, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x3e, 0x0a, 0x1b, 0x6e, 0x6f, 0x6e, 0x6e, - 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x5f, - 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x19, 0x6e, - 0x6f, 0x6e, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, - 0x72, 0x4f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x12, 0x6c, 0x0a, 0x20, 0x6e, 0x6f, 0x6e, 0x6e, - 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x5f, - 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x82, 0xee, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0x82, 0xb5, 0x18, 0x1d, 0x22, 0x1b, 0x6e, 0x6f, 0x6e, 0x6e, - 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x5f, - 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x52, 0x1d, 0x6e, 0x6f, 0x6e, 0x6e, 0x61, 0x74, 0x69, - 0x76, 0x65, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x74, 0x65, 0x72, 0x4f, 0x76, 0x65, 0x72, 0x6c, - 0x61, 0x79, 0x46, 0x69, 0x6c, 0x65, 0x3a, 0x1b, 0x82, 0xb5, 0x18, 0x17, 0x0a, 0x07, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x42, 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, - 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x32, 0x66, 0x6c, 0x79, 0x2f, 0x76, 0x32, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x35, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0xaa, 0x02, 0x1b, 0x56, 0x32, 0x52, 0x61, - 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x76, 0x32, 0x66, 0x6c, 0x79, 0x2f, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x76, 0x35, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0xaa, 0x02, 0x1b, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, + 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/subscription/config.proto b/app/subscription/config.proto index 71dd51a1e..e622ce4c9 100644 --- a/app/subscription/config.proto +++ b/app/subscription/config.proto @@ -14,7 +14,7 @@ message ImportSource { string url = 2; string tag_prefix = 3; - string import_network_tag = 4; + string import_using_tag = 4; uint64 default_expire_seconds = 5; } diff --git a/app/subscription/documentfetcher/dataurlfetcher/dataurl.go b/app/subscription/documentfetcher/dataurlfetcher/dataurl.go new file mode 100644 index 000000000..8acf7afb2 --- /dev/null +++ b/app/subscription/documentfetcher/dataurlfetcher/dataurl.go @@ -0,0 +1,24 @@ +package dataurlfetcher + +import ( + "context" + "github.com/v2fly/v2ray-core/v5/app/subscription" + "github.com/v2fly/v2ray-core/v5/app/subscription/documentfetcher" + "github.com/v2fly/v2ray-core/v5/common" +) + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +func newDataURLFetcher() *dataURLFetcher { + return &dataURLFetcher{} +} + +func init() { + common.Must(documentfetcher.RegisterFetcher("dataurl", newDataURLFetcher())) +} + +type dataURLFetcher struct{} + +func (d *dataURLFetcher) DownloadDocument(ctx context.Context, source *subscription.ImportSource, opts ...documentfetcher.FetcherOptions) ([]byte, error) { + panic("implement me") +} diff --git a/app/subscription/documentfetcher/httpfetcher/http.go b/app/subscription/documentfetcher/httpfetcher/http.go index 6da0b65c9..03edd2ad4 100644 --- a/app/subscription/documentfetcher/httpfetcher/http.go +++ b/app/subscription/documentfetcher/httpfetcher/http.go @@ -37,7 +37,7 @@ func (h *httpFetcher) DownloadDocument(ctx context.Context, source *subscription if err != nil { return nil, newError("unable to parse destination") } - return outboundDialer(ctx, dest, source.ImportNetworkTag) + return outboundDialer(ctx, dest, source.ImportUsingTag) }, } request, err := http.NewRequest("GET", source.Url, nil) diff --git a/app/subscription/subscriptionmanager/subdocupdater.go b/app/subscription/subscriptionmanager/subdocupdater.go index 86013e79e..d6cd2f74b 100644 --- a/app/subscription/subscriptionmanager/subdocupdater.go +++ b/app/subscription/subscriptionmanager/subdocupdater.go @@ -51,7 +51,7 @@ func (s *SubscriptionManagerImpl) updateSubscription(subscriptionName string) er serverConfigHashName := fmt.Sprintf("%x", documentHash) parsed, err := s.converter.TryAllConverters(server.Content, "outbound", server.KindHint) if err != nil { - trackedSub.originalServerConfig[serverConfigHashName] = &originalServerConfig{data: server.Content} + trackedSub.originalServerConfig["!!!"+serverConfigHashName] = &originalServerConfig{data: server.Content} continue } s.polyfillServerConfig(parsed, serverConfigHashName)