diff --git a/app/proxyman/command/command.go b/app/proxyman/command/command.go index 227a95c3..a86f0921 100644 --- a/app/proxyman/command/command.go +++ b/app/proxyman/command/command.go @@ -103,13 +103,22 @@ func (s *handlerServer) AlterInbound(ctx context.Context, request *AlterInboundR func (s *handlerServer) ListInbounds(ctx context.Context, request *ListInboundsRequest) (*ListInboundsResponse, error) { handlers := s.ihm.ListHandlers(ctx) response := &ListInboundsResponse{} - for _, handler := range handlers { - response.Inbounds = append(response.Inbounds, &core.InboundHandlerConfig{ - Tag: handler.Tag(), - ReceiverSettings: handler.ReceiverSettings(), - ProxySettings: handler.ProxySettings(), - }) + if request.GetIsOnlyTags() { + for _, handler := range handlers { + response.Inbounds = append(response.Inbounds, &core.InboundHandlerConfig{ + Tag: handler.Tag(), + }) + } + } else { + for _, handler := range handlers { + response.Inbounds = append(response.Inbounds, &core.InboundHandlerConfig{ + Tag: handler.Tag(), + ReceiverSettings: handler.ReceiverSettings(), + ProxySettings: handler.ProxySettings(), + }) + } } + return response, nil } diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index f4219d91..6c127960 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -368,6 +368,8 @@ type ListInboundsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + IsOnlyTags bool `protobuf:"varint,1,opt,name=isOnlyTags,proto3" json:"isOnlyTags,omitempty"` } func (x *ListInboundsRequest) Reset() { @@ -400,6 +402,13 @@ func (*ListInboundsRequest) Descriptor() ([]byte, []int) { return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} } +func (x *ListInboundsRequest) GetIsOnlyTags() bool { + if x != nil { + return x.IsOnlyTags + } + return false +} + type ListInboundsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -993,9 +1002,11 @@ var file_app_proxyman_command_command_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x16, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, 0x0a, 0x13, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0x53, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x61, 0x67, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x54, + 0x61, 0x67, 0x73, 0x22, 0x53, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, diff --git a/app/proxyman/command/command.proto b/app/proxyman/command/command.proto index 4ff499eb..71f8f0dc 100644 --- a/app/proxyman/command/command.proto +++ b/app/proxyman/command/command.proto @@ -37,7 +37,9 @@ message AlterInboundRequest { message AlterInboundResponse {} -message ListInboundsRequest {} +message ListInboundsRequest { + bool isOnlyTags = 1; +} message ListInboundsResponse { repeated core.InboundHandlerConfig inbounds = 1; diff --git a/main/commands/all/api/inbounds_list.go b/main/commands/all/api/inbounds_list.go index e4267a6b..6060074c 100644 --- a/main/commands/all/api/inbounds_list.go +++ b/main/commands/all/api/inbounds_list.go @@ -7,7 +7,7 @@ import ( var cmdListInbounds = &base.Command{ CustomFlags: true, - UsageLine: "{{.Exec}} api lsi [--server=127.0.0.1:8080]", + UsageLine: "{{.Exec}} api lsi [--server=127.0.0.1:8080] [--isOnlyTags=true]", Short: "List inbounds", Long: ` List inbounds in Xray. @@ -29,14 +29,17 @@ Example: func executeListInbounds(cmd *base.Command, args []string) { setSharedFlags(cmd) + var isOnlyTagsStr string + cmd.Flag.StringVar(&isOnlyTagsStr, "isOnlyTags", "", "") cmd.Flag.Parse(args) + isOnlyTags := isOnlyTagsStr == "true" conn, ctx, close := dialAPIServer() defer close() client := handlerService.NewHandlerServiceClient(conn) - resp, err := client.ListInbounds(ctx, &handlerService.ListInboundsRequest{}) + resp, err := client.ListInbounds(ctx, &handlerService.ListInboundsRequest{IsOnlyTags: isOnlyTags}) if err != nil { base.Fatalf("failed to list inbounds: %s", err) }