inbound_user_count.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package api
  2. import (
  3. handlerService "github.com/xtls/xray-core/app/proxyman/command"
  4. "github.com/xtls/xray-core/main/commands/base"
  5. )
  6. var cmdInboundUserCount = &base.Command{
  7. CustomFlags: true,
  8. UsageLine: "{{.Exec}} api inboundusercount [--server=127.0.0.1:8080] -tag=tag",
  9. Short: "Get Inbound User Count",
  10. Long: `
  11. Get User count from an inbound.
  12. Arguments:
  13. -s, -server
  14. The API server address. Default 127.0.0.1:8080
  15. -t, -timeout
  16. Timeout seconds to call API. Default 3
  17. -tag
  18. Inbound tag
  19. Example:
  20. {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name"
  21. `,
  22. Run: executeInboundUserCount,
  23. }
  24. func executeInboundUserCount(cmd *base.Command, args []string) {
  25. setSharedFlags(cmd)
  26. var tag string
  27. cmd.Flag.StringVar(&tag, "tag", "", "")
  28. cmd.Flag.Parse(args)
  29. conn, ctx, close := dialAPIServer()
  30. defer close()
  31. client := handlerService.NewHandlerServiceClient(conn)
  32. r := &handlerService.GetInboundUserRequest{
  33. Tag: tag,
  34. }
  35. resp, err := client.GetInboundUsersCount(ctx, r)
  36. if err != nil {
  37. base.Fatalf("failed to get inbound user count: %s", err)
  38. }
  39. showJSONResponse(resp)
  40. }