1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-11-23 12:02:58 -05:00

decouple commander interface from grpc

This commit is contained in:
Darien Raymond
2018-02-08 23:24:35 +01:00
parent 495ae1c5e3
commit d9040b571d
6 changed files with 66 additions and 56 deletions

View File

@@ -125,14 +125,16 @@ func (s *handlerServer) AlterOutbound(ctx context.Context, request *AlterOutboun
return &AlterOutboundResponse{}, operation.ApplyOutbound(ctx, handler)
}
type feature struct{}
func (*feature) Start() error {
return nil
type service struct {
v *core.Instance
}
func (*feature) Close() error {
return nil
func (s *service) Register(server *grpc.Server) {
RegisterHandlerServiceServer(server, &handlerServer{
s: s.v,
ihm: s.v.InboundHandlerManager(),
ohm: s.v.OutboundHandlerManager(),
})
}
func init() {
@@ -141,13 +143,6 @@ func init() {
if s == nil {
return nil, newError("V is not in context.")
}
s.Commander().RegisterService(func(server *grpc.Server) {
RegisterHandlerServiceServer(server, &handlerServer{
s: s,
ihm: s.InboundHandlerManager(),
ohm: s.OutboundHandlerManager(),
})
})
return &feature{}, nil
return &service{v: s}, nil
}))
}