mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-12 13:10:05 +00:00
no message
This commit is contained in:
parent
844efda925
commit
2afa5f02b7
12 changed files with 25 additions and 29 deletions
|
@ -10,8 +10,8 @@ import (
|
|||
"x-ui/logger"
|
||||
"x-ui/util/json_util"
|
||||
"x-ui/util/random"
|
||||
"x-ui/web/service"
|
||||
"x-ui/xray"
|
||||
"x-ui/web/service"
|
||||
)
|
||||
|
||||
//go:embed default.json
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"x-ui/logger"
|
||||
"x-ui/util/common"
|
||||
"x-ui/util/random"
|
||||
"x-ui/web/service"
|
||||
"x-ui/xray"
|
||||
"x-ui/web/service"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"x-ui/web/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type APIController struct {
|
||||
BaseController
|
||||
inboundController *InboundController
|
||||
Tgbot service.Tgbot
|
||||
}
|
||||
|
||||
func NewAPIController(g *gin.RouterGroup) *APIController {
|
||||
|
@ -29,7 +26,6 @@ func (a *APIController) initRouter(g *gin.RouterGroup) {
|
|||
Path string
|
||||
Handler gin.HandlerFunc
|
||||
}{
|
||||
{"GET", "/createbackup", a.createBackup},
|
||||
{"GET", "/list", a.inboundController.getInbounds},
|
||||
{"GET", "/get/:id", a.inboundController.getInbound},
|
||||
{"GET", "/getClientTraffics/:email", a.inboundController.getClientTraffics},
|
||||
|
@ -53,7 +49,3 @@ func (a *APIController) initRouter(g *gin.RouterGroup) {
|
|||
g.Handle(route.Method, route.Path, route.Handler)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *APIController) createBackup(c *gin.Context) {
|
||||
a.Tgbot.SendBackupToAdmins()
|
||||
}
|
||||
|
|
|
@ -6,15 +6,14 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"x-ui/database/model"
|
||||
"x-ui/web/service"
|
||||
"x-ui/database"
|
||||
)
|
||||
|
||||
type BlockedDomainController struct {
|
||||
service *service.BlockedDomainService
|
||||
}
|
||||
|
||||
func NewBlockedDomainController(g *gin.RouterGroup) *BlockedDomainController {
|
||||
ctrl := &BlockedDomainController{service: &service.BlockedDomainService{}}
|
||||
ctrl := &BlockedDomainController{}
|
||||
r := g.Group("/blocked-domains")
|
||||
r.GET("/", ctrl.List)
|
||||
r.POST("/", ctrl.Create)
|
||||
|
@ -24,7 +23,8 @@ func NewBlockedDomainController(g *gin.RouterGroup) *BlockedDomainController {
|
|||
}
|
||||
|
||||
func (ctrl *BlockedDomainController) List(c *gin.Context) {
|
||||
domains, err := ctrl.service.GetAll()
|
||||
var domains []model.BlockedDomain
|
||||
err := database.GetDB().Find(&domains).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
|
||||
return
|
||||
|
@ -38,7 +38,8 @@ func (ctrl *BlockedDomainController) Create(c *gin.Context) {
|
|||
c.JSON(http.StatusBadRequest, gin.H{"success": false, "msg": err.Error()})
|
||||
return
|
||||
}
|
||||
if err := ctrl.service.Create(&domain); err != nil {
|
||||
err := database.GetDB().Create(&domain).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
@ -57,7 +58,8 @@ func (ctrl *BlockedDomainController) Update(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
domain.Id = id
|
||||
if err := ctrl.service.Update(&domain); err != nil {
|
||||
err = database.GetDB().Save(&domain).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
@ -70,7 +72,8 @@ func (ctrl *BlockedDomainController) Delete(c *gin.Context) {
|
|||
c.JSON(http.StatusBadRequest, gin.H{"success": false, "msg": "invalid id"})
|
||||
return
|
||||
}
|
||||
if err := ctrl.service.Delete(id); err != nil {
|
||||
err = database.GetDB().Delete(&model.BlockedDomain{}, id).Error
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "msg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"strconv"
|
||||
|
||||
"x-ui/database/model"
|
||||
"x-ui/web/service"
|
||||
"x-ui/web/session"
|
||||
"x-ui/web/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -21,7 +21,6 @@ type LoginForm struct {
|
|||
|
||||
type IndexController struct {
|
||||
BaseController
|
||||
|
||||
settingService service.SettingService
|
||||
userService service.UserService
|
||||
tgbot service.Tgbot
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
"x-ui/util/crypto"
|
||||
"x-ui/web/entity"
|
||||
"x-ui/web/service"
|
||||
"x-ui/web/session"
|
||||
"x-ui/web/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"x-ui/web/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"x-ui/web/service"
|
||||
)
|
||||
|
||||
type XraySettingController struct {
|
||||
|
|
|
@ -4,9 +4,8 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"x-ui/web/service"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
"x-ui/web/service"
|
||||
)
|
||||
|
||||
type CheckCpuJob struct {
|
||||
|
|
|
@ -3,7 +3,6 @@ package service
|
|||
import (
|
||||
"x-ui/database"
|
||||
"x-ui/database/model"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BlockedDomainService struct{}
|
||||
|
|
|
@ -7,7 +7,8 @@ import (
|
|||
|
||||
"x-ui/logger"
|
||||
"x-ui/xray"
|
||||
"x-ui/web/service"
|
||||
"x-ui/database"
|
||||
"x-ui/database/model"
|
||||
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
@ -74,7 +75,8 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
|
|||
}
|
||||
|
||||
// --- Блокировка запрещённых доменов ---
|
||||
blockedDomains, err := service.BlockedDomainService{}.GetAll()
|
||||
var blockedDomains []model.BlockedDomain
|
||||
err = database.GetDB().Find(&blockedDomains).Error
|
||||
if err == nil && len(blockedDomains) > 0 {
|
||||
var domains []string
|
||||
for _, d := range blockedDomains {
|
||||
|
|
|
@ -100,8 +100,11 @@ type Server struct {
|
|||
func NewServer() *Server {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
return &Server{
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
xrayService: service.XrayService{},
|
||||
settingService: service.SettingService{},
|
||||
tgbotService: service.Tgbot{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue