diff --git a/app/observatory/command/command.go b/app/observatory/command/command.go index 1c3245343..824f8320f 100644 --- a/app/observatory/command/command.go +++ b/app/observatory/command/command.go @@ -3,8 +3,12 @@ package command +//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen + import ( "context" + "github.com/golang/protobuf/proto" + "github.com/v2fly/v2ray-core/v4/features" "google.golang.org/grpc" @@ -22,11 +26,21 @@ type service struct { } func (s *service) GetOutboundStatus(ctx context.Context, request *GetOutboundStatusRequest) (*GetOutboundStatusResponse, error) { - resp, err := s.observatory.GetObservation(ctx) - if err != nil { - return nil, err + var result proto.Message + if request.Tag == "" { + observeResult, err := s.observatory.GetObservation(ctx) + if err != nil { + newError("cannot get observation").Base(err) + } + result = observeResult + } else { + observeResult, err := common.Must2(s.observatory.(features.TaggedFeatures).GetFeaturesByTag(request.Tag)).(extension.Observatory).GetObservation(s.ctx) + if err != nil { + newError("cannot get observation").Base(err) + } + result = observeResult } - retdata := resp.(*observatory.ObservationResult) + retdata := result.(*observatory.ObservationResult) return &GetOutboundStatusResponse{ Status: retdata, }, nil