Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'web/web.go')
-rw-r--r--web/web.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/web/web.go b/web/web.go
index 60934048..462e88a0 100644
--- a/web/web.go
+++ b/web/web.go
@@ -101,9 +101,10 @@ type Server struct {
api *controller.APIController
ws *controller.WebSocketController
- xrayService service.XrayService
- settingService service.SettingService
- tgbotService service.Tgbot
+ xrayService service.XrayService
+ settingService service.SettingService
+ tgbotService service.Tgbot
+ customGeoService *service.CustomGeoService
wsHub *websocket.Hub
@@ -268,7 +269,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {
s.index = controller.NewIndexController(g)
s.panel = controller.NewXUIController(g)
- s.api = controller.NewAPIController(g)
+ s.api = controller.NewAPIController(g, s.customGeoService)
// Initialize WebSocket hub
s.wsHub = websocket.NewHub()
@@ -295,6 +296,7 @@ func (s *Server) initRouter() (*gin.Engine, error) {
// startTask schedules background jobs (Xray checks, traffic jobs, cron
// jobs) which the panel relies on for periodic maintenance and monitoring.
func (s *Server) startTask() {
+ s.customGeoService.EnsureOnStartup()
err := s.xrayService.RestartXray(true)
if err != nil {
logger.Warning("start xray failed:", err)
@@ -388,6 +390,8 @@ func (s *Server) Start() (err error) {
s.cron = cron.New(cron.WithLocation(loc), cron.WithSeconds())
s.cron.Start()
+ s.customGeoService = service.NewCustomGeoService()
+
engine, err := s.initRouter()
if err != nil {
return err