Skip to content

Commit

Permalink
Observatory related fixes (v2ray#788)
Browse files Browse the repository at this point in the history
* fix:observatory not supported by multi-json

* Fix: observatory starts with empty config & fails to close (v2ray#957)

* Update strategy_leastping.go (v2ray#1019)

* add custom probe URL support for observatory

* add custom probe interval for observer

* apply coding style

* Fix: observatory log & JSON config(v2ray#1211)

Co-authored-by: ihotte <[email protected]>

* Change default probe url from api.v2fly.org to www.google.com

* Cherry-pick missing code from branch 'dev-advloadblancer-2'

Co-authored-by: Shelikhoo <[email protected]>
Co-authored-by: Loyalsoldier <[email protected]>
Co-authored-by: fanyiguan <[email protected]>
Co-authored-by: ihotte <[email protected]>
Co-authored-by: ihotte <[email protected]>
  • Loading branch information
6 people committed Oct 26, 2021
1 parent 7038bde commit abb8ba8
Show file tree
Hide file tree
Showing 20 changed files with 601 additions and 22 deletions.
50 changes: 50 additions & 0 deletions app/observatory/command/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// +build !confonly

package command

import (
"context"

"google.golang.org/grpc"

core "github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/app/observatory"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/features/extension"
)

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)
sv := &service{v: s}
err := s.RequireFeatures(func(Observatory extension.Observatory) {
sv.observatory = Observatory
})
if err != nil {
return nil, err
}
return sv, nil
}))
}
278 changes: 278 additions & 0 deletions app/observatory/command/command.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions app/observatory/command/command.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";

package xray.core.app.observatory.command;
option csharp_namespace = "Xray.Core.App.Observatory.Command";
option go_package = "github.com/xtls/xray-core/app/observatory/command";
option java_package = "com.xray.core.app.observatory.command";
option java_multiple_files = true;

import "app/observatory/config.proto";

message GetOutboundStatusRequest {
}

message GetOutboundStatusResponse {
xray.core.app.observatory.ObservationResult status = 1;
}

service ObservatoryService {
rpc GetOutboundStatus(GetOutboundStatusRequest)
returns (GetOutboundStatusResponse) {}
}


message Config {}
Loading

0 comments on commit abb8ba8

Please sign in to comment.