1
0

api.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.POST("/add", a.addInbound)
  18. g.POST("/del/:id", a.delInbound)
  19. g.POST("/update/:id", a.updateInbound)
  20. g.POST("/clientIps/:email", a.getClientIps)
  21. g.POST("/clearClientIps/:email", a.clearClientIps)
  22. g.POST("/addClient/", a.addInboundClient)
  23. g.POST("/delClient/:email", a.delInboundClient)
  24. g.POST("/updateClient/:index", a.updateInboundClient)
  25. g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic)
  26. g.POST("/resetAllTraffics", a.resetAllTraffics)
  27. g.POST("/resetAllClientTraffics/:id", a.resetAllClientTraffics)
  28. a.inboundController = NewInboundController(g)
  29. }
  30. func (a *APIController) getAllInbounds(c *gin.Context) {
  31. a.inboundController.getInbounds(c)
  32. }
  33. func (a *APIController) getSingleInbound(c *gin.Context) {
  34. a.inboundController.getInbound(c)
  35. }
  36. func (a *APIController) addInbound(c *gin.Context) {
  37. a.inboundController.addInbound(c)
  38. }
  39. func (a *APIController) delInbound(c *gin.Context) {
  40. a.inboundController.delInbound(c)
  41. }
  42. func (a *APIController) updateInbound(c *gin.Context) {
  43. a.inboundController.updateInbound(c)
  44. }
  45. func (a *APIController) getClientIps(c *gin.Context) {
  46. a.inboundController.getClientIps(c)
  47. }
  48. func (a *APIController) clearClientIps(c *gin.Context) {
  49. a.inboundController.clearClientIps(c)
  50. }
  51. func (a *APIController) addInboundClient(c *gin.Context) {
  52. a.inboundController.addInboundClient(c)
  53. }
  54. func (a *APIController) delInboundClient(c *gin.Context) {
  55. a.inboundController.delInboundClient(c)
  56. }
  57. func (a *APIController) updateInboundClient(c *gin.Context) {
  58. a.inboundController.updateInboundClient(c)
  59. }
  60. func (a *APIController) resetClientTraffic(c *gin.Context) {
  61. a.inboundController.resetClientTraffic(c)
  62. }
  63. func (a *APIController) resetAllTraffics(c *gin.Context) {
  64. a.inboundController.resetAllTraffics(c)
  65. }
  66. func (a *APIController) resetAllClientTraffics(c *gin.Context) {
  67. a.inboundController.resetAllClientTraffics(c)
  68. }