Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions app/proxyman/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 13 additions & 2 deletions app/proxyman/command/command.pb.go

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

4 changes: 3 additions & 1 deletion app/proxyman/command/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ message AlterInboundRequest {

message AlterInboundResponse {}

message ListInboundsRequest {}
message ListInboundsRequest {
bool isOnlyTags = 1;
}

message ListInboundsResponse {
repeated core.InboundHandlerConfig inbounds = 1;
Expand Down
7 changes: 5 additions & 2 deletions main/commands/all/api/inbounds_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}
Expand Down