mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-10-28 10:52:51 +00:00
Compare commits
1 commit
e0664b29d4
...
302dd01b04
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
302dd01b04 |
5 changed files with 6 additions and 23 deletions
|
|
@ -37,6 +37,6 @@ func (j *PeriodicClientTrafficResetJob) Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if resetCount > 0 {
|
if resetCount > 0 {
|
||||||
logger.Infof("Periodic client traffic reset completed: %d clients reset", resetCount)
|
logger.Infof("Periodic client traffic reset completed: %d clients reseted", resetCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,6 @@ func (j *PeriodicTrafficResetJob) Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if resetCount > 0 {
|
if resetCount > 0 {
|
||||||
logger.Infof("Periodic traffic reset completed: %d inbounds reset", resetCount)
|
logger.Infof("Periodic traffic reset completed: %d inbounds reseted", resetCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -739,7 +739,7 @@ func (s *InboundService) DelInboundClient(inboundId int, clientId string) (bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId string) (bool, error) {
|
func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId string) (bool, error) {
|
||||||
// TODO: check if TrafficReset field is updating
|
// TODO: check if TrafficReset field are updating
|
||||||
clients, err := s.GetClients(data)
|
clients, err := s.GetClients(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"x-ui/database/model"
|
"x-ui/database/model"
|
||||||
|
|
||||||
|
|
@ -33,7 +32,6 @@ func SetMaxAge(c *gin.Context, maxAge int) {
|
||||||
Path: defaultPath,
|
Path: defaultPath,
|
||||||
MaxAge: maxAge,
|
MaxAge: maxAge,
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
SameSite: http.SameSiteLaxMode,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,6 +61,5 @@ func ClearSession(c *gin.Context) {
|
||||||
Path: defaultPath,
|
Path: defaultPath,
|
||||||
MaxAge: -1,
|
MaxAge: -1,
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
SameSite: http.SameSiteLaxMode,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
web/web.go
20
web/web.go
|
|
@ -31,7 +31,7 @@ import (
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed assets
|
//go:embed assets/*
|
||||||
var assetsFS embed.FS
|
var assetsFS embed.FS
|
||||||
|
|
||||||
//go:embed html/*
|
//go:embed html/*
|
||||||
|
|
@ -180,15 +180,6 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||||
assetsBasePath := basePath + "assets/"
|
assetsBasePath := basePath + "assets/"
|
||||||
|
|
||||||
store := cookie.NewStore(secret)
|
store := cookie.NewStore(secret)
|
||||||
// Configure default session cookie options, including expiration (MaxAge)
|
|
||||||
if sessionMaxAge, err := s.settingService.GetSessionMaxAge(); err == nil {
|
|
||||||
store.Options(sessions.Options{
|
|
||||||
Path: "/",
|
|
||||||
MaxAge: sessionMaxAge * 60, // minutes -> seconds
|
|
||||||
HttpOnly: true,
|
|
||||||
SameSite: http.SameSiteLaxMode,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
engine.Use(sessions.Sessions("3x-ui", store))
|
engine.Use(sessions.Sessions("3x-ui", store))
|
||||||
engine.Use(func(c *gin.Context) {
|
engine.Use(func(c *gin.Context) {
|
||||||
c.Set("base_path", basePath)
|
c.Set("base_path", basePath)
|
||||||
|
|
@ -210,11 +201,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||||
i18nWebFunc := func(key string, params ...string) string {
|
i18nWebFunc := func(key string, params ...string) string {
|
||||||
return locale.I18n(locale.Web, key, params...)
|
return locale.I18n(locale.Web, key, params...)
|
||||||
}
|
}
|
||||||
// Register template functions before loading templates
|
engine.FuncMap["i18n"] = i18nWebFunc
|
||||||
funcMap := template.FuncMap{
|
|
||||||
"i18n": i18nWebFunc,
|
|
||||||
}
|
|
||||||
engine.SetFuncMap(funcMap)
|
|
||||||
engine.Use(locale.LocalizerMiddleware())
|
engine.Use(locale.LocalizerMiddleware())
|
||||||
|
|
||||||
// set static files and template
|
// set static files and template
|
||||||
|
|
@ -224,12 +211,11 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Use the registered func map with the loaded templates
|
|
||||||
engine.LoadHTMLFiles(files...)
|
engine.LoadHTMLFiles(files...)
|
||||||
engine.StaticFS(basePath+"assets", http.FS(os.DirFS("web/assets")))
|
engine.StaticFS(basePath+"assets", http.FS(os.DirFS("web/assets")))
|
||||||
} else {
|
} else {
|
||||||
// for production
|
// for production
|
||||||
template, err := s.getHtmlTemplate(funcMap)
|
template, err := s.getHtmlTemplate(engine.FuncMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue