mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-18 01:58:41 +00:00
Add commands for listing inbound and outbound tags.
This commit is contained in:
parent
7cb8cfb9eb
commit
229a4b3fe1
8 changed files with 181 additions and 235 deletions
|
@ -21,6 +21,8 @@ var CmdAPI = &base.Command{
|
|||
cmdAddOutbounds,
|
||||
cmdRemoveInbounds,
|
||||
cmdRemoveOutbounds,
|
||||
cmdListInbounds,
|
||||
cmdListOutbounds,
|
||||
cmdInboundUser,
|
||||
cmdInboundUserCount,
|
||||
cmdAddRules,
|
||||
|
|
44
main/commands/all/api/inbounds_list.go
Normal file
44
main/commands/all/api/inbounds_list.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
handlerService "github.com/xtls/xray-core/app/proxyman/command"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
)
|
||||
|
||||
var cmdListInbounds = &base.Command{
|
||||
CustomFlags: true,
|
||||
UsageLine: "{{.Exec}} api lsi [--server=127.0.0.1:8080]",
|
||||
Short: "List inbounds",
|
||||
Long: `
|
||||
List inbounds in Xray.
|
||||
|
||||
Arguments:
|
||||
|
||||
-s, -server <server:port>
|
||||
The API server address. Default 127.0.0.1:8080
|
||||
|
||||
-t, -timeout <seconds>
|
||||
Timeout in seconds for calling API. Default 3
|
||||
|
||||
Example:
|
||||
|
||||
{{.Exec}} {{.LongName}} --server=127.0.0.1:8080
|
||||
`,
|
||||
Run: executeListInbounds,
|
||||
}
|
||||
|
||||
func executeListInbounds(cmd *base.Command, args []string) {
|
||||
setSharedFlags(cmd)
|
||||
cmd.Flag.Parse(args)
|
||||
|
||||
conn, ctx, close := dialAPIServer()
|
||||
defer close()
|
||||
|
||||
client := handlerService.NewHandlerServiceClient(conn)
|
||||
|
||||
resp, err := client.ListInbounds(ctx, &handlerService.ListInboundsRequest{})
|
||||
if err != nil {
|
||||
base.Fatalf("failed to list inbounds: %s", err)
|
||||
}
|
||||
showJSONResponse(resp)
|
||||
}
|
43
main/commands/all/api/outbounds_list.go
Normal file
43
main/commands/all/api/outbounds_list.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
handlerService "github.com/xtls/xray-core/app/proxyman/command"
|
||||
"github.com/xtls/xray-core/main/commands/base"
|
||||
)
|
||||
|
||||
var cmdListOutbounds = &base.Command{
|
||||
CustomFlags: true,
|
||||
UsageLine: "{{.Exec}} api lso [--server=127.0.0.1:8080]",
|
||||
Short: "List outbounds",
|
||||
Long: `
|
||||
List outbounds in Xray.
|
||||
|
||||
Arguments:
|
||||
|
||||
-s, -server <server:port>
|
||||
The API server address. Default 127.0.0.1:8080
|
||||
|
||||
-t, -timeout <seconds>
|
||||
Timeout in seconds for calling API. Default 3
|
||||
|
||||
Example:
|
||||
|
||||
{{.Exec}} {{.LongName}} --server=127.0.0.1:8080
|
||||
`,
|
||||
Run: executeListOutbounds,
|
||||
}
|
||||
|
||||
func executeListOutbounds(cmd *base.Command, args []string) {
|
||||
setSharedFlags(cmd)
|
||||
cmd.Flag.Parse(args)
|
||||
|
||||
conn, ctx, close := dialAPIServer()
|
||||
defer close()
|
||||
|
||||
client := handlerService.NewHandlerServiceClient(conn)
|
||||
resp, err := client.ListOutbounds(ctx, &handlerService.ListOutboundsRequest{})
|
||||
if err != nil {
|
||||
base.Fatalf("failed to list outbounds: %s", err)
|
||||
}
|
||||
showJSONResponse(resp)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue