mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-07-16 15:04:14 +00:00
API: add option to fetch only tags from ListInbounds (#4870)
* feat: add new method for get only inbound tags from core. ListTags. * refactor: simplify creating response. * refactor: move getting tags in already exist method via option.
This commit is contained in:
parent
cb1afb33e6
commit
486d005986
4 changed files with 36 additions and 11 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue