mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 07:26:24 -05:00
Add observatory grpc call
This commit is contained in:
parent
3a705cec5a
commit
a168ff3df6
39
app/observatory/command/command.go
Normal file
39
app/observatory/command/command.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package command
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
core "github.com/v2fly/v2ray-core/v4"
|
||||||
|
"github.com/v2fly/v2ray-core/v4/app/observatory"
|
||||||
|
"github.com/v2fly/v2ray-core/v4/common"
|
||||||
|
"github.com/v2fly/v2ray-core/v4/features/extension"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type service struct {
|
||||||
|
UnimplementedObservatoryServiceServer
|
||||||
|
v *core.Instance
|
||||||
|
|
||||||
|
Observatory extension.Observatory
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *service) GetOutboundStatus(ctx context.Context, request *GetOutboundStatusRequest) (*GetOutboundStatusResponse, error) {
|
||||||
|
resp, err := s.Observatory.GetObservation(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
retdata := resp.(*observatory.ObservationResult)
|
||||||
|
return &GetOutboundStatusResponse{
|
||||||
|
Status: retdata,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *service) Register(server *grpc.Server) {
|
||||||
|
RegisterObservatoryServiceServer(server, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, cfg interface{}) (interface{}, error) {
|
||||||
|
s := core.MustFromContext(ctx)
|
||||||
|
return &service{v: s}, nil
|
||||||
|
}))
|
||||||
|
}
|
@ -14,6 +14,9 @@ import (
|
|||||||
_ "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
|
_ "github.com/v2fly/v2ray-core/v4/app/proxyman/command"
|
||||||
_ "github.com/v2fly/v2ray-core/v4/app/stats/command"
|
_ "github.com/v2fly/v2ray-core/v4/app/stats/command"
|
||||||
|
|
||||||
|
// Developer preview services
|
||||||
|
_ "github.com/v2fly/v2ray-core/v4/app/observatory/command"
|
||||||
|
|
||||||
// Other optional features.
|
// Other optional features.
|
||||||
_ "github.com/v2fly/v2ray-core/v4/app/dns"
|
_ "github.com/v2fly/v2ray-core/v4/app/dns"
|
||||||
_ "github.com/v2fly/v2ray-core/v4/app/dns/fakedns"
|
_ "github.com/v2fly/v2ray-core/v4/app/dns/fakedns"
|
||||||
|
Loading…
Reference in New Issue
Block a user