1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

add support for tagged observer

This commit is contained in:
Shelikhoo 2021-06-19 11:21:35 +01:00
parent 44a11b5352
commit 89a82ece8b
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -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