3x-ui/web/controller/api.go

80 lines
2.1 KiB
Go
Raw Normal View History

2023-02-09 22:18:06 +03:00
package controller
2023-04-02 01:00:15 +03:00
import "github.com/gin-gonic/gin"
2023-02-09 22:18:06 +03:00
2023-04-02 01:00:15 +03:00
type APIController struct {
BaseController
inboundController *InboundController
settingController *SettingController
2023-02-09 22:18:06 +03:00
}
func NewAPIController(g *gin.RouterGroup) *APIController {
2023-04-02 01:00:15 +03:00
a := &APIController{}
a.initRouter(g)
return a
2023-02-09 22:18:06 +03:00
}
func (a *APIController) initRouter(g *gin.RouterGroup) {
2023-04-02 01:00:15 +03:00
g = g.Group("/xui/API/inbounds")
g.Use(a.checkLogin)
2023-02-09 22:18:06 +03:00
2023-04-02 01:00:15 +03:00
g.POST("/list", a.getAllInbounds)
g.GET("/get/:id", a.getSingleInbound)
g.POST("/add", a.addInbound)
g.POST("/del/:id", a.delInbound)
g.POST("/update/:id", a.updateInbound)
g.POST("/clientIps/:email", a.getClientIps)
g.POST("/clearClientIps/:email", a.clearClientIps)
g.POST("/addClient/", a.addInboundClient)
g.POST("/delClient/:email", a.delInboundClient)
g.POST("/updateClient/:index", a.updateInboundClient)
g.POST("/:id/resetClientTraffic/:email", a.resetClientTraffic)
2023-02-09 22:18:06 +03:00
2023-04-02 01:00:15 +03:00
a.inboundController = NewInboundController(g)
2023-02-09 22:18:06 +03:00
}
2023-04-02 01:00:15 +03:00
func (a *APIController) getAllInbounds(c *gin.Context) {
a.inboundController.getInbounds(c)
2023-02-09 22:18:06 +03:00
}
2023-04-02 01:00:15 +03:00
func (a *APIController) getSingleInbound(c *gin.Context) {
a.inboundController.getInbound(c)
2023-02-09 22:18:06 +03:00
}
2023-04-02 01:00:15 +03:00
2023-02-09 22:18:06 +03:00
func (a *APIController) addInbound(c *gin.Context) {
2023-04-02 01:00:15 +03:00
a.inboundController.addInbound(c)
2023-02-09 22:18:06 +03:00
}
2023-04-02 01:00:15 +03:00
2023-02-09 22:18:06 +03:00
func (a *APIController) delInbound(c *gin.Context) {
2023-04-02 01:00:15 +03:00
a.inboundController.delInbound(c)
2023-02-09 22:18:06 +03:00
}
2023-04-02 01:00:15 +03:00
2023-02-09 22:18:06 +03:00
func (a *APIController) updateInbound(c *gin.Context) {
2023-04-02 01:00:15 +03:00
a.inboundController.updateInbound(c)
}
func (a *APIController) getClientIps(c *gin.Context) {
a.inboundController.getClientIps(c)
}
func (a *APIController) clearClientIps(c *gin.Context) {
a.inboundController.clearClientIps(c)
}
func (a *APIController) addInboundClient(c *gin.Context) {
a.inboundController.addInboundClient(c)
}
func (a *APIController) delInboundClient(c *gin.Context) {
a.inboundController.delInboundClient(c)
}
func (a *APIController) updateInboundClient(c *gin.Context) {
a.inboundController.updateInboundClient(c)
}
func (a *APIController) resetClientTraffic(c *gin.Context) {
a.inboundController.resetClientTraffic(c)
2023-02-09 22:18:06 +03:00
}