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:
parent
44a11b5352
commit
89a82ece8b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user