api.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package controller
  2. import "github.com/gin-gonic/gin"
  3. type APIController struct {
  4. BaseController
  5. inboundController *InboundController
  6. }
  7. func NewAPIController(g *gin.RouterGroup) *APIController {
  8. a := &APIController{}
  9. a.initRouter(g)
  10. return a
  11. }
  12. func (a *APIController) initRouter(g *gin.RouterGroup) {
  13. g = g.Group("/xui/API/inbounds")
  14. g.Use(a.checkLogin)
  15. g.GET("/list", a.getAllInbounds)
  16. g.GET("/get/:id", a.getSingleInbound)
  17. g.GET("/getClientTraffics/:email", a.getClientTraffics)
  18. g.POST("/add", a.addInbound)
  19. g.POST("/del/:id", a.delInbound)
  20. g.POST("/update/:id", a.updateInbound)
  21. g.POST("/clientIps/:email", a.getClientIps)
  22. g.POST("/clearClientIps/:email", a.clearClientIps)
  23. g.POST("/addClient", a.addInboundClient)
  24. g.POST("/:id/delClient/:clientId", a.delInboundClient)
  25. g.POST("/updateClient/:clientId", a.updateInboundClient)
  26. g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic)
  27. g.POST("/resetAllTraffics", a.resetAllTraffics)
  28. g.POST("/resetAllClientTraffics/:id", a.resetAllClientTraffics)
  29. g.POST("/delDepletedClients/:id", a.delDepletedClients)
  30. a.inboundController = NewInboundController(g)
  31. }
  32. func (a *APIController) getAllInbounds(c *gin.Context) {
  33. a.inboundController.getInbounds(c)
  34. }
  35. func (a *APIController) getSingleInbound(c *gin.Context) {
  36. a.inboundController.getInbound(c)
  37. }
  38. func (a *APIController) getClientTraffics(c *gin.Context) {
  39. a.inboundController.getClientTraffics(c)
  40. }
  41. func (a *APIController) addInbound(c *gin.Context) {
  42. a.inboundController.addInbound(c)
  43. }
  44. func (a *APIController) delInbound(c *gin.Context) {
  45. a.inboundController.delInbound(c)
  46. }
  47. func (a *APIController) updateInbound(c *gin.Context) {
  48. a.inboundController.updateInbound(c)
  49. }
  50. func (a *APIController) getClientIps(c *gin.Context) {
  51. a.inboundController.getClientIps(c)
  52. }
  53. func (a *APIController) clearClientIps(c *gin.Context) {
  54. a.inboundController.clearClientIps(c)
  55. }
  56. func (a *APIController) addInboundClient(c *gin.Context) {
  57. a.inboundController.addInboundClient(c)
  58. }
  59. func (a *APIController) delInboundClient(c *gin.Context) {
  60. a.inboundController.delInboundClient(c)
  61. }
  62. func (a *APIController) updateInboundClient(c *gin.Context) {
  63. a.inboundController.updateInboundClient(c)
  64. }
  65. func (a *APIController) resetClientTraffic(c *gin.Context) {
  66. a.inboundController.resetClientTraffic(c)
  67. }
  68. func (a *APIController) resetAllTraffics(c *gin.Context) {
  69. a.inboundController.resetAllTraffics(c)
  70. }
  71. func (a *APIController) resetAllClientTraffics(c *gin.Context) {
  72. a.inboundController.resetAllClientTraffics(c)
  73. }
  74. func (a *APIController) delDepletedClients(c *gin.Context) {
  75. a.inboundController.delDepletedClients(c)
  76. }