remote_routing_job.go 844 B

12345678910111213141516171819202122232425262728293031
  1. package job
  2. import (
  3. "github.com/mhsanaei/3x-ui/v3/internal/logger"
  4. "github.com/mhsanaei/3x-ui/v3/internal/sub"
  5. "github.com/mhsanaei/3x-ui/v3/internal/web/service"
  6. )
  7. // RemoteRoutingJob keeps remote Happ and Clash/Mihomo routing URLs warm: all
  8. // network work runs here (cron + startup warm), never in a request handler.
  9. type RemoteRoutingJob struct {
  10. settingService service.SettingService
  11. }
  12. func NewRemoteRoutingJob() *RemoteRoutingJob {
  13. return &RemoteRoutingJob{}
  14. }
  15. func (j *RemoteRoutingJob) Run() {
  16. happ, err := j.settingService.GetSubRoutingRules()
  17. if err != nil {
  18. logger.Warning("Could not read Happ routing source:", err)
  19. return
  20. }
  21. clash, err := j.settingService.GetSubClashRules()
  22. if err != nil {
  23. logger.Warning("Could not read Clash routing source:", err)
  24. return
  25. }
  26. sub.RefreshRemoteRoutingSources(happ, clash)
  27. }