api.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. a.inboundController = NewInboundController(g)
  30. }
  31. func (a *APIController) getAllInbounds(c *gin.Context) {
  32. a.inboundController.getInbounds(c)
  33. }
  34. func (a *APIController) getSingleInbound(c *gin.Context) {
  35. a.inboundController.getInbound(c)
  36. }
  37. func (a *APIController) getClientTraffics(c *gin.Context) {
  38. a.inboundController.getClientTraffics(c)
  39. }
  40. func (a *APIController) addInbound(c *gin.Context) {
  41. a.inboundController.addInbound(c)
  42. }
  43. func (a *APIController) delInbound(c *gin.Context) {
  44. a.inboundController.delInbound(c)
  45. }
  46. func (a *APIController) updateInbound(c *gin.Context) {
  47. a.inboundController.updateInbound(c)
  48. }
  49. func (a *APIController) getClientIps(c *gin.Context) {
  50. a.inboundController.getClientIps(c)
  51. }
  52. func (a *APIController) clearClientIps(c *gin.Context) {
  53. a.inboundController.clearClientIps(c)
  54. }
  55. func (a *APIController) addInboundClient(c *gin.Context) {
  56. a.inboundController.addInboundClient(c)
  57. }
  58. func (a *APIController) delInboundClient(c *gin.Context) {
  59. a.inboundController.delInboundClient(c)
  60. }
  61. func (a *APIController) updateInboundClient(c *gin.Context) {
  62. a.inboundController.updateInboundClient(c)
  63. }
  64. func (a *APIController) resetClientTraffic(c *gin.Context) {
  65. a.inboundController.resetClientTraffic(c)
  66. }
  67. func (a *APIController) resetAllTraffics(c *gin.Context) {
  68. a.inboundController.resetAllTraffics(c)
  69. }
  70. func (a *APIController) resetAllClientTraffics(c *gin.Context) {
  71. a.inboundController.resetAllClientTraffics(c)
  72. }