From fe01d360e476315aa20e3d69c6acee2d3fd33e53 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Tue, 21 Nov 2023 23:03:20 +0000 Subject: [PATCH 1/6] Add subscription manager --- app/observatory/command/command.pb.go | 63 +++--- app/observatory/command/command.proto | 6 +- app/observatory/observer.go | 9 + app/proxyman/command/command.go | 2 +- app/proxyman/outbound/handler.go | 6 + app/proxyman/outbound/outbound.go | 15 +- app/subscription/config.proto | 31 +++ .../containers/base64urlline/base64urlline.go | 3 + .../containers/base64urlline/parser.go | 46 +++++ app/subscription/containers/containers.go | 28 +++ .../jsonfieldarray/jsonfieldarray.go | 3 + .../jsonfieldarray/jsonified/jsonified.go | 3 + .../jsonfieldarray/jsonified/parser.go | 36 ++++ .../containers/jsonfieldarray/parser.go | 68 +++++++ app/subscription/containers/tryall.go | 20 ++ app/subscription/documentfetcher/fetcher.go | 32 +++ .../documentfetcher/httpfetcher/http.go | 60 ++++++ app/subscription/entries/entries.go | 9 + .../entries/nonnative/converter.go | 51 +++++ .../nonnative/definitions/shadowsocks.jsont | 35 ++++ .../definitions/shadowsocks2022.jsont | 51 +++++ .../entries/nonnative/definitions/vmess.jsont | 66 ++++++ .../entries/nonnative/matchdef.go | 191 ++++++++++++++++++ .../entries/nonnative/nonnative.go | 108 ++++++++++ .../nonnative/nonnativeifce/nonnativeifce.go | 11 + app/subscription/entries/outbound/outbound.go | 33 +++ app/subscription/entries/register.go | 54 +++++ app/subscription/specs/abstract_spec.proto | 30 +++ app/subscription/specs/outbound_parser.go | 90 +++++++++ app/subscription/specs/skeleton.go | 19 ++ app/subscription/specs/specs.go | 3 + app/subscription/subscription.go | 3 + app/subscription/subscriptionmanager/delta.go | 8 + .../subscriptionmanager/known_metadata.go | 7 + .../subscriptionmanager/manager.go | 103 ++++++++++ .../serverspec_materialize.go | 50 +++++ .../subscriptionmanager/subdocapplier.go | 121 +++++++++++ .../subscriptionmanager/subdocchecker.go | 26 +++ .../subscriptionmanager/subdocupdater.go | 114 +++++++++++ .../tracked_subscription.go | 78 +++++++ common/environment/rootcap.go | 1 + common/environment/rootcap_impl.go | 10 +- common/protoext/extensions.pb.go | 30 ++- common/protoext/extensions.proto | 4 + common/protofilter/filter.go | 5 +- common/registry/registry.go | 7 + common/registry/restrict.go | 35 ++++ features/extension/subscription.go | 11 + main/commands/all/engineering/engineering.go | 3 + .../all/engineering/nonnativelinkexec.go | 54 +++++ .../all/engineering/nonnativelinkextract.go | 55 +++++ .../engineering/subscriptionEntriesExtract.go | 70 +++++++ main/distro/all/all.go | 15 ++ v2ray.go | 12 ++ 54 files changed, 1959 insertions(+), 45 deletions(-) create mode 100644 app/subscription/config.proto create mode 100644 app/subscription/containers/base64urlline/base64urlline.go create mode 100644 app/subscription/containers/base64urlline/parser.go create mode 100644 app/subscription/containers/containers.go create mode 100644 app/subscription/containers/jsonfieldarray/jsonfieldarray.go create mode 100644 app/subscription/containers/jsonfieldarray/jsonified/jsonified.go create mode 100644 app/subscription/containers/jsonfieldarray/jsonified/parser.go create mode 100644 app/subscription/containers/jsonfieldarray/parser.go create mode 100644 app/subscription/containers/tryall.go create mode 100644 app/subscription/documentfetcher/fetcher.go create mode 100644 app/subscription/documentfetcher/httpfetcher/http.go create mode 100644 app/subscription/entries/entries.go create mode 100644 app/subscription/entries/nonnative/converter.go create mode 100644 app/subscription/entries/nonnative/definitions/shadowsocks.jsont create mode 100644 app/subscription/entries/nonnative/definitions/shadowsocks2022.jsont create mode 100644 app/subscription/entries/nonnative/definitions/vmess.jsont create mode 100644 app/subscription/entries/nonnative/matchdef.go create mode 100644 app/subscription/entries/nonnative/nonnative.go create mode 100644 app/subscription/entries/nonnative/nonnativeifce/nonnativeifce.go create mode 100644 app/subscription/entries/outbound/outbound.go create mode 100644 app/subscription/entries/register.go create mode 100644 app/subscription/specs/abstract_spec.proto create mode 100644 app/subscription/specs/outbound_parser.go create mode 100644 app/subscription/specs/skeleton.go create mode 100644 app/subscription/specs/specs.go create mode 100644 app/subscription/subscription.go create mode 100644 app/subscription/subscriptionmanager/delta.go create mode 100644 app/subscription/subscriptionmanager/known_metadata.go create mode 100644 app/subscription/subscriptionmanager/manager.go create mode 100644 app/subscription/subscriptionmanager/serverspec_materialize.go create mode 100644 app/subscription/subscriptionmanager/subdocapplier.go create mode 100644 app/subscription/subscriptionmanager/subdocchecker.go create mode 100644 app/subscription/subscriptionmanager/subdocupdater.go create mode 100644 app/subscription/subscriptionmanager/tracked_subscription.go create mode 100644 common/registry/restrict.go create mode 100644 features/extension/subscription.go create mode 100644 main/commands/all/engineering/nonnativelinkexec.go create mode 100644 main/commands/all/engineering/nonnativelinkextract.go create mode 100644 main/commands/all/engineering/subscriptionEntriesExtract.go diff --git a/app/observatory/command/command.pb.go b/app/observatory/command/command.pb.go index bdbe6d2b7cb..28852b94b4c 100644 --- a/app/observatory/command/command.pb.go +++ b/app/observatory/command/command.pb.go @@ -2,6 +2,7 @@ package command import ( observatory "github.com/v2fly/v2ray-core/v5/app/observatory" + _ "github.com/v2fly/v2ray-core/v5/common/protoext" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -154,39 +155,43 @@ var file_app_observatory_command_command_proto_rawDesc = []byte{ 0x79, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, - 0x6f, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x1c, 0x61, 0x70, 0x70, - 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2c, 0x0a, 0x18, 0x47, 0x65, 0x74, + 0x6f, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 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, 0x1a, 0x1c, 0x61, + 0x70, 0x70, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2c, 0x0a, 0x18, 0x47, + 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x54, 0x61, 0x67, 0x22, 0x62, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x54, 0x61, 0x67, 0x22, 0x62, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x4f, 0x75, - 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, + 0x6f, 0x72, 0x79, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x28, 0x0a, + 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x3a, 0x1e, 0x82, 0xb5, 0x18, 0x1a, 0x0a, 0x0b, 0x67, + 0x72, 0x70, 0x63, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x0b, 0x6f, 0x62, 0x73, 0x65, + 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x32, 0xa9, 0x01, 0x0a, 0x12, 0x4f, 0x62, 0x73, 0x65, + 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x92, + 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x3c, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, - 0x79, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x08, 0x0a, 0x06, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xa9, 0x01, 0x0a, 0x12, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, - 0x61, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x92, 0x01, 0x0a, - 0x11, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x12, 0x3c, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x3d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x87, 0x01, 0x0a, 0x26, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, - 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x36, - 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, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x22, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, - 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, - 0x6f, 0x72, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x42, 0x87, 0x01, 0x0a, 0x26, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, + 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, + 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, + 0x5a, 0x36, 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, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, + 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x22, 0x56, 0x32, 0x52, 0x61, 0x79, + 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, + 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/observatory/command/command.proto b/app/observatory/command/command.proto index e5ff38bb668..b9291f632bf 100644 --- a/app/observatory/command/command.proto +++ b/app/observatory/command/command.proto @@ -6,6 +6,7 @@ option go_package = "github.com/v2fly/v2ray-core/v5/app/observatory/command"; option java_package = "com.v2ray.core.app.observatory.command"; option java_multiple_files = true; +import "common/protoext/extensions.proto"; import "app/observatory/config.proto"; message GetOutboundStatusRequest { @@ -22,4 +23,7 @@ service ObservatoryService { } -message Config {} \ No newline at end of file +message Config { + option (v2ray.core.common.protoext.message_opt).type = "grpcservice"; + option (v2ray.core.common.protoext.message_opt).short_name = "observatory"; +} \ No newline at end of file diff --git a/app/observatory/observer.go b/app/observatory/observer.go index 690d3c5252a..e0912074e23 100644 --- a/app/observatory/observer.go +++ b/app/observatory/observer.go @@ -73,6 +73,7 @@ func (o *Observer) background() { o.updateStatus(outbounds) + slept := false for _, v := range outbounds { result := o.probe(v) o.updateStatusForResult(v, &result) @@ -84,6 +85,14 @@ func (o *Observer) background() { sleepTime = time.Duration(o.config.ProbeInterval) } time.Sleep(sleepTime) + slept = true + } + if !slept { + sleepTime := time.Second * 10 + if o.config.ProbeInterval != 0 { + sleepTime = time.Duration(o.config.ProbeInterval) + } + time.Sleep(sleepTime) } } } diff --git a/app/proxyman/command/command.go b/app/proxyman/command/command.go index fdc0138395c..61758be3df2 100644 --- a/app/proxyman/command/command.go +++ b/app/proxyman/command/command.go @@ -107,7 +107,7 @@ func (s *handlerServer) AddOutbound(ctx context.Context, request *AddOutboundReq } func (s *handlerServer) RemoveOutbound(ctx context.Context, request *RemoveOutboundRequest) (*RemoveOutboundResponse, error) { - return &RemoveOutboundResponse{}, s.ohm.RemoveHandler(ctx, request.Tag) + return &RemoveOutboundResponse{}, core.RemoveOutboundHandler(s.s, request.Tag) } func (s *handlerServer) AlterOutbound(ctx context.Context, request *AlterOutboundRequest) (*AlterOutboundResponse, error) { diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 71e66c2ddd1..7febd5c2040 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -317,5 +317,11 @@ func (h *Handler) Start() error { // Close implements common.Closable. func (h *Handler) Close() error { common.Close(h.mux) + + if closableProxy, ok := h.proxy.(common.Closable); ok { + if err := closableProxy.Close(); err != nil { + return newError("unable to close proxy").Base(err) + } + } return nil } diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 300a535fe95..a612bf936ad 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -11,6 +11,7 @@ import ( "github.com/v2fly/v2ray-core/v5/app/proxyman" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/errors" + "github.com/v2fly/v2ray-core/v5/common/session" "github.com/v2fly/v2ray-core/v5/features/outbound" ) @@ -131,12 +132,18 @@ func (m *Manager) RemoveHandler(ctx context.Context, tag string) error { m.access.Lock() defer m.access.Unlock() - delete(m.taggedHandler, tag) - if m.defaultHandler != nil && m.defaultHandler.Tag() == tag { - m.defaultHandler = nil + if handler, found := m.taggedHandler[tag]; found { + if err := handler.Close(); err != nil { + newError("failed to close handler ", tag).Base(err).AtWarning().WriteToLog(session.ExportIDToError(ctx)) + } + delete(m.taggedHandler, tag) + if m.defaultHandler != nil && m.defaultHandler.Tag() == tag { + m.defaultHandler = nil + } + return nil } - return nil + return common.ErrNoClue } // Select implements outbound.HandlerSelector. diff --git a/app/subscription/config.proto b/app/subscription/config.proto new file mode 100644 index 00000000000..71dd51a1e45 --- /dev/null +++ b/app/subscription/config.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package v2ray.core.app.subscription; + +option csharp_namespace = "V2Ray.Core.App.Subscription"; +option go_package = "github.com/v2fly/v2ray-core/v5/app/subscription"; +option java_package = "com.v2ray.core.app.subscription"; +option java_multiple_files = true; + +import "common/protoext/extensions.proto"; + +message ImportSource { + string name = 1; + string url = 2; + string tag_prefix = 3; + + string import_network_tag = 4; + + uint64 default_expire_seconds = 5; +} + +// Config is the settings for Subscription Manager. +message Config { + option (v2ray.core.common.protoext.message_opt).type = "service"; + option (v2ray.core.common.protoext.message_opt).short_name = "subscription"; + + repeated ImportSource imports = 1; + + bytes nonnative_converter_overlay = 2; + string nonnative_converter_overlay_file = 96002 [(v2ray.core.common.protoext.field_opt).convert_time_read_file_into = "nonnative_converter_overlay"]; +} \ No newline at end of file diff --git a/app/subscription/containers/base64urlline/base64urlline.go b/app/subscription/containers/base64urlline/base64urlline.go new file mode 100644 index 00000000000..97b2fbf527a --- /dev/null +++ b/app/subscription/containers/base64urlline/base64urlline.go @@ -0,0 +1,3 @@ +package base64urlline + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen diff --git a/app/subscription/containers/base64urlline/parser.go b/app/subscription/containers/base64urlline/parser.go new file mode 100644 index 00000000000..44b7186e4da --- /dev/null +++ b/app/subscription/containers/base64urlline/parser.go @@ -0,0 +1,46 @@ +package base64urlline + +import ( + "bufio" + "bytes" + "encoding/base64" + "io" + + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/common" +) + +func newBase64URLLineParser() containers.SubscriptionContainerDocumentParser { + return &parser{} +} + +type parser struct{} + +func (p parser) ParseSubscriptionContainerDocument(rawConfig []byte) (*containers.Container, error) { + result := &containers.Container{} + result.Kind = "Base64URLLine" + result.Metadata = make(map[string]string) + + bodyDecoder := base64.NewDecoder(base64.StdEncoding, bytes.NewReader(rawConfig)) + decoded, err := io.ReadAll(bodyDecoder) + if err != nil { + return nil, newError("failed to decode base64url body base64").Base(err) + } + scanner := bufio.NewScanner(bytes.NewReader(decoded)) + + const maxCapacity int = 1024 * 256 + buf := make([]byte, maxCapacity) + scanner.Buffer(buf, maxCapacity) + + for scanner.Scan() { + result.ServerSpecs = append(result.ServerSpecs, containers.UnparsedServerConf{ + KindHint: "URL", + Content: scanner.Bytes(), + }) + } + return result, nil +} + +func init() { + common.Must(containers.RegisterParser("Base64URLLine", newBase64URLLineParser())) +} diff --git a/app/subscription/containers/containers.go b/app/subscription/containers/containers.go new file mode 100644 index 00000000000..5a1b4097c26 --- /dev/null +++ b/app/subscription/containers/containers.go @@ -0,0 +1,28 @@ +package containers + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +type UnparsedServerConf struct { + KindHint string + Content []byte +} + +type Container struct { + Kind string + Metadata map[string]string + ServerSpecs []UnparsedServerConf +} + +type SubscriptionContainerDocumentParser interface { + ParseSubscriptionContainerDocument(rawConfig []byte) (*Container, error) +} + +var knownParsers = make(map[string]SubscriptionContainerDocumentParser) + +func RegisterParser(kind string, parser SubscriptionContainerDocumentParser) error { + if _, found := knownParsers[kind]; found { + return newError("parser already registered for kind ", kind) + } + knownParsers[kind] = parser + return nil +} diff --git a/app/subscription/containers/jsonfieldarray/jsonfieldarray.go b/app/subscription/containers/jsonfieldarray/jsonfieldarray.go new file mode 100644 index 00000000000..52270eeae42 --- /dev/null +++ b/app/subscription/containers/jsonfieldarray/jsonfieldarray.go @@ -0,0 +1,3 @@ +package jsonfieldarray + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen diff --git a/app/subscription/containers/jsonfieldarray/jsonified/jsonified.go b/app/subscription/containers/jsonfieldarray/jsonified/jsonified.go new file mode 100644 index 00000000000..313ffc9d767 --- /dev/null +++ b/app/subscription/containers/jsonfieldarray/jsonified/jsonified.go @@ -0,0 +1,3 @@ +package jsonified + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen diff --git a/app/subscription/containers/jsonfieldarray/jsonified/parser.go b/app/subscription/containers/jsonfieldarray/jsonified/parser.go new file mode 100644 index 00000000000..b713899e9ef --- /dev/null +++ b/app/subscription/containers/jsonfieldarray/jsonified/parser.go @@ -0,0 +1,36 @@ +package jsonified + +import ( + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/app/subscription/containers/jsonfieldarray" + "github.com/v2fly/v2ray-core/v5/common" + jsonConf "github.com/v2fly/v2ray-core/v5/infra/conf/json" +) + +func newJsonifiedYamlParser() containers.SubscriptionContainerDocumentParser { + return &jsonifiedYAMLParser{} +} + +type jsonifiedYAMLParser struct{} + +func (j jsonifiedYAMLParser) ParseSubscriptionContainerDocument(rawConfig []byte) (*containers.Container, error) { + parser := jsonfieldarray.NewJSONFieldArrayParser() + jsonified, err := jsonConf.FromYAML(rawConfig) + if err != nil { + return nil, newError("failed to parse as yaml").Base(err) + } + container, err := parser.ParseSubscriptionContainerDocument(jsonified) + if err != nil { + return nil, newError("failed to parse as jsonfieldarray").Base(err) + } + container.Kind = "Yaml2Json+" + container.Kind + + for _, value := range container.ServerSpecs { + value.KindHint = "Yaml2Json+" + value.KindHint + } + return container, nil +} + +func init() { + common.Must(containers.RegisterParser("Yaml2Json", newJsonifiedYamlParser())) +} diff --git a/app/subscription/containers/jsonfieldarray/parser.go b/app/subscription/containers/jsonfieldarray/parser.go new file mode 100644 index 00000000000..1fadf001d65 --- /dev/null +++ b/app/subscription/containers/jsonfieldarray/parser.go @@ -0,0 +1,68 @@ +package jsonfieldarray + +import ( + "encoding/json" + + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/common" +) + +// NewJSONFieldArrayParser internal api +func NewJSONFieldArrayParser() containers.SubscriptionContainerDocumentParser { + return newJSONFieldArrayParser() +} + +func newJSONFieldArrayParser() containers.SubscriptionContainerDocumentParser { + return &parser{} +} + +type parser struct{} + +type jsonDocument map[string]json.RawMessage + +func (p parser) ParseSubscriptionContainerDocument(rawConfig []byte) (*containers.Container, error) { + result := &containers.Container{} + result.Kind = "JsonFieldArray" + result.Metadata = make(map[string]string) + + var doc jsonDocument + if err := json.Unmarshal(rawConfig, &doc); err != nil { + return nil, newError("failed to parse as json").Base(err) + } + + for key, value := range doc { + switch value[0] { + case '[': + parsedArray, err := p.parseArray(value, "JsonFieldArray+"+key) + if err != nil { + return nil, newError("failed to parse as json array").Base(err) + } + result.ServerSpecs = append(result.ServerSpecs, parsedArray...) + case '{': + fallthrough + default: + result.Metadata[key] = string(value) + } + } + + return result, nil +} + +func (p parser) parseArray(rawConfig []byte, kindHint string) ([]containers.UnparsedServerConf, error) { + var result []json.RawMessage + if err := json.Unmarshal(rawConfig, &result); err != nil { + return nil, newError("failed to parse as json array").Base(err) + } + var ret []containers.UnparsedServerConf + for _, value := range result { + ret = append(ret, containers.UnparsedServerConf{ + KindHint: kindHint, + Content: []byte(value), + }) + } + return ret, nil +} + +func init() { + common.Must(containers.RegisterParser("JsonFieldArray", newJSONFieldArrayParser())) +} diff --git a/app/subscription/containers/tryall.go b/app/subscription/containers/tryall.go new file mode 100644 index 00000000000..22ded5f4193 --- /dev/null +++ b/app/subscription/containers/tryall.go @@ -0,0 +1,20 @@ +package containers + +func TryAllParsers(rawConfig []byte, prioritizedParser string) (*Container, error) { + if prioritizedParser != "" { + if parser, found := knownParsers[prioritizedParser]; found { + container, err := parser.ParseSubscriptionContainerDocument(rawConfig) + if err == nil { + return container, nil + } + } + } + + for _, parser := range knownParsers { + container, err := parser.ParseSubscriptionContainerDocument(rawConfig) + if err == nil { + return container, nil + } + } + return nil, newError("no parser found for config") +} diff --git a/app/subscription/documentfetcher/fetcher.go b/app/subscription/documentfetcher/fetcher.go new file mode 100644 index 00000000000..8f17b5eaf55 --- /dev/null +++ b/app/subscription/documentfetcher/fetcher.go @@ -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") +} diff --git a/app/subscription/documentfetcher/httpfetcher/http.go b/app/subscription/documentfetcher/httpfetcher/http.go new file mode 100644 index 00000000000..6da0b65c925 --- /dev/null +++ b/app/subscription/documentfetcher/httpfetcher/http.go @@ -0,0 +1,60 @@ +package httpfetcher + +import ( + "context" + "io" + gonet "net" + "net/http" + + "github.com/v2fly/v2ray-core/v5/common" + "github.com/v2fly/v2ray-core/v5/common/net" + + "github.com/v2fly/v2ray-core/v5/app/subscription" + "github.com/v2fly/v2ray-core/v5/app/subscription/documentfetcher" + "github.com/v2fly/v2ray-core/v5/common/environment" + "github.com/v2fly/v2ray-core/v5/common/environment/envctx" +) + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +func newHTTPFetcher() *httpFetcher { + return &httpFetcher{} +} + +func init() { + common.Must(documentfetcher.RegisterFetcher("http", newHTTPFetcher())) +} + +type httpFetcher struct{} + +func (h *httpFetcher) DownloadDocument(ctx context.Context, source *subscription.ImportSource, opts ...documentfetcher.FetcherOptions) ([]byte, error) { + instanceNetwork := envctx.EnvironmentFromContext(ctx).(environment.InstanceNetworkCapabilitySet) + outboundDialer := instanceNetwork.OutboundDialer() + var httpRoundTripper http.RoundTripper //nolint: gosimple + httpRoundTripper = &http.Transport{ + DialContext: func(ctx_ context.Context, network string, addr string) (gonet.Conn, error) { + dest, err := net.ParseDestination(network + ":" + addr) + if err != nil { + return nil, newError("unable to parse destination") + } + return outboundDialer(ctx, dest, source.ImportNetworkTag) + }, + } + request, err := http.NewRequest("GET", source.Url, nil) + if err != nil { + return nil, newError("unable to generate request").Base(err) + } + resp, err := httpRoundTripper.RoundTrip(request) + if err != nil { + return nil, newError("unable to send request").Base(err) + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil, newError("unexpected http status ", resp.StatusCode, "=", resp.Status) + } + data, err := io.ReadAll(resp.Body) + if err != nil { + return nil, newError("unable to read response").Base(err) + } + return data, nil +} diff --git a/app/subscription/entries/entries.go b/app/subscription/entries/entries.go new file mode 100644 index 00000000000..5d5b5bc5f03 --- /dev/null +++ b/app/subscription/entries/entries.go @@ -0,0 +1,9 @@ +package entries + +import "github.com/v2fly/v2ray-core/v5/app/subscription/specs" + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +type Converter interface { + ConvertToAbstractServerConfig(rawConfig []byte, kindHint string) (*specs.SubscriptionServerConfig, error) +} diff --git a/app/subscription/entries/nonnative/converter.go b/app/subscription/entries/nonnative/converter.go new file mode 100644 index 00000000000..ab2b2b9c3cb --- /dev/null +++ b/app/subscription/entries/nonnative/converter.go @@ -0,0 +1,51 @@ +package nonnative + +import ( + "io/fs" + + "github.com/v2fly/v2ray-core/v5/app/subscription/entries" + "github.com/v2fly/v2ray-core/v5/app/subscription/entries/nonnative/nonnativeifce" + "github.com/v2fly/v2ray-core/v5/app/subscription/entries/outbound" + "github.com/v2fly/v2ray-core/v5/app/subscription/specs" + "github.com/v2fly/v2ray-core/v5/common" +) + +type nonNativeConverter struct { + matcher *DefMatcher +} + +func (n *nonNativeConverter) ConvertToAbstractServerConfig(rawConfig []byte, kindHint string) (*specs.SubscriptionServerConfig, error) { + nonNativeLink := ExtractAllValuesFromBytes(rawConfig) + nonNativeLink.Values["_kind"] = kindHint + result, err := n.matcher.ExecuteAll(nonNativeLink) + if err != nil { + return nil, newError("failed to find working converting template").Base(err) + } + outboundParser := outbound.NewOutboundEntriesParser() + outboundEntries, err := outboundParser.ConvertToAbstractServerConfig(result, "") + if err != nil { + return nil, newError("failed to parse template output as outbound entries").Base(err) + } + return outboundEntries, nil +} + +func NewNonNativeConverter(fs fs.FS) (entries.Converter, error) { + matcher := NewDefMatcher() + if fs == nil { + err := matcher.LoadEmbeddedDefinitions() + if err != nil { + return nil, newError("failed to load embedded definitions").Base(err) + } + } else { + err := matcher.LoadDefinitions(fs) + if err != nil { + return nil, newError("failed to load provided definitions").Base(err) + } + } + return &nonNativeConverter{matcher: matcher}, nil +} + +func init() { + common.Must(entries.RegisterConverter("nonnative", common.Must2(NewNonNativeConverter(nil)).(entries.Converter))) + nonnativeifce.NewNonNativeConverterConstructor = NewNonNativeConverter +} diff --git a/app/subscription/entries/nonnative/definitions/shadowsocks.jsont b/app/subscription/entries/nonnative/definitions/shadowsocks.jsont new file mode 100644 index 00000000000..0dd3a4c7b66 --- /dev/null +++ b/app/subscription/entries/nonnative/definitions/shadowsocks.jsont @@ -0,0 +1,35 @@ +{{if assertExists . "root_!kind" | not}} Unknown environment {{end}} +{{if assertIsOneOf . "root_!kind" "json" | not}} This template only works for json input. {{end}} + +{{ $methodName := tryGet . "root_!json_method_!unquoted" "root_!json_protocol_!unquoted" "root_!json_cipher_!unquoted"}} +{{if assertValueIsOneOf $methodName "chacha20-ietf-poly1305" "chacha20-poly1305" "aes-128-gcm" "aes-256-gcm" | not}} + This template only works for ss. {{end}} + +{{ $server_address := tryGet . "root_!json_server" "root_!json_address" "root_!json_endpoint"}} +{{ $server_port := tryGet . "root_!json_port" "root_!json_server_port" "root_!json_endpoint"}} +{{if $server_address | splitAndGetAfterNth ":" 0 | len | gt 1}} + {{ $server_addressport_unquoted := tryGet . "root_!json_endpoint_!unquoted"}} + {{ $server_port = $server_addressport_unquoted | splitAndGetAfterNth ":" -1}} + + {{ $server_portWithSep := printf ":%v" $server_port}} + {{ $server_address = $server_addressport_unquoted | stringCutSuffix $server_portWithSep | jsonEncode}} +{{end}} + +{{ $name_annotation := tryGet . "root_!json_name_!unquoted" "root_!json_id_!unquoted" "root_!json_tag_!unquoted" "root_!json_remarks_!unquoted" ""}} + +{{$password := tryGet . "root_!json_password" "root_!json_psk"}} + +{ + "protocol": "shadowsocks", + "settings": { + "address": {{$server_address}}, + "port": {{$server_port}}, + "method": {{$methodName | jsonEncode}}, + "password": {{$password}} + }, + "metadata":{ + + "TagName": {{print $name_annotation "_" $server_address | jsonEncode}} + + } +} \ No newline at end of file diff --git a/app/subscription/entries/nonnative/definitions/shadowsocks2022.jsont b/app/subscription/entries/nonnative/definitions/shadowsocks2022.jsont new file mode 100644 index 00000000000..585008867e9 --- /dev/null +++ b/app/subscription/entries/nonnative/definitions/shadowsocks2022.jsont @@ -0,0 +1,51 @@ +{{if assertExists . "root_!kind" | not}} Unknown environment {{end}} +{{if assertIsOneOf . "root_!kind" "json" | not}} This template only works for json input. {{end}} + +{{ $methodName := tryGet . "root_!json_method_!unquoted" "root_!json_protocol_!unquoted"}} +{{if assertValueIsOneOf $methodName "2022-blake3-aes-128-gcm" "2022-blake3-aes-256-gcm" | not}} + This template only works for ss2022. {{end}} + +{{ $server_address := tryGet . "root_!json_server" "root_!json_address" "root_!json_endpoint"}} +{{ $server_port := tryGet . "root_!json_port" "root_!json_server_port" "root_!json_endpoint"}} +{{if $server_address | splitAndGetAfterNth ":" 0 | len | gt 1}} + {{ $server_addressport_unquoted := tryGet . "root_!json_endpoint_!unquoted"}} + {{ $server_port = $server_addressport_unquoted | splitAndGetAfterNth ":" -1}} + + {{ $server_portWithSep := printf ":%v" $server_port}} + {{ $server_address = $server_addressport_unquoted | stringCutSuffix $server_portWithSep | jsonEncode}} +{{end}} + +{{ $name_annotation := tryGet . "root_!json_name_!unquoted" "root_!json_id_!unquoted" "root_!json_tag_!unquoted" "root_!json_remarks_!unquoted" ""}} + +{{ $psk := tryGet . "root_!json_password_!unquoted" "root_!json_psk_!unquoted"}} +{{ $ipsk_encoded := "" }} +{{if $psk | splitAndGetAfterNth ":" 0 | len | ne 1}} + {{ $origpsk := $psk }} + {{ $psk = $psk | splitAndGetNth ":" -1 }} + {{ $pskWithSep := printf ":%v" $psk}} + {{ $ipsk_encoded = $origpsk | stringCutSuffix $pskWithSep | splitAndGetAfterNth ":" 0 | jsonEncode}} +{{else}} + {{$ipsk_encoded = tryGet . "root_!json_iPSKs" ""}} +{{end}} + + + { + "protocol": "shadowsocks2022", + "settings": { + "address": {{$server_address}}, + "port": {{$server_port}}, + "method": {{$methodName | jsonEncode}}, + "psk": {{$psk | jsonEncode}} + {{if $ipsk_encoded|len|ne 0}} + , + "ipsk": {{$ipsk_encoded}} + {{end}} + }, + + "metadata":{ + + "TagName": {{print $name_annotation "_" $server_address | jsonEncode}} + + } + + } \ No newline at end of file diff --git a/app/subscription/entries/nonnative/definitions/vmess.jsont b/app/subscription/entries/nonnative/definitions/vmess.jsont new file mode 100644 index 00000000000..7c42af3e176 --- /dev/null +++ b/app/subscription/entries/nonnative/definitions/vmess.jsont @@ -0,0 +1,66 @@ +{{if assertExists . "root_!kind" | not}} Unknown environment {{end}} +{{ $protocol_name := tryGet . "root_!link_protocol" "root_!json_type_!unquoted"}} +{{if assertValueIsOneOf $protocol_name "vmess" | not}} This template will only handle vmess link {{end}} + +{{ $server_address := tryGet . "root_!link_host_!base64_!json_add" "root_!json_server"}} +{{ $server_uuid := tryGet . "root_!link_host_!base64_!json_id" "root_!json_uuid"}} +{{ $server_port := tryGet . "root_!link_host_!base64_!json_port_!unquoted" "root_!link_host_!base64_!json_port" "root_!json_port_!unquoted" "root_!json_port"}} + +{{ $transport_type := tryGet . "root_!link_host_!base64_!json_net_!unquoted" "root_!json_network_!unquoted" ""}} +{{ $transport_type = $transport_type | unalias "tcp" ""}} + +{{ $name_annotation := tryGet . "root_!link_host_!base64_!json_ps_!unquoted" "root_!json_name_!unquoted" ""}} + +{{if assertValueIsOneOf $transport_type "tcp" "kcp" "ws" "h2" "quic" "grpc"| not }} + unknown transport type {{end}} + + {{$transport_grpc_service_name := ""}} + {{ if $transport_type | eq "grpc"}} + {{ $transport_grpc_service_name = tryGet . "root_!link_host_!base64_!json_path" ""}} + {{end}} + + {{$transport_ws_path := ""}} + {{ if $transport_type | eq "ws"}} + {{ $transport_ws_path = tryGet . "root_!link_host_!base64_!json_path" "root_!json_ws-opts_!json_path" ""}} + {{end}} + +{{ $security_type := tryGet . "root_!link_host_!base64_!json_tls_!unquoted" "root_!json_tls" ""}} +{{ $security_type = $security_type | unalias "none" "" "false"}} + +{{if assertValueIsOneOf $security_type "tls" "utls" "none"| not }} + unknown security type {{end}} + +{{ $security_tlsmmon_sni := tryGet . "root_!link_host_!base64_!json_sni" ""}} +{{ $security_tlsmmon_sni = $security_tlsmmon_sni | unalias $server_address ""}} + +{ + "protocol": "vmess", + "settings":{ + "address":{{$server_address}}, + "port":{{$server_port}}, + "uuid":{{$server_uuid}} + }, + "streamSettings":{ + "transport":{{$transport_type|jsonEncode}}, + "security":{{$security_type|jsonEncode}}, + "transportSettings":{ + {{ if $transport_type | eq "grpc"}} + "serviceName":{{$transport_grpc_service_name}} + {{end}} + {{ if $transport_type | eq "ws"}} + "path":{{$transport_ws_path}} + {{end}} + }, + + "securitySettings":{ + {{ if $security_type | eq "tls"}} + "serverName":{{$security_tlsmmon_sni}} + {{end}} + } + }, + "metadata":{ + + "TagName": {{print $name_annotation "_" $server_address | jsonEncode}} + + } +} \ No newline at end of file diff --git a/app/subscription/entries/nonnative/matchdef.go b/app/subscription/entries/nonnative/matchdef.go new file mode 100644 index 00000000000..8a95084e4a1 --- /dev/null +++ b/app/subscription/entries/nonnative/matchdef.go @@ -0,0 +1,191 @@ +package nonnative + +import ( + "bytes" + "embed" + "encoding/json" + "io/fs" + "strings" + "text/template" +) + +//go:embed definitions/* +var embeddedDefinitions embed.FS + +func NewDefMatcher() *DefMatcher { + d := &DefMatcher{} + d.init() + return d +} + +type DefMatcher struct { + templates *template.Template +} + +type ExecutionEnvironment struct { + link AbstractNonNativeLink +} + +func (d *DefMatcher) createFuncMap() template.FuncMap { + return map[string]any{ + "assertExists": func(env *ExecutionEnvironment, names ...string) (bool, error) { + link := env.link + for _, v := range names { + _, ok := link.Values[v] + if !ok { + return false, newError("failed assertExists of ", v) + } + } + return true, nil + }, + "assertIsOneOf": func(env *ExecutionEnvironment, name string, values ...string) (bool, error) { + link := env.link + actualValue, ok := link.Values[name] + if !ok { + return false, newError("failed assertIs of non-exist ", name) + } + found := false + for _, currentValue := range values { + if currentValue == actualValue { + found = true + break + } + } + if !found { + return false, newError("failed assertIsOneOf name = ", actualValue, "is not one of ", values) + } + return true, nil + }, + "assertValueIsOneOf": func(value string, values ...string) (bool, error) { + actualValue := value + found := false + for _, currentValue := range values { + if currentValue == actualValue { + found = true + break + } + } + if !found { + return false, newError("failed assertIsOneOf name = ", actualValue, "is not one of ", values) + } + return true, nil + }, + "tryGet": func(env *ExecutionEnvironment, names ...string) (string, error) { + link := env.link + for _, currentName := range names { + value, ok := link.Values[currentName] + if ok { + return value, nil + } else if currentName == "" { + return "", nil + } + } + return "", newError("failed tryGet exists none of ", names) + }, + "splitAndGetNth": func(sep string, n int, content string) (string, error) { + result := strings.Split(content, sep) + if n > len(result)-1 { + return "", newError("failed splitAndGetNth exists too short content:", content, "n = ", n, "sep =", sep) + } + if n < 0 { + n = len(result) + n + if n < 0 { + return "", newError("failed splitAndGetNth exists too short content:", content, "n = ", n, "sep =", sep) + } + } + return result[n], nil + }, + "splitAndGetAfterNth": func(sep string, n int, content string) ([]string, error) { + result := strings.Split(content, sep) + if n < 0 { + n = len(result) + n + } + if n > len(result)-1 { + return []string{}, newError("failed splitAndGetNth exists too short content:", content) + } + return result[n:], nil + }, + "splitAndGetBeforeNth": func(sep string, n int, content string) ([]string, error) { + result := strings.Split(content, sep) + if n < 0 { + n = len(result) + n + } + if n > len(result)-1 { + return []string{}, newError("failed splitAndGetNth exists too short content:", content) + } + return result[:n], nil + }, + "jsonEncode": func(content any) (string, error) { + buf := bytes.NewBuffer(nil) + err := json.NewEncoder(buf).Encode(content) + if err != nil { + return "", newError("unable to jsonQuote ", content).Base(err) + } + return buf.String(), nil + }, + "stringCutSuffix": func(suffix, content string) (string, error) { + remaining, found := strings.CutSuffix(content, suffix) + if !found { + return "", newError("suffix not found in content =", suffix, " suffix =", suffix) + } + return remaining, nil + }, + "unalias": func(standardName string, names ...string) (string, error) { + if len(names) == 0 { + return "", newError("no input value specified") + } + actualInput := names[len(names)-1] + alias := names[:len(names)-1] + for _, v := range alias { + if v == actualInput { + return standardName, nil + } + } + return actualInput, nil + }, + } +} + +func (d *DefMatcher) init() { + d.templates = template.New("root").Funcs(d.createFuncMap()) +} + +func (d *DefMatcher) LoadEmbeddedDefinitions() error { + return d.LoadDefinitions(embeddedDefinitions) +} + +func (d *DefMatcher) LoadDefinitions(fs fs.FS) error { + var err error + d.templates, err = d.templates.ParseFS(fs, "definitions/*.jsont") + if err != nil { + return err + } + return nil +} + +func (d *DefMatcher) ExecuteNamed(link AbstractNonNativeLink, name string) ([]byte, error) { + outputBuffer := bytes.NewBuffer(nil) + env := &ExecutionEnvironment{link: link} + err := d.templates.ExecuteTemplate(outputBuffer, name, env) + if err != nil { + return nil, newError("failed to execute template").Base(err) + } + return outputBuffer.Bytes(), nil +} + +func (d *DefMatcher) ExecuteAll(link AbstractNonNativeLink) ([]byte, error) { + outputBuffer := bytes.NewBuffer(nil) + for _, loadedTemplates := range d.templates.Templates() { + env := &ExecutionEnvironment{link: link} + err := loadedTemplates.Execute(outputBuffer, env) + if err != nil { + outputBuffer.Reset() + } else { + break + } + } + if outputBuffer.Len() == 0 { + return nil, newError("failed to find a working template") + } + return outputBuffer.Bytes(), nil +} diff --git a/app/subscription/entries/nonnative/nonnative.go b/app/subscription/entries/nonnative/nonnative.go new file mode 100644 index 00000000000..fe65839760b --- /dev/null +++ b/app/subscription/entries/nonnative/nonnative.go @@ -0,0 +1,108 @@ +package nonnative + +import ( + "encoding/base64" + "encoding/json" + "net/url" + "regexp" + "strings" +) + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +func ExtractAllValuesFromBytes(bytes []byte) AbstractNonNativeLink { + link := AbstractNonNativeLink{} + link.fromBytes(bytes) + return link +} + +type jsonDocument map[string]json.RawMessage + +type AbstractNonNativeLink struct { + Values map[string]string +} + +func (a *AbstractNonNativeLink) fromBytes(bytes []byte) { + a.Values = make(map[string]string) + content := string(bytes) + content = strings.Trim(content, " \n\t\r") + a.extractValue(content, "root") +} + +func (a *AbstractNonNativeLink) extractValue(content, prefix string) { + { + // check if the content is a link + match, err := regexp.Match("[a-zA-Z0-9]+:((\\/\\/)|\\?)", []byte(content)) + if err != nil { + panic(err) + } + if match { + // if so, parse as link + parsedURL, err := url.Parse(content) + // if process is successful, then continue to parse every element of the link + if err == nil { + a.Values[prefix+"_!kind"] = "link" + a.extractLink(parsedURL, prefix) + return + } + } + } + { + // check if it is base64 + content = strings.Trim(content, "=") + decoded, err := base64.RawStdEncoding.DecodeString(content) + if err == nil { + a.Values[prefix+"_!kind"] = "base64" + a.extractValue(string(decoded), prefix+"_!base64") + return + } + } + { + // check if it is base64url + content = strings.Trim(content, "=") + decoded, err := base64.RawURLEncoding.DecodeString(content) + if err == nil { + a.Values[prefix+"_!kind"] = "base64url" + a.extractValue(string(decoded), prefix+"_!base64") + return + } + } + { + // check if it is json + var doc jsonDocument + if err := json.Unmarshal([]byte(content), &doc); err == nil { + a.Values[prefix+"_!kind"] = "json" + a.extractJSON(&doc, prefix) + return + } + } +} + +func (a *AbstractNonNativeLink) extractLink(content *url.URL, prefix string) { + a.Values[prefix+"_!link"] = content.String() + a.Values[prefix+"_!link_protocol"] = content.Scheme + a.Values[prefix+"_!link_host"] = content.Host + a.extractValue(content.Host, prefix+"_!link_host") + a.Values[prefix+"_!link_path"] = content.Path + a.Values[prefix+"_!link_query"] = content.RawQuery + a.Values[prefix+"_!link_fragment"] = content.Fragment + a.Values[prefix+"_!link_userinfo"] = content.User.String() + a.Values[prefix+"_!link_opaque"] = content.Opaque +} + +func (a *AbstractNonNativeLink) extractJSON(content *jsonDocument, prefix string) { + for key, value := range *content { + switch value[0] { + case '{': + a.extractValue(string(value), prefix+"_!json_"+key) + case '"': + var unquoted string + if err := json.Unmarshal(value, &unquoted); err == nil { + a.Values[prefix+"_!json_"+key+"_!unquoted"] = unquoted + } + fallthrough + default: + a.Values[prefix+"_!json_"+key] = string(value) + } + } +} diff --git a/app/subscription/entries/nonnative/nonnativeifce/nonnativeifce.go b/app/subscription/entries/nonnative/nonnativeifce/nonnativeifce.go new file mode 100644 index 00000000000..f5c207eefe6 --- /dev/null +++ b/app/subscription/entries/nonnative/nonnativeifce/nonnativeifce.go @@ -0,0 +1,11 @@ +package nonnativeifce + +import ( + "io/fs" + + "github.com/v2fly/v2ray-core/v5/app/subscription/entries" +) + +type NonNativeConverterConstructorT func(fs fs.FS) (entries.Converter, error) + +var NewNonNativeConverterConstructor NonNativeConverterConstructorT diff --git a/app/subscription/entries/outbound/outbound.go b/app/subscription/entries/outbound/outbound.go new file mode 100644 index 00000000000..d376d226914 --- /dev/null +++ b/app/subscription/entries/outbound/outbound.go @@ -0,0 +1,33 @@ +package outbound + +import ( + "github.com/v2fly/v2ray-core/v5/app/subscription/entries" + "github.com/v2fly/v2ray-core/v5/app/subscription/specs" + "github.com/v2fly/v2ray-core/v5/common" +) + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +// NewOutboundEntriesParser internal api +func NewOutboundEntriesParser() entries.Converter { + return newOutboundEntriesParser() +} + +func newOutboundEntriesParser() entries.Converter { + return &outboundEntriesParser{} +} + +type outboundEntriesParser struct{} + +func (o *outboundEntriesParser) ConvertToAbstractServerConfig(rawConfig []byte, kindHint string) (*specs.SubscriptionServerConfig, error) { + parser := specs.NewOutboundParser() + outbound, err := parser.ParseOutboundConfig(rawConfig) + if err != nil { + return nil, newError("failed to parse outbound config").Base(err).AtWarning() + } + return parser.ToSubscriptionServerConfig(outbound) +} + +func init() { + common.Must(entries.RegisterConverter("outbound", newOutboundEntriesParser())) +} diff --git a/app/subscription/entries/register.go b/app/subscription/entries/register.go new file mode 100644 index 00000000000..02249d70b80 --- /dev/null +++ b/app/subscription/entries/register.go @@ -0,0 +1,54 @@ +package entries + +import "github.com/v2fly/v2ray-core/v5/app/subscription/specs" + +type ConverterRegistry struct { + knownConverters map[string]Converter + parent *ConverterRegistry +} + +var globalConverterRegistry = &ConverterRegistry{knownConverters: map[string]Converter{}} + +func RegisterConverter(kind string, converter Converter) error { + return globalConverterRegistry.RegisterConverter(kind, converter) +} + +func GetOverlayConverterRegistry() *ConverterRegistry { + return globalConverterRegistry.GetOverlayConverterRegistry() +} + +func (c *ConverterRegistry) RegisterConverter(kind string, converter Converter) error { + if _, found := c.knownConverters[kind]; found { + return newError("converter already registered for kind ", kind) + } + c.knownConverters[kind] = converter + return nil +} + +func (c *ConverterRegistry) TryAllConverters(rawConfig []byte, prioritizedConverter, kindHint string) (*specs.SubscriptionServerConfig, error) { + if prioritizedConverter != "" { + if converter, found := c.knownConverters[prioritizedConverter]; found { + serverConfig, err := converter.ConvertToAbstractServerConfig(rawConfig, kindHint) + if err == nil { + return serverConfig, nil + } + } + } + + for _, converter := range c.knownConverters { + serverConfig, err := converter.ConvertToAbstractServerConfig(rawConfig, kindHint) + if err == nil { + return serverConfig, nil + } + } + if c.parent != nil { + if serverConfig, err := c.parent.TryAllConverters(rawConfig, prioritizedConverter, kindHint); err == nil { + return serverConfig, nil + } + } + return nil, newError("no converter found for config") +} + +func (c *ConverterRegistry) GetOverlayConverterRegistry() *ConverterRegistry { + return &ConverterRegistry{knownConverters: map[string]Converter{}, parent: c} +} diff --git a/app/subscription/specs/abstract_spec.proto b/app/subscription/specs/abstract_spec.proto new file mode 100644 index 00000000000..1b4951010f6 --- /dev/null +++ b/app/subscription/specs/abstract_spec.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package v2ray.core.app.subscription.specs; + +option csharp_namespace = "V2Ray.Core.App.Subscription.Specs"; +option go_package = "github.com/v2fly/v2ray-core/v5/app/subscription/specs"; +option java_package = "com.v2ray.core.app.subscription.specs"; +option java_multiple_files = true; + +import "google/protobuf/any.proto"; + +message ServerConfiguration{ + string protocol = 1; + google.protobuf.Any protocol_settings = 2; + string transport = 3; + google.protobuf.Any transport_settings = 4; + string security = 5; + google.protobuf.Any security_settings = 6; +} + +message SubscriptionServerConfig{ + string id = 1; + map metadata = 2; + ServerConfiguration configuration = 3; +} + +message SubscriptionDocument { + map metadata = 2; + repeated SubscriptionServerConfig server = 3; +} \ No newline at end of file diff --git a/app/subscription/specs/outbound_parser.go b/app/subscription/specs/outbound_parser.go new file mode 100644 index 00000000000..b309efd11cc --- /dev/null +++ b/app/subscription/specs/outbound_parser.go @@ -0,0 +1,90 @@ +package specs + +import ( + "bytes" + "context" + "encoding/json" + + "github.com/golang/protobuf/proto" + + "github.com/v2fly/v2ray-core/v5/common/registry" + "github.com/v2fly/v2ray-core/v5/common/serial" +) + +func NewOutboundParser() *OutboundParser { + return &OutboundParser{} +} + +type OutboundParser struct{} + +func (p *OutboundParser) ParseOutboundConfig(rawConfig []byte) (*OutboundConfig, error) { + skeleton := &OutboundConfig{} + decoder := json.NewDecoder(bytes.NewReader(rawConfig)) + decoder.DisallowUnknownFields() + err := decoder.Decode(skeleton) + if err != nil { + return nil, newError("failed to parse outbound config skeleton").Base(err) + } + return skeleton, nil +} + +func (p *OutboundParser) toAbstractServerSpec(config *OutboundConfig) (*ServerConfiguration, error) { + serverConfig := &ServerConfiguration{} + serverConfig.Protocol = config.Protocol + { + protocolSettings, err := loadHeterogeneousConfigFromRawJSONRestricted("outbound", config.Protocol, config.Settings) + if err != nil { + return nil, newError("failed to parse protocol settings").Base(err) + } + serverConfig.ProtocolSettings = serial.ToTypedMessage(protocolSettings) + } + + if config.StreamSetting != nil { + if config.StreamSetting.Transport == "" { + config.StreamSetting.Transport = "tcp" + } + if config.StreamSetting.Security == "" { + config.StreamSetting.Security = "none" + } + { + serverConfig.Transport = config.StreamSetting.Transport + transportSettings, err := loadHeterogeneousConfigFromRawJSONRestricted( + "transport", config.StreamSetting.Transport, config.StreamSetting.TransportSettings) + if err != nil { + return nil, newError("failed to parse transport settings").Base(err) + } + serverConfig.TransportSettings = serial.ToTypedMessage(transportSettings) + } + { + securitySettings, err := loadHeterogeneousConfigFromRawJSONRestricted( + "security", config.StreamSetting.Security, config.StreamSetting.SecuritySettings) + if err != nil { + return nil, newError("failed to parse security settings").Base(err) + } + + serverConfig.SecuritySettings = serial.ToTypedMessage(securitySettings) + serverConfig.Security = serial.V2Type(serverConfig.SecuritySettings) + } + } + return serverConfig, nil +} + +func (p *OutboundParser) ToSubscriptionServerConfig(config *OutboundConfig) (*SubscriptionServerConfig, error) { + serverSpec, err := p.toAbstractServerSpec(config) + if err != nil { + return nil, newError("unable to parse server specification") + } + return &SubscriptionServerConfig{ + Configuration: serverSpec, + Metadata: config.Metadata, + }, nil +} + +func loadHeterogeneousConfigFromRawJSONRestricted(interfaceType, name string, rawJSON json.RawMessage) (proto.Message, error) { + ctx := context.TODO() + ctx = registry.CreateRestrictedModeContext(ctx) + if len(rawJSON) == 0 { + rawJSON = []byte("{}") + } + return registry.LoadImplementationByAlias(ctx, interfaceType, name, []byte(rawJSON)) +} diff --git a/app/subscription/specs/skeleton.go b/app/subscription/specs/skeleton.go new file mode 100644 index 00000000000..42e4f0e8d10 --- /dev/null +++ b/app/subscription/specs/skeleton.go @@ -0,0 +1,19 @@ +package specs + +import ( + "encoding/json" +) + +type OutboundConfig struct { + Protocol string `json:"protocol"` + Settings json.RawMessage `json:"settings"` + StreamSetting *StreamConfig `json:"streamSettings"` + Metadata map[string]string `json:"metadata"` +} + +type StreamConfig struct { + Transport string `json:"transport"` + TransportSettings json.RawMessage `json:"transportSettings"` + Security string `json:"security"` + SecuritySettings json.RawMessage `json:"securitySettings"` +} diff --git a/app/subscription/specs/specs.go b/app/subscription/specs/specs.go new file mode 100644 index 00000000000..14a73792cc5 --- /dev/null +++ b/app/subscription/specs/specs.go @@ -0,0 +1,3 @@ +package specs + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen diff --git a/app/subscription/subscription.go b/app/subscription/subscription.go new file mode 100644 index 00000000000..f4cd634fead --- /dev/null +++ b/app/subscription/subscription.go @@ -0,0 +1,3 @@ +package subscription + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen diff --git a/app/subscription/subscriptionmanager/delta.go b/app/subscription/subscriptionmanager/delta.go new file mode 100644 index 00000000000..95ca2cbd84a --- /dev/null +++ b/app/subscription/subscriptionmanager/delta.go @@ -0,0 +1,8 @@ +package subscriptionmanager + +type changedDocument struct { + removed []string + added []string + modified []string + unchanged []string +} diff --git a/app/subscription/subscriptionmanager/known_metadata.go b/app/subscription/subscriptionmanager/known_metadata.go new file mode 100644 index 00000000000..c978fdcf8ec --- /dev/null +++ b/app/subscription/subscriptionmanager/known_metadata.go @@ -0,0 +1,7 @@ +package subscriptionmanager + +const ( + ServerMetadataID = "ID" + ServerMetadataTagName = "TagName" + ServerMetadataFullyQualifiedName = "FullyQualifiedName" +) diff --git a/app/subscription/subscriptionmanager/manager.go b/app/subscription/subscriptionmanager/manager.go new file mode 100644 index 00000000000..5f10fcb95bd --- /dev/null +++ b/app/subscription/subscriptionmanager/manager.go @@ -0,0 +1,103 @@ +package subscriptionmanager + +import ( + "archive/zip" + "bytes" + "context" + "time" + + core "github.com/v2fly/v2ray-core/v5" + "github.com/v2fly/v2ray-core/v5/app/subscription" + "github.com/v2fly/v2ray-core/v5/app/subscription/entries" + "github.com/v2fly/v2ray-core/v5/app/subscription/entries/nonnative/nonnativeifce" + "github.com/v2fly/v2ray-core/v5/common" + "github.com/v2fly/v2ray-core/v5/common/task" + "github.com/v2fly/v2ray-core/v5/features/extension" +) + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +type SubscriptionManagerImpl struct { + config *subscription.Config + ctx context.Context + + s *core.Instance + converter *entries.ConverterRegistry + + trackedSubscriptions map[string]*trackedSubscription + + refreshTask *task.Periodic +} + +func (s *SubscriptionManagerImpl) Type() interface{} { + return extension.SubscriptionManagerType() +} + +func (s *SubscriptionManagerImpl) housekeeping() error { + for subscriptionName := range s.trackedSubscriptions { + if err := s.checkupSubscription(subscriptionName); err != nil { + newError("failed to checkup subscription: ", err).AtWarning().WriteToLog() + } + } + return nil +} + +func (s *SubscriptionManagerImpl) Start() error { + if err := s.refreshTask.Start(); err != nil { + return err + } + return nil +} + +func (s *SubscriptionManagerImpl) Close() error { + if err := s.refreshTask.Close(); err != nil { + return err + } + return nil +} + +func (s *SubscriptionManagerImpl) init() error { + s.refreshTask = &task.Periodic{ + Interval: time.Duration(60) * time.Second, + Execute: s.housekeeping, + } + s.trackedSubscriptions = make(map[string]*trackedSubscription) + s.converter = entries.GetOverlayConverterRegistry() + if s.config.NonnativeConverterOverlay != nil { + zipReader, err := zip.NewReader(bytes.NewReader(s.config.NonnativeConverterOverlay), int64(len(s.config.NonnativeConverterOverlay))) + if err != nil { + return newError("failed to read nonnative converter overlay: ", err) + } + converter, err := nonnativeifce.NewNonNativeConverterConstructor(zipReader) + if err != nil { + return newError("failed to construct nonnative converter: ", err) + } + if err := s.converter.RegisterConverter("user_nonnative", converter); err != nil { + return newError("failed to register user nonnative converter: ", err) + } + } + + for _, v := range s.config.Imports { + tracked, err := newTrackedSubscription(v) + if err != nil { + return newError("failed to init subscription ", v.Name, ": ", err) + } + s.trackedSubscriptions[v.Name] = tracked + } + return nil +} + +func NewSubscriptionManager(ctx context.Context, config *subscription.Config) (*SubscriptionManagerImpl, error) { + instance := core.MustFromContext(ctx) + impl := &SubscriptionManagerImpl{ctx: ctx, s: instance, config: config} + if err := impl.init(); err != nil { + return nil, newError("failed to init subscription manager: ", err) + } + return impl, nil +} + +func init() { + common.Must(common.RegisterConfig((*subscription.Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { + return NewSubscriptionManager(ctx, config.(*subscription.Config)) + })) +} diff --git a/app/subscription/subscriptionmanager/serverspec_materialize.go b/app/subscription/subscriptionmanager/serverspec_materialize.go new file mode 100644 index 00000000000..53e1cbac663 --- /dev/null +++ b/app/subscription/subscriptionmanager/serverspec_materialize.go @@ -0,0 +1,50 @@ +package subscriptionmanager + +import ( + core "github.com/v2fly/v2ray-core/v5" + "github.com/v2fly/v2ray-core/v5/app/proxyman" + "github.com/v2fly/v2ray-core/v5/app/subscription/specs" + "github.com/v2fly/v2ray-core/v5/common/serial" + "github.com/v2fly/v2ray-core/v5/transport/internet" +) + +func (s *SubscriptionManagerImpl) materialize(subscriptionName, tagName string, serverSpec *specs.SubscriptionServerConfig) (*core.OutboundHandlerConfig, error) { + outboundConf, err := s.getOutboundTemplateForSubscriptionName(subscriptionName) + if err != nil { + return nil, newError("failed to get outbound template for subscription name: ", err) + } + + senderSettingsIfcd, err := serial.GetInstanceOf(outboundConf.SenderSettings) + if err != nil { + return nil, newError("failed to get sender settings: ", err) + } + senderSettings := senderSettingsIfcd.(*proxyman.SenderConfig) + + if serverSpec.Configuration.Transport != "" { + senderSettings.StreamSettings.ProtocolName = serverSpec.Configuration.Transport + senderSettings.StreamSettings.TransportSettings = append(senderSettings.StreamSettings.TransportSettings, + &internet.TransportConfig{ProtocolName: serverSpec.Configuration.Transport, Settings: serverSpec.Configuration.TransportSettings}) + } + + if serverSpec.Configuration.Security != "" { + senderSettings.StreamSettings.SecurityType = serverSpec.Configuration.Security + senderSettings.StreamSettings.SecuritySettings = append(senderSettings.StreamSettings.SecuritySettings, + serverSpec.Configuration.SecuritySettings) + } + + outboundConf.SenderSettings = serial.ToTypedMessage(senderSettings) + + outboundConf.ProxySettings = serverSpec.Configuration.ProtocolSettings + + outboundConf.Tag = tagName + + return outboundConf, nil +} + +func (s *SubscriptionManagerImpl) getOutboundTemplateForSubscriptionName(subscriptionName string) (*core.OutboundHandlerConfig, error) { //nolint: unparam + senderSetting := &proxyman.SenderConfig{ + DomainStrategy: proxyman.SenderConfig_AS_IS, StreamSettings: &internet.StreamConfig{}, + } + + return &core.OutboundHandlerConfig{SenderSettings: serial.ToTypedMessage(senderSetting)}, nil +} diff --git a/app/subscription/subscriptionmanager/subdocapplier.go b/app/subscription/subscriptionmanager/subdocapplier.go new file mode 100644 index 00000000000..56756864efe --- /dev/null +++ b/app/subscription/subscriptionmanager/subdocapplier.go @@ -0,0 +1,121 @@ +package subscriptionmanager + +import ( + "fmt" + + core "github.com/v2fly/v2ray-core/v5" + "github.com/v2fly/v2ray-core/v5/app/subscription/specs" +) + +func (s *SubscriptionManagerImpl) applySubscriptionTo(name string, document *specs.SubscriptionDocument) error { + var trackedSub *trackedSubscription + if trackedSubFound, found := s.trackedSubscriptions[name]; !found { + return newError("not found") + } else { + trackedSub = trackedSubFound + } + + delta, err := trackedSub.diff(document) + if err != nil { + return err + } + + nameToServerConfig := make(map[string]*specs.SubscriptionServerConfig) + for _, server := range document.Server { + nameToServerConfig[server.Id] = server + } + + for _, serverName := range delta.removed { + if err := s.removeManagedServer(name, serverName); err != nil { + newError("failed to remove managed server: ", err).AtWarning().WriteToLog() + continue + } + trackedSub.recordRemovedServer(serverName) + } + + for _, serverName := range delta.modified { + serverConfig := nameToServerConfig[serverName] + if err := s.updateManagedServer(name, serverName, serverConfig); err != nil { + newError("failed to update managed server: ", err).AtWarning().WriteToLog() + continue + } + trackedSub.recordUpdatedServer(serverName, serverConfig.Metadata[ServerMetadataTagName], serverConfig) + } + + for _, serverName := range delta.added { + serverConfig := nameToServerConfig[serverName] + if err := s.addManagedServer(name, serverName, serverConfig); err != nil { + newError("failed to add managed server: ", err).AtWarning().WriteToLog() + continue + } + trackedSub.recordUpdatedServer(serverName, serverConfig.Metadata[ServerMetadataTagName], serverConfig) + } + + newError("finished applying subscription, ", name, "; ", fmt.Sprintf( + "%v updated, %v added, %v removed, %v unchanged", + len(delta.modified), len(delta.added), len(delta.removed), len(delta.unchanged))).AtInfo().WriteToLog() + + return nil +} + +func (s *SubscriptionManagerImpl) removeManagedServer(subscriptionName, serverName string) error { + var trackedSub *trackedSubscription + if trackedSubFound, found := s.trackedSubscriptions[subscriptionName]; !found { + return newError("not found") + } else { + trackedSub = trackedSubFound + } + + var trackedServer *materializedServer + if trackedServerFound, err := trackedSub.getCurrentServer(serverName); err != nil { + return err + } else { + trackedServer = trackedServerFound + } + + tagName := fmt.Sprintf("%s_%s", trackedSub.importSource.TagPrefix, trackedServer.tagPostfix) + + if err := core.RemoveOutboundHandler(s.s, tagName); err != nil { + return newError("failed to remove handler: ", err) + } + trackedSub.recordRemovedServer(serverName) + return nil +} + +func (s *SubscriptionManagerImpl) addManagedServer(subscriptionName, serverName string, + serverSpec *specs.SubscriptionServerConfig, +) error { + var trackedSub *trackedSubscription + if trackedSubFound, found := s.trackedSubscriptions[subscriptionName]; !found { + return newError("not found") + } else { + trackedSub = trackedSubFound + } + tagPostfix := serverSpec.Metadata[ServerMetadataTagName] + tagName := fmt.Sprintf("%s_%s", trackedSub.importSource.TagPrefix, tagPostfix) + + materialized, err := s.materialize(subscriptionName, tagName, serverSpec) + if err != nil { + return newError("failed to materialize server: ", err) + } + + if err := core.AddOutboundHandler(s.s, materialized); err != nil { + return newError("failed to add handler: ", err) + } + + trackedSub.recordUpdatedServer(serverName, tagPostfix, serverSpec) + + return nil +} + +func (s *SubscriptionManagerImpl) updateManagedServer(subscriptionName, serverName string, + serverSpec *specs.SubscriptionServerConfig, +) error { + if err := s.removeManagedServer(subscriptionName, serverName); err != nil { + return newError("failed to update managed server: ", err).AtWarning() + } + if err := s.addManagedServer(subscriptionName, serverName, serverSpec); err != nil { + return newError("failed to update managed server : ", err).AtWarning() + } + return nil +} diff --git a/app/subscription/subscriptionmanager/subdocchecker.go b/app/subscription/subscriptionmanager/subdocchecker.go new file mode 100644 index 00000000000..d876dfd5a37 --- /dev/null +++ b/app/subscription/subscriptionmanager/subdocchecker.go @@ -0,0 +1,26 @@ +package subscriptionmanager + +import "time" + +func (s *SubscriptionManagerImpl) checkupSubscription(subscriptionName string) error { + var trackedSub *trackedSubscription + if trackedSubFound, found := s.trackedSubscriptions[subscriptionName]; !found { + return newError("not found") + } else { + trackedSub = trackedSubFound + } + + shouldUpdate := false + + if trackedSub.currentDocumentExpireTime.Before(time.Now()) { + shouldUpdate = true + } + + if shouldUpdate { + if err := s.updateSubscription(subscriptionName); err != nil { + return newError("failed to update subscription: ", err) + } + } + + return nil +} diff --git a/app/subscription/subscriptionmanager/subdocupdater.go b/app/subscription/subscriptionmanager/subdocupdater.go new file mode 100644 index 00000000000..86013e79eda --- /dev/null +++ b/app/subscription/subscriptionmanager/subdocupdater.go @@ -0,0 +1,114 @@ +package subscriptionmanager + +import ( + "fmt" + "strings" + "time" + "unicode" + + "golang.org/x/crypto/sha3" + + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/app/subscription/documentfetcher" + "github.com/v2fly/v2ray-core/v5/app/subscription/specs" +) + +func (s *SubscriptionManagerImpl) updateSubscription(subscriptionName string) error { + var trackedSub *trackedSubscription + if trackedSubFound, found := s.trackedSubscriptions[subscriptionName]; !found { + return newError("not found") + } else { + trackedSub = trackedSubFound + } + importSource := trackedSub.importSource + + docFetcher, err := documentfetcher.GetFetcher("http") + if err != nil { + return newError("failed to get fetcher: ", err) + } + + downloadedDocument, err := docFetcher.DownloadDocument(s.ctx, importSource) + if err != nil { + return newError("failed to download document: ", err) + } + + trackedSub.originalDocument = downloadedDocument + + container, err := containers.TryAllParsers(trackedSub.originalDocument, "") + if err != nil { + return newError("failed to parse document: ", err) + } + + trackedSub.originalContainer = container + + parsedDocument := &specs.SubscriptionDocument{} + parsedDocument.Metadata = container.Metadata + + trackedSub.originalServerConfig = make(map[string]*originalServerConfig) + + for _, server := range trackedSub.originalContainer.ServerSpecs { + documentHash := sha3.Sum256(server.Content) + 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} + continue + } + s.polyfillServerConfig(parsed, serverConfigHashName) + parsedDocument.Server = append(parsedDocument.Server, parsed) + trackedSub.originalServerConfig[parsed.Id] = &originalServerConfig{data: server.Content} + } + newError("new subscription document fetched and parsed from ", subscriptionName).AtInfo().WriteToLog() + if err := s.applySubscriptionTo(subscriptionName, parsedDocument); err != nil { + return newError("failed to apply subscription: ", err) + } + trackedSub.currentDocument = parsedDocument + trackedSub.currentDocumentExpireTime = time.Now().Add(time.Second * time.Duration(importSource.DefaultExpireSeconds)) + return nil +} + +func (s *SubscriptionManagerImpl) polyfillServerConfig(document *specs.SubscriptionServerConfig, hash string) { + document.Id = hash + + if document.Metadata == nil { + document.Metadata = make(map[string]string) + } + + if id, ok := document.Metadata[ServerMetadataID]; !ok || id == "" { + document.Metadata[ServerMetadataID] = document.Id + } else { + document.Id = document.Metadata[ServerMetadataID] + } + + if fqn, ok := document.Metadata[ServerMetadataFullyQualifiedName]; !ok || fqn == "" { + document.Metadata[ServerMetadataFullyQualifiedName] = hash + } + + if tagName, ok := document.Metadata[ServerMetadataTagName]; !ok || tagName == "" { + document.Metadata[ServerMetadataTagName] = document.Metadata[ServerMetadataID] + } + document.Metadata[ServerMetadataTagName] = s.restrictTagName(document.Metadata[ServerMetadataTagName]) +} + +func (s *SubscriptionManagerImpl) restrictTagName(tagName string) string { + newTagName := &strings.Builder{} + somethingRemoved := false + for _, c := range tagName { + if (unicode.IsLetter(c) || unicode.IsNumber(c)) && c < 128 { + newTagName.WriteRune(c) + } else { + somethingRemoved = true + } + } + newTagNameString := newTagName.String() + if len(newTagNameString) > 24 { + newTagNameString = newTagNameString[:15] + somethingRemoved = true + } + if somethingRemoved { + hashedTagName := sha3.Sum256([]byte(tagName)) + hashedTagNameString := fmt.Sprintf("%x", hashedTagName) + newTagNameString = newTagNameString + "_" + hashedTagNameString[:8] + } + return newTagNameString +} diff --git a/app/subscription/subscriptionmanager/tracked_subscription.go b/app/subscription/subscriptionmanager/tracked_subscription.go new file mode 100644 index 00000000000..b473d8ec6a5 --- /dev/null +++ b/app/subscription/subscriptionmanager/tracked_subscription.go @@ -0,0 +1,78 @@ +package subscriptionmanager + +import ( + "time" + + "github.com/v2fly/v2ray-core/v5/app/subscription" + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/app/subscription/specs" +) + +func newTrackedSubscription(importSource *subscription.ImportSource) (*trackedSubscription, error) { //nolint: unparam + return &trackedSubscription{importSource: importSource, materialized: map[string]*materializedServer{}}, nil +} + +type trackedSubscription struct { + importSource *subscription.ImportSource + + currentDocumentExpireTime time.Time + currentDocument *specs.SubscriptionDocument + + materialized map[string]*materializedServer + + originalDocument []byte + originalContainer *containers.Container + originalServerConfig map[string]*originalServerConfig +} + +type originalServerConfig struct { + data []byte +} + +func (s *trackedSubscription) diff(newDocument *specs.SubscriptionDocument) (changedDocument, error) { //nolint: unparam + delta := changedDocument{} + seen := make(map[string]bool) + + for _, server := range newDocument.Server { + if currentMaterialized, found := s.materialized[server.Id]; found { + if currentMaterialized.serverConfig.Metadata[ServerMetadataFullyQualifiedName] == server.Metadata[ServerMetadataFullyQualifiedName] { + delta.unchanged = append(delta.unchanged, server.Id) + } else { + delta.modified = append(delta.modified, server.Id) + } + seen[server.Id] = true + } else { + delta.added = append(delta.added, server.Id) + } + } + + for name := range s.materialized { + if _, ok := seen[name]; !ok { + delta.removed = append(delta.removed, name) + } + } + + return delta, nil +} + +func (s *trackedSubscription) recordRemovedServer(name string) { + delete(s.materialized, name) +} + +func (s *trackedSubscription) recordUpdatedServer(name, tagPostfix string, serverConfig *specs.SubscriptionServerConfig) { + s.materialized[name] = &materializedServer{tagPostfix: tagPostfix, serverConfig: serverConfig} +} + +func (s *trackedSubscription) getCurrentServer(name string) (*materializedServer, error) { + if materialized, found := s.materialized[name]; found { + return materialized, nil + } else { + return nil, newError("not found") + } +} + +type materializedServer struct { + tagPostfix string + + serverConfig *specs.SubscriptionServerConfig +} diff --git a/common/environment/rootcap.go b/common/environment/rootcap.go index 6fe376d3a4d..7f32a8acf77 100644 --- a/common/environment/rootcap.go +++ b/common/environment/rootcap.go @@ -3,5 +3,6 @@ package environment type RootEnvironment interface { AppEnvironment(tag string) AppEnvironment ProxyEnvironment(tag string) ProxyEnvironment + DropProxyEnvironment(tag string) error doNotImpl() } diff --git a/common/environment/rootcap_impl.go b/common/environment/rootcap_impl.go index 2bbf862e239..adc5567bfd7 100644 --- a/common/environment/rootcap_impl.go +++ b/common/environment/rootcap_impl.go @@ -58,6 +58,14 @@ func (r *rootEnvImpl) ProxyEnvironment(tag string) ProxyEnvironment { } } +func (r *rootEnvImpl) DropProxyEnvironment(tag string) error { + transientStorage, err := r.transientStorage.NarrowScope(r.ctx, tag) + if err != nil { + return err + } + return transientStorage.DropScope(r.ctx, tag) +} + type appEnvImpl struct { transientStorage storage.ScopedTransientStorage systemDialer internet.SystemDialer @@ -83,7 +91,7 @@ func (a *appEnvImpl) Listener() internet.SystemListener { } func (a *appEnvImpl) OutboundDialer() tagged.DialFunc { - panic("implement me") + return internet.DialTaggedOutbound } func (a *appEnvImpl) OpenFileForReadSeek() fsifce.FileSeekerFunc { diff --git a/common/protoext/extensions.pb.go b/common/protoext/extensions.pb.go index 2a9d23e4358..cbeaf2b4687 100644 --- a/common/protoext/extensions.pb.go +++ b/common/protoext/extensions.pb.go @@ -23,6 +23,9 @@ type MessageOpt struct { Type []string `protobuf:"bytes,1,rep,name=type,proto3" json:"type,omitempty"` ShortName []string `protobuf:"bytes,2,rep,name=short_name,json=shortName,proto3" json:"short_name,omitempty"` TransportOriginalName string `protobuf:"bytes,86001,opt,name=transport_original_name,json=transportOriginalName,proto3" json:"transport_original_name,omitempty"` + // allow_restricted_mode_load allow this config to be loaded in restricted mode + // this is typically used when a an attacker can control the content + AllowRestrictedModeLoad bool `protobuf:"varint,86002,opt,name=allow_restricted_mode_load,json=allowRestrictedModeLoad,proto3" json:"allow_restricted_mode_load,omitempty"` } func (x *MessageOpt) Reset() { @@ -78,6 +81,13 @@ func (x *MessageOpt) GetTransportOriginalName() string { return "" } +func (x *MessageOpt) GetAllowRestrictedModeLoad() bool { + if x != nil { + return x.AllowRestrictedModeLoad + } + return false +} + type FieldOpt struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -217,14 +227,18 @@ var file_common_protoext_extensions_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x65, 0x78, 0x74, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x79, 0x0a, 0x0a, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x38, 0x0a, 0x17, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6f, - 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0xf1, 0x9f, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4f, - 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xd0, 0x02, 0x0a, 0x08, + 0x22, 0xb8, 0x01, 0x0a, 0x0a, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x38, 0x0a, 0x17, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, + 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0xf1, 0x9f, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3d, 0x0a, 0x1a, + 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, + 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0xf2, 0x9f, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x17, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x52, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, + 0x74, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x61, 0x64, 0x22, 0xd0, 0x02, 0x0a, 0x08, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x6e, 0x79, 0x5f, 0x77, 0x61, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x61, 0x6e, 0x79, 0x57, 0x61, 0x6e, 0x74, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, diff --git a/common/protoext/extensions.proto b/common/protoext/extensions.proto index e7fd821401d..3fd7bf26ce4 100644 --- a/common/protoext/extensions.proto +++ b/common/protoext/extensions.proto @@ -21,6 +21,10 @@ message MessageOpt{ repeated string short_name = 2; string transport_original_name = 86001; + + // allow_restricted_mode_load allow this config to be loaded in restricted mode + // this is typically used when a an attacker can control the content + bool allow_restricted_mode_load = 86002; } message FieldOpt{ diff --git a/common/protofilter/filter.go b/common/protofilter/filter.go index d83c0942fa1..521d0d1c428 100644 --- a/common/protofilter/filter.go +++ b/common/protofilter/filter.go @@ -85,8 +85,11 @@ func filterMessage(ctx context.Context, message protoreflect.Message) error { } fsenvironment := envctx.EnvironmentFromContext(ctx) - fsifce := fsenvironment.(filesystemcap.FileSystemCapabilitySet) + fsifce, fsifceOk := fsenvironment.(filesystemcap.FileSystemCapabilitySet) for _, v := range fileReadingQueue { + if !fsifceOk { + return newError("unable to read file as filesystem capability is not given") + } field := message.Descriptor().Fields().ByTextName(v.field) if v.filename == "" { continue diff --git a/common/registry/registry.go b/common/registry/registry.go index b62e9a0cdb3..8d0731fed42 100644 --- a/common/registry/registry.go +++ b/common/registry/registry.go @@ -72,6 +72,13 @@ func (i *implementationRegistry) LoadImplementationByAlias(ctx context.Context, } implementationConfigInstancev2 := proto.MessageV2(implementationConfigInstance) + + if isRestrictedModeContext(ctx) { + if err := enforceRestriction(implementationConfigInstancev2); err != nil { + return nil, err + } + } + if err := protofilter.FilterProtoConfig(ctx, implementationConfigInstancev2); err != nil { return nil, err } diff --git a/common/registry/restrict.go b/common/registry/restrict.go new file mode 100644 index 00000000000..47e16793bfe --- /dev/null +++ b/common/registry/restrict.go @@ -0,0 +1,35 @@ +package registry + +import ( + "context" + + "google.golang.org/protobuf/proto" + + "github.com/v2fly/v2ray-core/v5/common/protoext" +) + +const restrictedLoadModeCtx = "restrictedLoadModeCtx" + +func CreateRestrictedModeContext(ctx context.Context) context.Context { + return context.WithValue(ctx, restrictedLoadModeCtx, true) //nolint: staticcheck +} + +func isRestrictedModeContext(ctx context.Context) bool { + v := ctx.Value(restrictedLoadModeCtx) + if v == nil { + return false + } + return v.(bool) +} + +func enforceRestriction(config proto.Message) error { + configDescriptor := config.ProtoReflect().Descriptor() + msgOpts, err := protoext.GetMessageOptions(configDescriptor) + if err != nil { + return newError("unable to find message options").Base(err) + } + if !msgOpts.AllowRestrictedModeLoad { + return newError("component has not opted in for load in restricted mode") + } + return nil +} diff --git a/features/extension/subscription.go b/features/extension/subscription.go new file mode 100644 index 00000000000..cbc51061a00 --- /dev/null +++ b/features/extension/subscription.go @@ -0,0 +1,11 @@ +package extension + +import "github.com/v2fly/v2ray-core/v5/features" + +type SubscriptionManager interface { + features.Feature +} + +func SubscriptionManagerType() interface{} { + return (*SubscriptionManager)(nil) +} diff --git a/main/commands/all/engineering/engineering.go b/main/commands/all/engineering/engineering.go index d1883d1e1a2..fb31d8349df 100644 --- a/main/commands/all/engineering/engineering.go +++ b/main/commands/all/engineering/engineering.go @@ -9,6 +9,9 @@ var cmdEngineering = &base.Command{ Commands: []*base.Command{ cmdConvertPb, cmdReversePb, + cmdNonNativeLinkExtract, + cmdNonNativeLinkExec, + cmdSubscriptionEntriesExtract, }, } diff --git a/main/commands/all/engineering/nonnativelinkexec.go b/main/commands/all/engineering/nonnativelinkexec.go new file mode 100644 index 00000000000..7ae3df168e8 --- /dev/null +++ b/main/commands/all/engineering/nonnativelinkexec.go @@ -0,0 +1,54 @@ +package engineering + +import ( + "bytes" + "flag" + "io" + "os" + + "github.com/v2fly/v2ray-core/v5/app/subscription/entries/nonnative" + "github.com/v2fly/v2ray-core/v5/main/commands/base" +) + +var cmdNonNativeLinkExecInputName *string + +var cmdNonNativeLinkExecTemplatePath *string + +var cmdNonNativeLinkExec = &base.Command{ + UsageLine: "{{.Exec}} engineering nonnativelinkexec", + Flag: func() flag.FlagSet { + fs := flag.NewFlagSet("", flag.ExitOnError) + cmdNonNativeLinkExecInputName = fs.String("name", "", "") + cmdNonNativeLinkExecTemplatePath = fs.String("templatePath", "", "path for template directory (WARNING: This will not stop templates from reading file outside this directory)") + return *fs + }(), + Run: func(cmd *base.Command, args []string) { + cmd.Flag.Parse(args) + + content, err := io.ReadAll(os.Stdin) + if err != nil { + base.Fatalf("%s", err) + } + flattenedLink := nonnative.ExtractAllValuesFromBytes(content) + + matcher := nonnative.NewDefMatcher() + if *cmdNonNativeLinkExecTemplatePath != "" { + osFs := os.DirFS(*cmdNonNativeLinkExecTemplatePath) + err = matcher.LoadDefinitions(osFs) + if err != nil { + base.Fatalf("%s", err) + } + } else { + err = matcher.LoadEmbeddedDefinitions() + if err != nil { + base.Fatalf("%s", err) + } + } + + spec, err := matcher.ExecuteNamed(flattenedLink, *cmdNonNativeLinkExecInputName) + if err != nil { + base.Fatalf("%s", err) + } + io.Copy(os.Stdout, bytes.NewReader(spec)) + }, +} diff --git a/main/commands/all/engineering/nonnativelinkextract.go b/main/commands/all/engineering/nonnativelinkextract.go new file mode 100644 index 00000000000..2d88ebc08b6 --- /dev/null +++ b/main/commands/all/engineering/nonnativelinkextract.go @@ -0,0 +1,55 @@ +package engineering + +import ( + "flag" + "fmt" + "io" + "os" + "sort" + "strings" + + "github.com/v2fly/v2ray-core/v5/app/subscription/entries/nonnative" + "github.com/v2fly/v2ray-core/v5/main/commands/base" +) + +type valueContainer struct { + key, value string +} + +type orderedValueContainer []valueContainer + +func (o *orderedValueContainer) Len() int { + return len(*o) +} + +func (o *orderedValueContainer) Less(i, j int) bool { + return strings.Compare((*o)[i].key, (*o)[j].key) < 0 +} + +func (o *orderedValueContainer) Swap(i, j int) { + (*o)[i], (*o)[j] = (*o)[j], (*o)[i] +} + +var cmdNonNativeLinkExtract = &base.Command{ + UsageLine: "{{.Exec}} engineering nonnativelinkextract", + Flag: func() flag.FlagSet { + fs := flag.NewFlagSet("", flag.ExitOnError) + return *fs + }(), + Run: func(cmd *base.Command, args []string) { + content, err := io.ReadAll(os.Stdin) + if err != nil { + base.Fatalf("%s", err) + } + flattenedLink := nonnative.ExtractAllValuesFromBytes(content) + var valueContainerOrdered orderedValueContainer + + for key, value := range flattenedLink.Values { + valueContainerOrdered = append(valueContainerOrdered, valueContainer{key, value}) + } + sort.Sort(&valueContainerOrdered) + for _, valueContainer := range valueContainerOrdered { + io.WriteString(os.Stdout, fmt.Sprintf("%s=%s\n", valueContainer.key, valueContainer.value)) + } + }, +} diff --git a/main/commands/all/engineering/subscriptionEntriesExtract.go b/main/commands/all/engineering/subscriptionEntriesExtract.go new file mode 100644 index 00000000000..ff64002270b --- /dev/null +++ b/main/commands/all/engineering/subscriptionEntriesExtract.go @@ -0,0 +1,70 @@ +package engineering + +import ( + "archive/zip" + "encoding/json" + "flag" + "fmt" + "io" + "os" + + "golang.org/x/crypto/sha3" + + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/main/commands/base" +) + +var cmdSubscriptionEntriesExtractInputName *string + +var cmdSubscriptionEntriesExtract = &base.Command{ + UsageLine: "{{.Exec}} engineering subscriptionEntriesExtract", + Flag: func() flag.FlagSet { + fs := flag.NewFlagSet("", flag.ExitOnError) + cmdSubscriptionEntriesExtractInputName = fs.String("input", "", "") + return *fs + }(), + Run: func(cmd *base.Command, args []string) { + cmd.Flag.Parse(args) + inputReader := os.Stdin + if *cmdSubscriptionEntriesExtractInputName != "" { + file, err := os.Open(*cmdSubscriptionEntriesExtractInputName) + if err != nil { + base.Fatalf("%s", err) + } + inputReader = file + defer file.Close() + } + content, err := io.ReadAll(inputReader) + if err != nil { + base.Fatalf("%s", err) + } + parsed, err := containers.TryAllParsers(content, "") + if err != nil { + base.Fatalf("%s", err) + } + zipWriter := zip.NewWriter(os.Stdout) + { + writer, err := zipWriter.Create("meta.json") + if err != nil { + base.Fatalf("%s", err) + } + err = json.NewEncoder(writer).Encode(parsed.Metadata) + if err != nil { + base.Fatalf("%s", err) + } + } + for k, entry := range parsed.ServerSpecs { + hash := sha3.Sum256(entry.Content) + fileName := fmt.Sprintf("entry_%v_%x", k, hash[:8]) + writer, err := zipWriter.Create(fileName) + if err != nil { + base.Fatalf("%s", err) + } + _, err = writer.Write(entry.Content) + if err != nil { + base.Fatalf("%s", err) + } + } + zipWriter.Close() + }, +} diff --git a/main/distro/all/all.go b/main/distro/all/all.go index 4475e4b0610..ccf4fed0014 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -112,4 +112,19 @@ import ( _ "github.com/v2fly/v2ray-core/v5/proxy/shadowsocks/simplified" _ "github.com/v2fly/v2ray-core/v5/proxy/socks/simplified" _ "github.com/v2fly/v2ray-core/v5/proxy/trojan/simplified" + + // Subscription Supports + _ "github.com/v2fly/v2ray-core/v5/app/subscription/subscriptionmanager" + + // Subscription Containers: general purpose + _ "github.com/v2fly/v2ray-core/v5/app/subscription/containers/base64urlline" + _ "github.com/v2fly/v2ray-core/v5/app/subscription/containers/jsonfieldarray" + _ "github.com/v2fly/v2ray-core/v5/app/subscription/containers/jsonfieldarray/jsonified" + + // Subscription Fetchers + _ "github.com/v2fly/v2ray-core/v5/app/subscription/documentfetcher/httpfetcher" + + // Subscription Entries Converters + _ "github.com/v2fly/v2ray-core/v5/app/subscription/entries/nonnative" + _ "github.com/v2fly/v2ray-core/v5/app/subscription/entries/outbound" // Natively Supported Outbound Format ) diff --git a/v2ray.go b/v2ray.go index 2d0397d91b4..0828df98502 100644 --- a/v2ray.go +++ b/v2ray.go @@ -142,6 +142,18 @@ func AddOutboundHandler(server *Instance, config *OutboundHandlerConfig) error { return nil } +func RemoveOutboundHandler(server *Instance, tag string) error { + outboundManager := server.GetFeature(outbound.ManagerType()).(outbound.Manager) + if err := outboundManager.RemoveHandler(server.ctx, tag); err != nil { + return err + } + + if err := server.env.DropProxyEnvironment("o" + tag); err != nil { + return err + } + return nil +} + func addOutboundHandlers(server *Instance, configs []*OutboundHandlerConfig) error { for _, outboundConfig := range configs { if err := AddOutboundHandler(server, outboundConfig); err != nil { From c9f16ea635beb76d916ba8fa0727825e0e5506ee Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Tue, 21 Nov 2023 23:04:06 +0000 Subject: [PATCH 2/6] Add subscription manager (autogenerated) --- app/subscription/config.pb.go | 284 +++++++++++++ .../base64urlline/errors.generated.go | 9 + .../containers/errors.generated.go | 9 + .../jsonfieldarray/errors.generated.go | 9 + .../jsonified/errors.generated.go | 9 + .../documentfetcher/errors.generated.go | 9 + .../httpfetcher/errors.generated.go | 9 + app/subscription/entries/errors.generated.go | 9 + .../entries/nonnative/errors.generated.go | 9 + .../entries/outbound/errors.generated.go | 9 + app/subscription/errors.generated.go | 9 + app/subscription/specs/abstract_spec.pb.go | 396 ++++++++++++++++++ app/subscription/specs/errors.generated.go | 9 + .../subscriptionmanager/errors.generated.go | 9 + app/tun/config.pb.go | 6 - 15 files changed, 788 insertions(+), 6 deletions(-) create mode 100644 app/subscription/config.pb.go create mode 100644 app/subscription/containers/base64urlline/errors.generated.go create mode 100644 app/subscription/containers/errors.generated.go create mode 100644 app/subscription/containers/jsonfieldarray/errors.generated.go create mode 100644 app/subscription/containers/jsonfieldarray/jsonified/errors.generated.go create mode 100644 app/subscription/documentfetcher/errors.generated.go create mode 100644 app/subscription/documentfetcher/httpfetcher/errors.generated.go create mode 100644 app/subscription/entries/errors.generated.go create mode 100644 app/subscription/entries/nonnative/errors.generated.go create mode 100644 app/subscription/entries/outbound/errors.generated.go create mode 100644 app/subscription/errors.generated.go create mode 100644 app/subscription/specs/abstract_spec.pb.go create mode 100644 app/subscription/specs/errors.generated.go create mode 100644 app/subscription/subscriptionmanager/errors.generated.go diff --git a/app/subscription/config.pb.go b/app/subscription/config.pb.go new file mode 100644 index 00000000000..a1dfff4fe0c --- /dev/null +++ b/app/subscription/config.pb.go @@ -0,0 +1,284 @@ +package subscription + +import ( + _ "github.com/v2fly/v2ray-core/v5/common/protoext" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ImportSource struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + 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"` + DefaultExpireSeconds uint64 `protobuf:"varint,5,opt,name=default_expire_seconds,json=defaultExpireSeconds,proto3" json:"default_expire_seconds,omitempty"` +} + +func (x *ImportSource) Reset() { + *x = ImportSource{} + if protoimpl.UnsafeEnabled { + mi := &file_app_subscription_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ImportSource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ImportSource) ProtoMessage() {} + +func (x *ImportSource) ProtoReflect() protoreflect.Message { + mi := &file_app_subscription_config_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ImportSource.ProtoReflect.Descriptor instead. +func (*ImportSource) Descriptor() ([]byte, []int) { + return file_app_subscription_config_proto_rawDescGZIP(), []int{0} +} + +func (x *ImportSource) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ImportSource) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *ImportSource) GetTagPrefix() string { + if x != nil { + return x.TagPrefix + } + return "" +} + +func (x *ImportSource) GetImportNetworkTag() string { + if x != nil { + return x.ImportNetworkTag + } + return "" +} + +func (x *ImportSource) GetDefaultExpireSeconds() uint64 { + if x != nil { + return x.DefaultExpireSeconds + } + return 0 +} + +// Config is the settings for Subscription Manager. +type Config struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Imports []*ImportSource `protobuf:"bytes,1,rep,name=imports,proto3" json:"imports,omitempty"` + NonnativeConverterOverlay []byte `protobuf:"bytes,2,opt,name=nonnative_converter_overlay,json=nonnativeConverterOverlay,proto3" json:"nonnative_converter_overlay,omitempty"` + NonnativeConverterOverlayFile string `protobuf:"bytes,96002,opt,name=nonnative_converter_overlay_file,json=nonnativeConverterOverlayFile,proto3" json:"nonnative_converter_overlay_file,omitempty"` +} + +func (x *Config) Reset() { + *x = Config{} + if protoimpl.UnsafeEnabled { + mi := &file_app_subscription_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Config) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Config) ProtoMessage() {} + +func (x *Config) ProtoReflect() protoreflect.Message { + mi := &file_app_subscription_config_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Config.ProtoReflect.Descriptor instead. +func (*Config) Descriptor() ([]byte, []int) { + return file_app_subscription_config_proto_rawDescGZIP(), []int{1} +} + +func (x *Config) GetImports() []*ImportSource { + if x != nil { + return x.Imports + } + return nil +} + +func (x *Config) GetNonnativeConverterOverlay() []byte { + if x != nil { + return x.NonnativeConverterOverlay + } + return nil +} + +func (x *Config) GetNonnativeConverterOverlayFile() string { + if x != nil { + return x.NonnativeConverterOverlayFile + } + return "" +} + +var File_app_subscription_config_proto protoreflect.FileDescriptor + +var file_app_subscription_config_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 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, + 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, 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, +} + +var ( + file_app_subscription_config_proto_rawDescOnce sync.Once + file_app_subscription_config_proto_rawDescData = file_app_subscription_config_proto_rawDesc +) + +func file_app_subscription_config_proto_rawDescGZIP() []byte { + file_app_subscription_config_proto_rawDescOnce.Do(func() { + file_app_subscription_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_subscription_config_proto_rawDescData) + }) + return file_app_subscription_config_proto_rawDescData +} + +var file_app_subscription_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_app_subscription_config_proto_goTypes = []interface{}{ + (*ImportSource)(nil), // 0: v2ray.core.app.subscription.ImportSource + (*Config)(nil), // 1: v2ray.core.app.subscription.Config +} +var file_app_subscription_config_proto_depIdxs = []int32{ + 0, // 0: v2ray.core.app.subscription.Config.imports:type_name -> v2ray.core.app.subscription.ImportSource + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_app_subscription_config_proto_init() } +func file_app_subscription_config_proto_init() { + if File_app_subscription_config_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_app_subscription_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ImportSource); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_subscription_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Config); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_app_subscription_config_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_app_subscription_config_proto_goTypes, + DependencyIndexes: file_app_subscription_config_proto_depIdxs, + MessageInfos: file_app_subscription_config_proto_msgTypes, + }.Build() + File_app_subscription_config_proto = out.File + file_app_subscription_config_proto_rawDesc = nil + file_app_subscription_config_proto_goTypes = nil + file_app_subscription_config_proto_depIdxs = nil +} diff --git a/app/subscription/containers/base64urlline/errors.generated.go b/app/subscription/containers/base64urlline/errors.generated.go new file mode 100644 index 00000000000..a8717d7d982 --- /dev/null +++ b/app/subscription/containers/base64urlline/errors.generated.go @@ -0,0 +1,9 @@ +package base64urlline + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/containers/errors.generated.go b/app/subscription/containers/errors.generated.go new file mode 100644 index 00000000000..3703c45303d --- /dev/null +++ b/app/subscription/containers/errors.generated.go @@ -0,0 +1,9 @@ +package containers + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/containers/jsonfieldarray/errors.generated.go b/app/subscription/containers/jsonfieldarray/errors.generated.go new file mode 100644 index 00000000000..8d568391b15 --- /dev/null +++ b/app/subscription/containers/jsonfieldarray/errors.generated.go @@ -0,0 +1,9 @@ +package jsonfieldarray + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/containers/jsonfieldarray/jsonified/errors.generated.go b/app/subscription/containers/jsonfieldarray/jsonified/errors.generated.go new file mode 100644 index 00000000000..63763d08fca --- /dev/null +++ b/app/subscription/containers/jsonfieldarray/jsonified/errors.generated.go @@ -0,0 +1,9 @@ +package jsonified + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/documentfetcher/errors.generated.go b/app/subscription/documentfetcher/errors.generated.go new file mode 100644 index 00000000000..b9194cfb895 --- /dev/null +++ b/app/subscription/documentfetcher/errors.generated.go @@ -0,0 +1,9 @@ +package documentfetcher + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/documentfetcher/httpfetcher/errors.generated.go b/app/subscription/documentfetcher/httpfetcher/errors.generated.go new file mode 100644 index 00000000000..4ba81a8aa75 --- /dev/null +++ b/app/subscription/documentfetcher/httpfetcher/errors.generated.go @@ -0,0 +1,9 @@ +package httpfetcher + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/entries/errors.generated.go b/app/subscription/entries/errors.generated.go new file mode 100644 index 00000000000..4ac96824286 --- /dev/null +++ b/app/subscription/entries/errors.generated.go @@ -0,0 +1,9 @@ +package entries + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/entries/nonnative/errors.generated.go b/app/subscription/entries/nonnative/errors.generated.go new file mode 100644 index 00000000000..0e7edbeebbc --- /dev/null +++ b/app/subscription/entries/nonnative/errors.generated.go @@ -0,0 +1,9 @@ +package nonnative + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/entries/outbound/errors.generated.go b/app/subscription/entries/outbound/errors.generated.go new file mode 100644 index 00000000000..44135e85927 --- /dev/null +++ b/app/subscription/entries/outbound/errors.generated.go @@ -0,0 +1,9 @@ +package outbound + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/errors.generated.go b/app/subscription/errors.generated.go new file mode 100644 index 00000000000..5a290ba76ce --- /dev/null +++ b/app/subscription/errors.generated.go @@ -0,0 +1,9 @@ +package subscription + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/specs/abstract_spec.pb.go b/app/subscription/specs/abstract_spec.pb.go new file mode 100644 index 00000000000..e4fddbb9783 --- /dev/null +++ b/app/subscription/specs/abstract_spec.pb.go @@ -0,0 +1,396 @@ +package specs + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ServerConfiguration struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Protocol string `protobuf:"bytes,1,opt,name=protocol,proto3" json:"protocol,omitempty"` + ProtocolSettings *anypb.Any `protobuf:"bytes,2,opt,name=protocol_settings,json=protocolSettings,proto3" json:"protocol_settings,omitempty"` + Transport string `protobuf:"bytes,3,opt,name=transport,proto3" json:"transport,omitempty"` + TransportSettings *anypb.Any `protobuf:"bytes,4,opt,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"` + Security string `protobuf:"bytes,5,opt,name=security,proto3" json:"security,omitempty"` + SecuritySettings *anypb.Any `protobuf:"bytes,6,opt,name=security_settings,json=securitySettings,proto3" json:"security_settings,omitempty"` +} + +func (x *ServerConfiguration) Reset() { + *x = ServerConfiguration{} + if protoimpl.UnsafeEnabled { + mi := &file_app_subscription_specs_abstract_spec_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ServerConfiguration) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerConfiguration) ProtoMessage() {} + +func (x *ServerConfiguration) ProtoReflect() protoreflect.Message { + mi := &file_app_subscription_specs_abstract_spec_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerConfiguration.ProtoReflect.Descriptor instead. +func (*ServerConfiguration) Descriptor() ([]byte, []int) { + return file_app_subscription_specs_abstract_spec_proto_rawDescGZIP(), []int{0} +} + +func (x *ServerConfiguration) GetProtocol() string { + if x != nil { + return x.Protocol + } + return "" +} + +func (x *ServerConfiguration) GetProtocolSettings() *anypb.Any { + if x != nil { + return x.ProtocolSettings + } + return nil +} + +func (x *ServerConfiguration) GetTransport() string { + if x != nil { + return x.Transport + } + return "" +} + +func (x *ServerConfiguration) GetTransportSettings() *anypb.Any { + if x != nil { + return x.TransportSettings + } + return nil +} + +func (x *ServerConfiguration) GetSecurity() string { + if x != nil { + return x.Security + } + return "" +} + +func (x *ServerConfiguration) GetSecuritySettings() *anypb.Any { + if x != nil { + return x.SecuritySettings + } + return nil +} + +type SubscriptionServerConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Metadata map[string]string `protobuf:"bytes,2,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Configuration *ServerConfiguration `protobuf:"bytes,3,opt,name=configuration,proto3" json:"configuration,omitempty"` +} + +func (x *SubscriptionServerConfig) Reset() { + *x = SubscriptionServerConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_app_subscription_specs_abstract_spec_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SubscriptionServerConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubscriptionServerConfig) ProtoMessage() {} + +func (x *SubscriptionServerConfig) ProtoReflect() protoreflect.Message { + mi := &file_app_subscription_specs_abstract_spec_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubscriptionServerConfig.ProtoReflect.Descriptor instead. +func (*SubscriptionServerConfig) Descriptor() ([]byte, []int) { + return file_app_subscription_specs_abstract_spec_proto_rawDescGZIP(), []int{1} +} + +func (x *SubscriptionServerConfig) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *SubscriptionServerConfig) GetMetadata() map[string]string { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *SubscriptionServerConfig) GetConfiguration() *ServerConfiguration { + if x != nil { + return x.Configuration + } + return nil +} + +type SubscriptionDocument struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata map[string]string `protobuf:"bytes,2,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Server []*SubscriptionServerConfig `protobuf:"bytes,3,rep,name=server,proto3" json:"server,omitempty"` +} + +func (x *SubscriptionDocument) Reset() { + *x = SubscriptionDocument{} + if protoimpl.UnsafeEnabled { + mi := &file_app_subscription_specs_abstract_spec_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SubscriptionDocument) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubscriptionDocument) ProtoMessage() {} + +func (x *SubscriptionDocument) ProtoReflect() protoreflect.Message { + mi := &file_app_subscription_specs_abstract_spec_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubscriptionDocument.ProtoReflect.Descriptor instead. +func (*SubscriptionDocument) Descriptor() ([]byte, []int) { + return file_app_subscription_specs_abstract_spec_proto_rawDescGZIP(), []int{2} +} + +func (x *SubscriptionDocument) GetMetadata() map[string]string { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *SubscriptionDocument) GetServer() []*SubscriptionServerConfig { + if x != nil { + return x.Server + } + return nil +} + +var File_app_subscription_specs_abstract_spec_proto protoreflect.FileDescriptor + +var file_app_subscription_specs_abstract_spec_proto_rawDesc = []byte{ + 0x0a, 0x2a, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x73, 0x2f, 0x61, 0x62, 0x73, 0x74, 0x72, 0x61, 0x63, + 0x74, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 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, 0x73, 0x70, 0x65, 0x63, 0x73, 0x1a, + 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x02, 0x0a, 0x13, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x41, + 0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, + 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, + 0x43, 0x0a, 0x12, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x12, 0x41, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x10, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x22, 0xac, 0x02, 0x0a, 0x18, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x65, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x49, 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, 0x73, 0x70, 0x65, 0x63, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x5c, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, + 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, 0x73, 0x70, 0x65, + 0x63, 0x73, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x8b, 0x02, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x61, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 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, 0x73, 0x70, 0x65, 0x63, + 0x73, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x53, + 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3b, + 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, 0x73, 0x70, 0x65, + 0x63, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x06, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x42, 0x84, 0x01, 0x0a, 0x25, 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, 0x73, 0x70, 0x65, 0x63, 0x73, 0x50, 0x01, 0x5a, 0x35, 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, 0x2f, 0x73, 0x70, + 0x65, 0x63, 0x73, 0xaa, 0x02, 0x21, 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, 0x2e, 0x53, 0x70, 0x65, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_app_subscription_specs_abstract_spec_proto_rawDescOnce sync.Once + file_app_subscription_specs_abstract_spec_proto_rawDescData = file_app_subscription_specs_abstract_spec_proto_rawDesc +) + +func file_app_subscription_specs_abstract_spec_proto_rawDescGZIP() []byte { + file_app_subscription_specs_abstract_spec_proto_rawDescOnce.Do(func() { + file_app_subscription_specs_abstract_spec_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_subscription_specs_abstract_spec_proto_rawDescData) + }) + return file_app_subscription_specs_abstract_spec_proto_rawDescData +} + +var file_app_subscription_specs_abstract_spec_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_app_subscription_specs_abstract_spec_proto_goTypes = []interface{}{ + (*ServerConfiguration)(nil), // 0: v2ray.core.app.subscription.specs.ServerConfiguration + (*SubscriptionServerConfig)(nil), // 1: v2ray.core.app.subscription.specs.SubscriptionServerConfig + (*SubscriptionDocument)(nil), // 2: v2ray.core.app.subscription.specs.SubscriptionDocument + nil, // 3: v2ray.core.app.subscription.specs.SubscriptionServerConfig.MetadataEntry + nil, // 4: v2ray.core.app.subscription.specs.SubscriptionDocument.MetadataEntry + (*anypb.Any)(nil), // 5: google.protobuf.Any +} +var file_app_subscription_specs_abstract_spec_proto_depIdxs = []int32{ + 5, // 0: v2ray.core.app.subscription.specs.ServerConfiguration.protocol_settings:type_name -> google.protobuf.Any + 5, // 1: v2ray.core.app.subscription.specs.ServerConfiguration.transport_settings:type_name -> google.protobuf.Any + 5, // 2: v2ray.core.app.subscription.specs.ServerConfiguration.security_settings:type_name -> google.protobuf.Any + 3, // 3: v2ray.core.app.subscription.specs.SubscriptionServerConfig.metadata:type_name -> v2ray.core.app.subscription.specs.SubscriptionServerConfig.MetadataEntry + 0, // 4: v2ray.core.app.subscription.specs.SubscriptionServerConfig.configuration:type_name -> v2ray.core.app.subscription.specs.ServerConfiguration + 4, // 5: v2ray.core.app.subscription.specs.SubscriptionDocument.metadata:type_name -> v2ray.core.app.subscription.specs.SubscriptionDocument.MetadataEntry + 1, // 6: v2ray.core.app.subscription.specs.SubscriptionDocument.server:type_name -> v2ray.core.app.subscription.specs.SubscriptionServerConfig + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_app_subscription_specs_abstract_spec_proto_init() } +func file_app_subscription_specs_abstract_spec_proto_init() { + if File_app_subscription_specs_abstract_spec_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_app_subscription_specs_abstract_spec_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ServerConfiguration); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_subscription_specs_abstract_spec_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SubscriptionServerConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_subscription_specs_abstract_spec_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SubscriptionDocument); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_app_subscription_specs_abstract_spec_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_app_subscription_specs_abstract_spec_proto_goTypes, + DependencyIndexes: file_app_subscription_specs_abstract_spec_proto_depIdxs, + MessageInfos: file_app_subscription_specs_abstract_spec_proto_msgTypes, + }.Build() + File_app_subscription_specs_abstract_spec_proto = out.File + file_app_subscription_specs_abstract_spec_proto_rawDesc = nil + file_app_subscription_specs_abstract_spec_proto_goTypes = nil + file_app_subscription_specs_abstract_spec_proto_depIdxs = nil +} diff --git a/app/subscription/specs/errors.generated.go b/app/subscription/specs/errors.generated.go new file mode 100644 index 00000000000..ccbfba52328 --- /dev/null +++ b/app/subscription/specs/errors.generated.go @@ -0,0 +1,9 @@ +package specs + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/subscriptionmanager/errors.generated.go b/app/subscription/subscriptionmanager/errors.generated.go new file mode 100644 index 00000000000..d5c3b8012bf --- /dev/null +++ b/app/subscription/subscriptionmanager/errors.generated.go @@ -0,0 +1,9 @@ +package subscriptionmanager + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/tun/config.pb.go b/app/tun/config.pb.go index 47f757f38aa..ddadd362939 100644 --- a/app/tun/config.pb.go +++ b/app/tun/config.pb.go @@ -1,9 +1,3 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.30.0 -// protoc v4.24.4 -// source: app/tun/config.proto - package tun import ( From 85d3e9bbd1a441d3e8a4c3155a5fc342dd0a9bf8 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Wed, 22 Nov 2023 00:20:35 +0000 Subject: [PATCH 3/6] enable restricted mode load for some settings --- proxy/shadowsocks/simplified/config.pb.go | 38 +++++++++---------- proxy/shadowsocks/simplified/config.proto | 1 + proxy/shadowsocks2022/config.pb.go | 23 +++++------ proxy/shadowsocks2022/config.proto | 1 + proxy/vmess/outbound/config.pb.go | 23 +++++------ proxy/vmess/outbound/config.proto | 1 + transport/internet/grpc/config.pb.go | 24 ++++++------ transport/internet/grpc/config.proto | 1 + transport/internet/httpupgrade/config.pb.go | 26 ++++++------- transport/internet/httpupgrade/config.proto | 1 + transport/internet/kcp/config.pb.go | 24 ++++++------ transport/internet/kcp/config.proto | 1 + .../request/stereotype/meek/config.pb.go | 33 ++++++++-------- .../request/stereotype/meek/config.proto | 2 + transport/internet/tcp/config.pb.go | 25 ++++++------ transport/internet/tcp/config.proto | 2 + transport/internet/tls/config.pb.go | 24 ++++++------ transport/internet/tls/config.proto | 1 + transport/internet/tls/utls/config.pb.go | 36 +++++++++--------- transport/internet/tls/utls/config.proto | 1 + transport/internet/websocket/config.pb.go | 27 ++++++------- transport/internet/websocket/config.proto | 1 + 22 files changed, 167 insertions(+), 149 deletions(-) diff --git a/proxy/shadowsocks/simplified/config.pb.go b/proxy/shadowsocks/simplified/config.pb.go index 1991d97f3c7..037b0e25f34 100644 --- a/proxy/shadowsocks/simplified/config.pb.go +++ b/proxy/shadowsocks/simplified/config.pb.go @@ -252,7 +252,7 @@ var file_proxy_shadowsocks_simplified_config_proto_rawDesc = []byte{ 0x79, 0x70, 0x65, 0x52, 0x0e, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x1a, 0x82, 0xb5, 0x18, 0x16, 0x0a, 0x07, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x0b, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x22, - 0xba, 0x02, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0xbe, 0x02, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, @@ -270,24 +270,24 @@ var file_proxy_shadowsocks_simplified_config_proto_rawDesc = []byte{ 0x65, 0x6e, 0x74, 0x72, 0x6f, 0x70, 0x79, 0x18, 0x91, 0xbf, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x64, 0x49, 0x76, 0x48, 0x65, 0x61, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x6f, 0x70, 0x79, 0x3a, - 0x1b, 0x82, 0xb5, 0x18, 0x17, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, - 0x0b, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x22, 0x53, 0x0a, 0x11, - 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, - 0x72, 0x12, 0x3e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x28, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x2e, - 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x42, 0x96, 0x01, 0x0a, 0x2b, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, - 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x2e, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x69, 0x66, 0x69, 0x65, - 0x64, 0x50, 0x01, 0x5a, 0x3b, 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, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, - 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x69, 0x66, 0x69, 0x65, 0x64, - 0xaa, 0x02, 0x27, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x2e, - 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x69, 0x66, 0x69, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x1f, 0x82, 0xb5, 0x18, 0x1b, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, + 0x0b, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x90, 0xff, 0x29, 0x01, + 0x22, 0x53, 0x0a, 0x11, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x57, 0x72, + 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x3e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x28, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, + 0x63, 0x6b, 0x73, 0x2e, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x96, 0x01, 0x0a, 0x2b, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, + 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, + 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x2e, 0x73, 0x69, 0x6d, 0x70, 0x6c, + 0x69, 0x66, 0x69, 0x65, 0x64, 0x50, 0x01, 0x5a, 0x3b, 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, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, + 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x69, + 0x66, 0x69, 0x65, 0x64, 0xaa, 0x02, 0x27, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, + 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, + 0x63, 0x6b, 0x73, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x69, 0x66, 0x69, 0x65, 0x64, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/shadowsocks/simplified/config.proto b/proxy/shadowsocks/simplified/config.proto index 936a8d610cd..7ea3187d1ed 100644 --- a/proxy/shadowsocks/simplified/config.proto +++ b/proxy/shadowsocks/simplified/config.proto @@ -25,6 +25,7 @@ message ServerConfig{ message ClientConfig { option (v2ray.core.common.protoext.message_opt).type = "outbound"; option (v2ray.core.common.protoext.message_opt).short_name = "shadowsocks"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; v2ray.core.common.net.IPOrDomain address = 1; uint32 port = 2; diff --git a/proxy/shadowsocks2022/config.pb.go b/proxy/shadowsocks2022/config.pb.go index fbf35b50188..b65953686c5 100644 --- a/proxy/shadowsocks2022/config.pb.go +++ b/proxy/shadowsocks2022/config.pb.go @@ -106,7 +106,7 @@ var file_proxy_shadowsocks2022_config_proto_rawDesc = []byte{ 0x65, 0x74, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0xbe, 0x01, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, + 0x74, 0x6f, 0x22, 0xc2, 0x01, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x70, 0x73, 0x6b, 0x12, 0x12, 0x0a, @@ -116,17 +116,18 @@ var file_proxy_shadowsocks2022_config_proto_rawDesc = []byte{ 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, - 0x72, 0x74, 0x3a, 0x1f, 0x82, 0xb5, 0x18, 0x1b, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, + 0x72, 0x74, 0x3a, 0x23, 0x82, 0xb5, 0x18, 0x1f, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x0f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, - 0x30, 0x32, 0x32, 0x42, 0x81, 0x01, 0x0a, 0x24, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, - 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x50, 0x01, 0x5a, 0x34, - 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, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, - 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x20, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, - 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, - 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x30, 0x32, 0x32, 0x90, 0xff, 0x29, 0x01, 0x42, 0x81, 0x01, 0x0a, 0x24, 0x63, 0x6f, 0x6d, 0x2e, + 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, + 0x50, 0x01, 0x5a, 0x34, 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, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, + 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x20, 0x56, 0x32, 0x52, 0x61, 0x79, + 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, + 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/shadowsocks2022/config.proto b/proxy/shadowsocks2022/config.proto index c8aebb4d60e..4f2c914bc8a 100644 --- a/proxy/shadowsocks2022/config.proto +++ b/proxy/shadowsocks2022/config.proto @@ -12,6 +12,7 @@ import "common/protoext/extensions.proto"; message ClientConfig { option (v2ray.core.common.protoext.message_opt).type = "outbound"; option (v2ray.core.common.protoext.message_opt).short_name = "shadowsocks2022"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; string method = 1; bytes psk = 2; diff --git a/proxy/vmess/outbound/config.pb.go b/proxy/vmess/outbound/config.pb.go index 1ac3ba66cdc..306a5253cb1 100644 --- a/proxy/vmess/outbound/config.pb.go +++ b/proxy/vmess/outbound/config.pb.go @@ -145,7 +145,7 @@ var file_proxy_vmess_outbound_config_proto_rawDesc = []byte{ 0x2a, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x08, 0x52, 0x65, 0x63, - 0x65, 0x69, 0x76, 0x65, 0x72, 0x22, 0x8e, 0x01, 0x0a, 0x10, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x69, + 0x65, 0x69, 0x76, 0x65, 0x72, 0x22, 0x92, 0x01, 0x0a, 0x10, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, @@ -153,16 +153,17 @@ var file_proxy_vmess_outbound_config_proto_rawDesc = []byte{ 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x3a, - 0x15, 0x82, 0xb5, 0x18, 0x11, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, - 0x05, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x42, 0x7e, 0x0a, 0x23, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, - 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, - 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x50, 0x01, 0x5a, - 0x33, 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, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2f, 0x6f, 0x75, 0x74, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0xaa, 0x02, 0x1f, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, - 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x56, 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x4f, 0x75, - 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x19, 0x82, 0xb5, 0x18, 0x15, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, + 0x05, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x90, 0xff, 0x29, 0x01, 0x42, 0x7e, 0x0a, 0x23, 0x63, 0x6f, + 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x50, 0x01, 0x5a, 0x33, 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, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2f, + 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0xaa, 0x02, 0x1f, 0x56, 0x32, 0x52, 0x61, 0x79, + 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x56, 0x6d, 0x65, 0x73, + 0x73, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/proxy/vmess/outbound/config.proto b/proxy/vmess/outbound/config.proto index e5e91322f85..7265956d87e 100644 --- a/proxy/vmess/outbound/config.proto +++ b/proxy/vmess/outbound/config.proto @@ -18,6 +18,7 @@ message Config { message SimplifiedConfig { option (v2ray.core.common.protoext.message_opt).type = "outbound"; option (v2ray.core.common.protoext.message_opt).short_name = "vmess"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; v2ray.core.common.net.IPOrDomain address = 1; uint32 port = 2; diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index 14035c9db7f..a82f3a1a779 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -80,22 +80,22 @@ var file_transport_internet_grpc_config_proto_rawDesc = []byte{ 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 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, 0x5d, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x61, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x3a, 0x1c, 0x82, 0xb5, 0x18, 0x18, 0x0a, 0x09, 0x74, 0x72, + 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x3a, 0x20, 0x82, 0xb5, 0x18, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x8a, 0xff, 0x29, - 0x03, 0x67, 0x75, 0x6e, 0x42, 0x85, 0x01, 0x0a, 0x26, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, - 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5a, - 0x36, 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, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0xaa, 0x02, 0x22, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, - 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x03, 0x67, 0x75, 0x6e, 0x90, 0xff, 0x29, 0x01, 0x42, 0x85, 0x01, 0x0a, 0x26, 0x63, 0x6f, 0x6d, + 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x5a, 0x36, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0xaa, 0x02, 0x22, 0x56, 0x32, + 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x47, 0x72, 0x70, 0x63, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/grpc/config.proto b/transport/internet/grpc/config.proto index 3e012f04451..049e0d64342 100644 --- a/transport/internet/grpc/config.proto +++ b/transport/internet/grpc/config.proto @@ -10,6 +10,7 @@ import "common/protoext/extensions.proto"; message Config { option (v2ray.core.common.protoext.message_opt).type = "transport"; option (v2ray.core.common.protoext.message_opt).short_name = "grpc"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; option (v2ray.core.common.protoext.message_opt).transport_original_name = "gun"; diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go index 6e9633e26a0..b6fba507fdc 100644 --- a/transport/internet/httpupgrade/config.pb.go +++ b/transport/internet/httpupgrade/config.pb.go @@ -81,22 +81,22 @@ var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ 0x75, 0x65, 0x73, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 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, 0x4e, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x6f, 0x22, 0x52, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x68, 0x6f, 0x73, 0x74, 0x3a, 0x1c, 0x82, 0xb5, 0x18, 0x18, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, + 0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x82, 0xb5, 0x18, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0b, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, - 0x64, 0x65, 0x42, 0x9c, 0x01, 0x0a, 0x2d, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, - 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x3d, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, - 0x67, 0x72, 0x61, 0x64, 0x65, 0xaa, 0x02, 0x29, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, - 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x65, 0x90, 0xff, 0x29, 0x01, 0x42, 0x9c, 0x01, 0x0a, 0x2d, 0x63, 0x6f, 0x6d, 0x2e, 0x76, + 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, + 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x3d, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, + 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0xaa, 0x02, 0x29, 0x56, 0x32, 0x52, 0x61, + 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x55, 0x70, + 0x67, 0x72, 0x61, 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/httpupgrade/config.proto b/transport/internet/httpupgrade/config.proto index 28ce2e085ff..90f242bef88 100644 --- a/transport/internet/httpupgrade/config.proto +++ b/transport/internet/httpupgrade/config.proto @@ -11,6 +11,7 @@ import "common/protoext/extensions.proto"; message Config { option (v2ray.core.common.protoext.message_opt).type = "transport"; option (v2ray.core.common.protoext.message_opt).short_name = "httpupgrade"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; string path = 1; string host = 2; diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index e9c171632b0..0fea1917710 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -539,7 +539,7 @@ var file_transport_internet_kcp_config_proto_rawDesc = []byte{ 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x24, 0x0a, 0x0e, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x73, 0x65, 0x65, 0x64, 0x22, 0xa3, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, + 0x09, 0x52, 0x04, 0x73, 0x65, 0x65, 0x64, 0x22, 0xa7, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x38, 0x0a, 0x03, 0x6d, 0x74, 0x75, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, @@ -579,18 +579,18 @@ var file_transport_internet_kcp_config_proto_rawDesc = []byte{ 0x32, 0x31, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x6b, 0x63, 0x70, 0x2e, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x65, 0x65, 0x64, 0x52, 0x04, 0x73, 0x65, 0x65, 0x64, 0x3a, 0x1c, 0x82, 0xb5, 0x18, 0x18, 0x0a, + 0x65, 0x65, 0x64, 0x52, 0x04, 0x73, 0x65, 0x65, 0x64, 0x3a, 0x20, 0x82, 0xb5, 0x18, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x03, 0x6b, 0x63, 0x70, 0x8a, - 0xff, 0x29, 0x04, 0x6d, 0x6b, 0x63, 0x70, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x42, 0x84, 0x01, - 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2e, 0x6b, 0x63, 0x70, 0x50, 0x01, 0x5a, 0x35, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x63, 0x70, - 0xaa, 0x02, 0x21, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x4b, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0xff, 0x29, 0x04, 0x6d, 0x6b, 0x63, 0x70, 0x90, 0xff, 0x29, 0x01, 0x4a, 0x04, 0x08, 0x09, 0x10, + 0x0a, 0x42, 0x84, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x6b, 0x63, 0x70, 0x50, 0x01, 0x5a, 0x35, 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, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2f, 0x6b, 0x63, 0x70, 0xaa, 0x02, 0x21, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, + 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x4b, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/kcp/config.proto b/transport/internet/kcp/config.proto index 5f4d2d07bfd..b7ac38d6d54 100644 --- a/transport/internet/kcp/config.proto +++ b/transport/internet/kcp/config.proto @@ -52,6 +52,7 @@ message EncryptionSeed { message Config { option (v2ray.core.common.protoext.message_opt).type = "transport"; option (v2ray.core.common.protoext.message_opt).short_name = "kcp"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; option (v2ray.core.common.protoext.message_opt).transport_original_name = "mkcp"; diff --git a/transport/internet/request/stereotype/meek/config.pb.go b/transport/internet/request/stereotype/meek/config.pb.go index 72a8a94f2d3..ce3d1531f3c 100644 --- a/transport/internet/request/stereotype/meek/config.pb.go +++ b/transport/internet/request/stereotype/meek/config.pb.go @@ -74,22 +74,23 @@ var file_transport_internet_request_stereotype_meek_config_proto_rawDesc = []byt 0x2e, 0x73, 0x74, 0x65, 0x72, 0x65, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, 0x65, 0x65, 0x6b, 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, 0x31, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, - 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x3a, 0x15, - 0x82, 0xb5, 0x18, 0x11, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, - 0x04, 0x6d, 0x65, 0x65, 0x6b, 0x42, 0xc0, 0x01, 0x0a, 0x39, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, - 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x65, 0x72, 0x65, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x6d, - 0x65, 0x65, 0x6b, 0x50, 0x01, 0x5a, 0x49, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x2f, 0x73, 0x74, 0x65, 0x72, 0x65, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x6d, 0x65, 0x65, 0x6b, - 0xaa, 0x02, 0x35, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x53, 0x74, 0x65, 0x72, 0x65, 0x6f, 0x74, - 0x79, 0x70, 0x65, 0x2e, 0x4d, 0x65, 0x65, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x22, 0x35, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, + 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x3a, 0x19, + 0x82, 0xb5, 0x18, 0x15, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, + 0x04, 0x6d, 0x65, 0x65, 0x6b, 0x90, 0xff, 0x29, 0x01, 0x42, 0xc0, 0x01, 0x0a, 0x39, 0x63, 0x6f, + 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x73, 0x74, 0x65, 0x72, 0x65, 0x6f, 0x74, 0x79, + 0x70, 0x65, 0x2e, 0x6d, 0x65, 0x65, 0x6b, 0x50, 0x01, 0x5a, 0x49, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x2f, 0x73, 0x74, 0x65, 0x72, 0x65, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2f, + 0x6d, 0x65, 0x65, 0x6b, 0xaa, 0x02, 0x35, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, + 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x53, 0x74, 0x65, + 0x72, 0x65, 0x6f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x4d, 0x65, 0x65, 0x6b, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/request/stereotype/meek/config.proto b/transport/internet/request/stereotype/meek/config.proto index 482bc28663f..26ca6c594b0 100644 --- a/transport/internet/request/stereotype/meek/config.proto +++ b/transport/internet/request/stereotype/meek/config.proto @@ -11,6 +11,8 @@ import "common/protoext/extensions.proto"; message Config{ option (v2ray.core.common.protoext.message_opt).type = "transport"; option (v2ray.core.common.protoext.message_opt).short_name = "meek"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; + string url = 1; } \ No newline at end of file diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index 5d3da899470..4d94a04d28c 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -82,7 +82,7 @@ var file_transport_internet_tcp_config_proto_rawDesc = []byte{ 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0x97, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9b, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3d, 0x0a, 0x0f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, @@ -90,17 +90,18 @@ var file_transport_internet_tcp_config_proto_rawDesc = []byte{ 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x3a, 0x14, 0x82, 0xb5, 0x18, 0x10, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x12, 0x03, 0x74, 0x63, 0x70, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, - 0x84, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, - 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x63, 0x70, 0x50, 0x01, 0x5a, 0x35, 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, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, - 0x63, 0x70, 0xaa, 0x02, 0x21, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x54, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x6c, 0x3a, 0x18, 0x82, 0xb5, 0x18, 0x14, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x12, 0x03, 0x74, 0x63, 0x70, 0x90, 0xff, 0x29, 0x01, 0x4a, 0x04, 0x08, + 0x01, 0x10, 0x02, 0x42, 0x84, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, + 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x63, 0x70, 0x50, 0x01, 0x5a, + 0x35, 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, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2f, 0x74, 0x63, 0x70, 0xaa, 0x02, 0x21, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, + 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x63, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/transport/internet/tcp/config.proto b/transport/internet/tcp/config.proto index 1ed0be39c53..3d05f1d64c3 100644 --- a/transport/internet/tcp/config.proto +++ b/transport/internet/tcp/config.proto @@ -12,6 +12,8 @@ import "common/protoext/extensions.proto"; message Config { option (v2ray.core.common.protoext.message_opt).type = "transport"; option (v2ray.core.common.protoext.message_opt).short_name = "tcp"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; + reserved 1; google.protobuf.Any header_settings = 2; diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 3c399854dc9..cd94057cc22 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -294,7 +294,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x12, 0x1b, 0x0a, 0x17, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x5f, 0x43, 0x4c, 0x49, - 0x45, 0x4e, 0x54, 0x10, 0x03, 0x22, 0xdc, 0x03, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x45, 0x4e, 0x54, 0x10, 0x03, 0x22, 0xe0, 0x03, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2d, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x42, 0x06, 0x82, 0xb5, 0x18, 0x02, 0x28, 0x01, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, @@ -323,17 +323,17 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x17, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x3a, - 0x13, 0x82, 0xb5, 0x18, 0x0f, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x03, 0x74, 0x6c, 0x73, 0x42, 0x84, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, - 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x50, 0x01, - 0x5a, 0x35, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x21, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, - 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x17, 0x82, 0xb5, 0x18, 0x13, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, + 0x03, 0x74, 0x6c, 0x73, 0x90, 0xff, 0x29, 0x01, 0x42, 0x84, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, + 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, + 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x35, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x21, 0x56, 0x32, + 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index 6d1b8bdd96f..07816697bc4 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -31,6 +31,7 @@ message Certificate { message Config { option (v2ray.core.common.protoext.message_opt).type = "security"; option (v2ray.core.common.protoext.message_opt).short_name = "tls"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; // Whether or not to allow self-signed certificates. bool allow_insecure = 1 [(v2ray.core.common.protoext.field_opt).forbidden = true]; diff --git a/transport/internet/tls/utls/config.pb.go b/transport/internet/tls/utls/config.pb.go index 057eeb7d8ad..31670fe12d9 100644 --- a/transport/internet/tls/utls/config.pb.go +++ b/transport/internet/tls/utls/config.pb.go @@ -148,7 +148,7 @@ var file_transport_internet_tls_utls_config_proto_rawDesc = []byte{ 0x65, 0x78, 0x74, 0x2f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0x2f, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xeb, 0x01, 0x0a, 0x06, 0x43, 0x6f, + 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xef, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x48, 0x0a, 0x0a, 0x74, 0x6c, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, @@ -162,23 +162,23 @@ var file_transport_internet_tls_utls_config_proto_rawDesc = []byte{ 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x2e, 0x75, 0x74, 0x6c, 0x73, 0x2e, 0x46, 0x6f, 0x72, 0x63, 0x65, 0x64, 0x41, 0x4c, 0x50, 0x4e, 0x52, 0x09, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x41, 0x6c, 0x70, - 0x6e, 0x3a, 0x14, 0x82, 0xb5, 0x18, 0x10, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, - 0x79, 0x12, 0x04, 0x75, 0x74, 0x6c, 0x73, 0x2a, 0x52, 0x0a, 0x0a, 0x46, 0x6f, 0x72, 0x63, 0x65, - 0x64, 0x41, 0x4c, 0x50, 0x4e, 0x12, 0x26, 0x0a, 0x22, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x50, 0x4f, - 0x52, 0x54, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x54, 0x41, - 0x4b, 0x45, 0x5f, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x10, 0x00, 0x12, 0x0b, 0x0a, - 0x07, 0x4e, 0x4f, 0x5f, 0x41, 0x4c, 0x50, 0x4e, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x54, - 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x54, 0x10, 0x02, 0x42, 0x93, 0x01, 0x0a, 0x2a, - 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x2e, 0x75, 0x74, 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x3a, 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, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, - 0x74, 0x6c, 0x73, 0x2f, 0x75, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x26, 0x56, 0x32, 0x52, 0x61, 0x79, - 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x2e, 0x55, 0x54, 0x6c, - 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x3a, 0x18, 0x82, 0xb5, 0x18, 0x14, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, + 0x79, 0x12, 0x04, 0x75, 0x74, 0x6c, 0x73, 0x90, 0xff, 0x29, 0x01, 0x2a, 0x52, 0x0a, 0x0a, 0x46, + 0x6f, 0x72, 0x63, 0x65, 0x64, 0x41, 0x4c, 0x50, 0x4e, 0x12, 0x26, 0x0a, 0x22, 0x54, 0x52, 0x41, + 0x4e, 0x53, 0x50, 0x4f, 0x52, 0x54, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x45, 0x52, 0x45, 0x4e, 0x43, + 0x45, 0x5f, 0x54, 0x41, 0x4b, 0x45, 0x5f, 0x50, 0x52, 0x49, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x10, + 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x4f, 0x5f, 0x41, 0x4c, 0x50, 0x4e, 0x10, 0x01, 0x12, 0x0f, + 0x0a, 0x0b, 0x55, 0x54, 0x4c, 0x53, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x54, 0x10, 0x02, 0x42, + 0x93, 0x01, 0x0a, 0x2a, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, + 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x2e, 0x75, 0x74, 0x6c, 0x73, 0x50, 0x01, + 0x5a, 0x3a, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0x2f, 0x75, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x26, 0x56, + 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, + 0x2e, 0x55, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/utls/config.proto b/transport/internet/tls/utls/config.proto index 0b5702f677a..7b17952f360 100644 --- a/transport/internet/tls/utls/config.proto +++ b/transport/internet/tls/utls/config.proto @@ -18,6 +18,7 @@ enum ForcedALPN{ message Config { option (v2ray.core.common.protoext.message_opt).type = "security"; option (v2ray.core.common.protoext.message_opt).short_name = "utls"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; v2ray.core.transport.internet.tls.Config tls_config = 1; string imitate = 2; diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index ff62bc2fa2d..5d552eb400c 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -171,7 +171,7 @@ var file_transport_internet_websocket_config_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x30, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xd2, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xd6, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x47, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, @@ -190,19 +190,20 @@ var file_transport_internet_websocket_config_proto_rawDesc = []byte{ 0x12, 0x33, 0x0a, 0x16, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x44, 0x61, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3a, 0x20, 0x82, 0xb5, 0x18, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x61, + 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x3a, 0x24, 0x82, 0xb5, 0x18, 0x20, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x02, 0x77, 0x73, 0x8a, 0xff, 0x29, 0x09, 0x77, 0x65, - 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x96, 0x01, - 0x0a, 0x2b, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x50, 0x01, 0x5a, - 0x3b, 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, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0xaa, 0x02, 0x27, 0x56, - 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x57, 0x65, 0x62, - 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x90, 0xff, 0x29, 0x01, 0x4a, 0x04, 0x08, 0x01, 0x10, + 0x02, 0x42, 0x96, 0x01, 0x0a, 0x2b, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x32, 0x72, 0x61, 0x79, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, + 0x74, 0x50, 0x01, 0x5a, 0x3b, 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, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, + 0xaa, 0x02, 0x27, 0x56, 0x32, 0x52, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/transport/internet/websocket/config.proto b/transport/internet/websocket/config.proto index 939a0355138..502abb8ceb2 100644 --- a/transport/internet/websocket/config.proto +++ b/transport/internet/websocket/config.proto @@ -16,6 +16,7 @@ message Header { message Config { option (v2ray.core.common.protoext.message_opt).type = "transport"; option (v2ray.core.common.protoext.message_opt).short_name = "ws"; + option (v2ray.core.common.protoext.message_opt).allow_restricted_mode_load = true; option (v2ray.core.common.protoext.message_opt).transport_original_name = "websocket"; From cafc2f3a9f8092ba19a0283b44f197de4ed95118 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sat, 25 Nov 2023 15:44:31 +0000 Subject: [PATCH 4/6] 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 a1dfff4fe0c..14e66cb7528 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 71dd51a1e45..e622ce4c941 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 00000000000..8acf7afb2a2 --- /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 6da0b65c925..03edd2ad470 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 86013e79eda..d6cd2f74b81 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) From 60eace27dfca13a9210a2b642e47013242b95b4e Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sat, 25 Nov 2023 16:53:05 +0000 Subject: [PATCH 5/6] Add data URL Link support to subscription --- .../containers/dataurlsingle/dataurl.go | 44 +++++++++++++++++++ .../dataurlsingle/errors.generated.go | 9 ++++ .../documentfetcher/dataurlfetcher/dataurl.go | 16 ++++++- .../dataurlfetcher/errors.generated.go | 9 ++++ .../subscriptionmanager/subdocupdater.go | 7 ++- go.mod | 1 + go.sum | 2 + .../commands/all/engineering/encodedataurl.go | 32 ++++++++++++++ main/commands/all/engineering/engineering.go | 1 + main/distro/all/all.go | 2 + 10 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 app/subscription/containers/dataurlsingle/dataurl.go create mode 100644 app/subscription/containers/dataurlsingle/errors.generated.go create mode 100644 app/subscription/documentfetcher/dataurlfetcher/errors.generated.go create mode 100644 main/commands/all/engineering/encodedataurl.go diff --git a/app/subscription/containers/dataurlsingle/dataurl.go b/app/subscription/containers/dataurlsingle/dataurl.go new file mode 100644 index 00000000000..6e289b6e26e --- /dev/null +++ b/app/subscription/containers/dataurlsingle/dataurl.go @@ -0,0 +1,44 @@ +package dataurlsingle + +import ( + "bytes" + "strings" + + "github.com/vincent-petithory/dataurl" + + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/common" +) + +//go:generate go run github.com/v2fly/v2ray-core/v5/common/errors/errorgen + +func newSingularDataURLParser() containers.SubscriptionContainerDocumentParser { + return &parser{} +} + +type parser struct{} + +func (p parser) ParseSubscriptionContainerDocument(rawConfig []byte) (*containers.Container, error) { + dataURL, err := dataurl.Decode(bytes.NewReader(rawConfig)) + 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-singular") { + return nil, newError("unsupported media subtype: ", dataURL.MediaType.Subtype) + } + result := &containers.Container{} + result.Kind = "DataURLSingle" + result.Metadata = make(map[string]string) + result.ServerSpecs = append(result.ServerSpecs, containers.UnparsedServerConf{ + KindHint: "", + Content: dataURL.Data, + }) + return result, nil +} + +func init() { + common.Must(containers.RegisterParser("DataURLSingle", newSingularDataURLParser())) +} diff --git a/app/subscription/containers/dataurlsingle/errors.generated.go b/app/subscription/containers/dataurlsingle/errors.generated.go new file mode 100644 index 00000000000..4db46411c70 --- /dev/null +++ b/app/subscription/containers/dataurlsingle/errors.generated.go @@ -0,0 +1,9 @@ +package dataurlsingle + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/documentfetcher/dataurlfetcher/dataurl.go b/app/subscription/documentfetcher/dataurlfetcher/dataurl.go index 8acf7afb2a2..6f6ebb4bd6e 100644 --- a/app/subscription/documentfetcher/dataurlfetcher/dataurl.go +++ b/app/subscription/documentfetcher/dataurlfetcher/dataurl.go @@ -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 } diff --git a/app/subscription/documentfetcher/dataurlfetcher/errors.generated.go b/app/subscription/documentfetcher/dataurlfetcher/errors.generated.go new file mode 100644 index 00000000000..0dc4c9e4560 --- /dev/null +++ b/app/subscription/documentfetcher/dataurlfetcher/errors.generated.go @@ -0,0 +1,9 @@ +package dataurlfetcher + +import "github.com/v2fly/v2ray-core/v5/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/subscription/subscriptionmanager/subdocupdater.go b/app/subscription/subscriptionmanager/subdocupdater.go index d6cd2f74b81..19b798b5824 100644 --- a/app/subscription/subscriptionmanager/subdocupdater.go +++ b/app/subscription/subscriptionmanager/subdocupdater.go @@ -21,11 +21,16 @@ func (s *SubscriptionManagerImpl) updateSubscription(subscriptionName string) er trackedSub = trackedSubFound } importSource := trackedSub.importSource - docFetcher, err := documentfetcher.GetFetcher("http") if err != nil { return newError("failed to get fetcher: ", err) } + if strings.HasPrefix(importSource.Url, "data:") { + docFetcher, err = documentfetcher.GetFetcher("dataurl") + if err != nil { + return newError("failed to get fetcher: ", err) + } + } downloadedDocument, err := docFetcher.DownloadDocument(s.ctx, importSource) if err != nil { diff --git a/go.mod b/go.mod index a9da1119b6a..63c73082db7 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/v2fly/BrowserBridge v0.0.0-20210430233438-0570fc1d7d08 github.com/v2fly/VSign v0.0.0-20201108000810-e2adc24bf848 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e + github.com/vincent-petithory/dataurl v1.0.0 github.com/xiaokangwang/VLite v0.0.0-20220418190619-cff95160a432 go.starlark.net v0.0.0-20230612165344-9532f5667272 go4.org/netipx v0.0.0-20230303233057-f1b76eb4bb35 diff --git a/go.sum b/go.sum index 529c94982e1..c5598ab512c 100644 --- a/go.sum +++ b/go.sum @@ -325,6 +325,8 @@ github.com/v2fly/VSign v0.0.0-20201108000810-e2adc24bf848 h1:p1UzXK6VAutXFFQMnre github.com/v2fly/VSign v0.0.0-20201108000810-e2adc24bf848/go.mod h1:p80Bv154ZtrGpXMN15slDCqc9UGmfBuUzheDFBYaW/M= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= +github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI= +github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xiaokangwang/VLite v0.0.0-20220418190619-cff95160a432 h1:I/ATawgO2RerCq9ACwL0wBB8xNXZdE3J+93MCEHReRs= github.com/xiaokangwang/VLite v0.0.0-20220418190619-cff95160a432/go.mod h1:QN7Go2ftTVfx0aCTh9RXHV8pkpi0FtmbwQw40dy61wQ= diff --git a/main/commands/all/engineering/encodedataurl.go b/main/commands/all/engineering/encodedataurl.go new file mode 100644 index 00000000000..af8e76a64db --- /dev/null +++ b/main/commands/all/engineering/encodedataurl.go @@ -0,0 +1,32 @@ +package engineering + +import ( + "flag" + "io" + "os" + + "github.com/vincent-petithory/dataurl" + + "github.com/v2fly/v2ray-core/v5/main/commands/base" +) + +var cmdEncodeDataURLContentType *string + +var cmdEncodeDataURL = &base.Command{ + UsageLine: "{{.Exec}} engineering encodeDataURL", + Flag: func() flag.FlagSet { + fs := flag.NewFlagSet("", flag.ExitOnError) + cmdEncodeDataURLContentType = fs.String("type", "application/vnd.v2ray.subscription-singular", "") + return *fs + }(), + Run: func(cmd *base.Command, args []string) { + cmd.Flag.Parse(args) + + content, err := io.ReadAll(os.Stdin) + if err != nil { + base.Fatalf("%s", err) + } + dataURL := dataurl.New(content, *cmdEncodeDataURLContentType) + dataURL.WriteTo(os.Stdout) + }, +} diff --git a/main/commands/all/engineering/engineering.go b/main/commands/all/engineering/engineering.go index fb31d8349df..d7b62d707bf 100644 --- a/main/commands/all/engineering/engineering.go +++ b/main/commands/all/engineering/engineering.go @@ -12,6 +12,7 @@ var cmdEngineering = &base.Command{ cmdNonNativeLinkExtract, cmdNonNativeLinkExec, cmdSubscriptionEntriesExtract, + cmdEncodeDataURL, }, } diff --git a/main/distro/all/all.go b/main/distro/all/all.go index ccf4fed0014..200f1228304 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -118,10 +118,12 @@ import ( // Subscription Containers: general purpose _ "github.com/v2fly/v2ray-core/v5/app/subscription/containers/base64urlline" + _ "github.com/v2fly/v2ray-core/v5/app/subscription/containers/dataurlsingle" _ "github.com/v2fly/v2ray-core/v5/app/subscription/containers/jsonfieldarray" _ "github.com/v2fly/v2ray-core/v5/app/subscription/containers/jsonfieldarray/jsonified" // Subscription Fetchers + _ "github.com/v2fly/v2ray-core/v5/app/subscription/documentfetcher/dataurlfetcher" _ "github.com/v2fly/v2ray-core/v5/app/subscription/documentfetcher/httpfetcher" // Subscription Entries Converters From b34944d45c2c46fe23ab2fc78e75048681f78ee7 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sat, 25 Nov 2023 17:08:28 +0000 Subject: [PATCH 6/6] fixed processing none security subscription --- app/subscription/specs/outbound_parser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/subscription/specs/outbound_parser.go b/app/subscription/specs/outbound_parser.go index b309efd11cc..27211757803 100644 --- a/app/subscription/specs/outbound_parser.go +++ b/app/subscription/specs/outbound_parser.go @@ -55,7 +55,7 @@ func (p *OutboundParser) toAbstractServerSpec(config *OutboundConfig) (*ServerCo } serverConfig.TransportSettings = serial.ToTypedMessage(transportSettings) } - { + if config.StreamSetting.Security != "none" { securitySettings, err := loadHeterogeneousConfigFromRawJSONRestricted( "security", config.StreamSetting.Security, config.StreamSetting.SecuritySettings) if err != nil { @@ -72,7 +72,7 @@ func (p *OutboundParser) toAbstractServerSpec(config *OutboundConfig) (*ServerCo func (p *OutboundParser) ToSubscriptionServerConfig(config *OutboundConfig) (*SubscriptionServerConfig, error) { serverSpec, err := p.toAbstractServerSpec(config) if err != nil { - return nil, newError("unable to parse server specification") + return nil, newError("unable to parse server specification").Base(err) } return &SubscriptionServerConfig{ Configuration: serverSpec,