diff --git a/app/observatory/observer.go b/app/observatory/observer.go index e578be1c7..60b35d715 100644 --- a/app/observatory/observer.go +++ b/app/observatory/observer.go @@ -1,3 +1,5 @@ +// +build !confonly + package observatory import ( diff --git a/go.sum b/go.sum index 3e676dd3b..ad14004eb 100644 --- a/go.sum +++ b/go.sum @@ -325,6 +325,7 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12 h1:OwhZOOMuf7leLaSCuxtQ9FW7ui2L2L6UKOtKAUqovUQ= google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= diff --git a/infra/conf/services.go b/infra/conf/services.go index bbeba19d2..bbc2e1903 100644 --- a/infra/conf/services.go +++ b/infra/conf/services.go @@ -1,7 +1,6 @@ package conf import ( - "bytes" "encoding/json" "github.com/golang/protobuf/jsonpb" "github.com/jhump/protoreflect/desc" @@ -13,13 +12,13 @@ func (c *Config) BuildServices(service map[string]*json.RawMessage) ([]*serial.T var ret []*serial.TypedMessage for k, v := range service { message, err := desc.LoadMessageDescriptor(k) - if err != nil { + if err != nil || message == nil { return nil, newError("Cannot find service", k, "").Base(err) } serviceConfig := dynamic.NewMessage(message) - if err := jsonpb.Unmarshal(bytes.NewReader(*v), serviceConfig); err != nil { + if err := serviceConfig.UnmarshalJSONPB(&jsonpb.Unmarshaler{AllowUnknownFields: false}, *v); err != nil { return nil, newError("Cannot interpret service configure file", k, "").Base(err) } diff --git a/infra/conf/v2ray.go b/infra/conf/v2ray.go index 6d6c4259d..0843bc418 100644 --- a/infra/conf/v2ray.go +++ b/infra/conf/v2ray.go @@ -2,6 +2,8 @@ package conf import ( "encoding/json" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" "log" "os" "strings" @@ -575,7 +577,18 @@ func (c *Config) Build() (*core.Config, error) { developererr := newError("Loading a V2Ray Features as a service is intended for developers only. " + "This is used for developers to prototype new features or for an advanced client to use special features in V2Ray," + " instead of allowing end user to enable it without special tool and knowledge.") - return nil, newError("Cannot load service").Base(developererr).Base(err) + sb := strings.Builder{} + protoregistry.GlobalTypes.RangeMessages(func(messageType protoreflect.MessageType) bool { + switch d := messageType.Descriptor().(type) { + case protoreflect.MessageDescriptor: + sb.WriteString(string(d.Name())) + sb.WriteString(":") + sb.WriteString(string(d.FullName())) + sb.WriteString("\n") + } + return true + }) + return nil, newError("Cannot load service").Base(developererr).Base(err).Base(newError(sb.String())) } else { config.App = append(config.App, msg...) } diff --git a/main/distro/all/all.go b/main/distro/all/all.go index 8e1528404..3417b55f9 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -26,6 +26,9 @@ import ( // Fix dependency cycle caused by core import in internet package _ "github.com/v2fly/v2ray-core/v4/transport/internet/tagged/taggedimpl" + // Developer preview features + _ "github.com/v2fly/v2ray-core/v4/app/observatory" + // Inbound and outbound proxies. _ "github.com/v2fly/v2ray-core/v4/proxy/blackhole" _ "github.com/v2fly/v2ray-core/v4/proxy/dns"