api.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package controller
  2. import "github.com/gin-gonic/gin"
  3. type APIController struct {
  4. BaseController
  5. inboundController *InboundController
  6. settingController *SettingController
  7. }
  8. func NewAPIController(g *gin.RouterGroup) *APIController {
  9. a := &APIController{}
  10. a.initRouter(g)
  11. return a
  12. }
  13. func (a *APIController) initRouter(g *gin.RouterGroup) {
  14. g = g.Group("/xui/API/inbounds")
  15. g.Use(a.checkLogin)
  16. g.POST("/list", a.getAllInbounds)
  17. g.GET("/get/:id", a.getSingleInbound)
  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("/delClient/:email", a.delInboundClient)
  25. g.POST("/updateClient/:index", a.updateInboundClient)
  26. g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic)
  27. a.inboundController = NewInboundController(g)
  28. }
  29. func (a *APIController) getAllInbounds(c *gin.Context) {
  30. a.inboundController.getInbounds(c)
  31. }
  32. func (a *APIController) getSingleInbound(c *gin.Context) {
  33. a.inboundController.getInbound(c)
  34. }
  35. func (a *APIController) addInbound(c *gin.Context) {
  36. a.inboundController.addInbound(c)
  37. }
  38. func (a *APIController) delInbound(c *gin.Context) {
  39. a.inboundController.delInbound(c)
  40. }
  41. func (a *APIController) updateInbound(c *gin.Context) {
  42. a.inboundController.updateInbound(c)
  43. }
  44. func (a *APIController) getClientIps(c *gin.Context) {
  45. a.inboundController.getClientIps(c)
  46. }
  47. func (a *APIController) clearClientIps(c *gin.Context) {
  48. a.inboundController.clearClientIps(c)
  49. }
  50. func (a *APIController) addInboundClient(c *gin.Context) {
  51. a.inboundController.addInboundClient(c)
  52. }
  53. func (a *APIController) delInboundClient(c *gin.Context) {
  54. a.inboundController.delInboundClient(c)
  55. }
  56. func (a *APIController) updateInboundClient(c *gin.Context) {
  57. a.inboundController.updateInboundClient(c)
  58. }
  59. func (a *APIController) resetClientTraffic(c *gin.Context) {
  60. a.inboundController.resetClientTraffic(c)
  61. }