proxy.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package base
  2. import (
  3. subSupplier "github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier"
  4. "github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier/shooter"
  5. "github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier/subhd"
  6. "github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier/xunlei"
  7. "github.com/allanpk716/ChineseSubFinder/internal/logic/sub_supplier/zimuku"
  8. "github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
  9. "github.com/gin-gonic/gin"
  10. "github.com/huandu/go-clone"
  11. "net/http"
  12. )
  13. func (cb ControllerBase) CheckProxyHandler(c *gin.Context) {
  14. var err error
  15. defer func() {
  16. // 统一的异常处理
  17. cb.ErrorProcess(c, "CheckProxyHandler", err)
  18. }()
  19. tmpSettings := clone.Clone(*settings.GetSettings()).(settings.Settings)
  20. // 使用提交过来的这个代理地址,测试多个字幕网站的可用性
  21. subSupplierHub := subSupplier.NewSubSupplierHub(
  22. tmpSettings,
  23. zimuku.NewSupplier(tmpSettings),
  24. xunlei.NewSupplier(tmpSettings),
  25. shooter.NewSupplier(tmpSettings),
  26. subhd.NewSupplier(tmpSettings),
  27. )
  28. outStatus := subSupplierHub.CheckSubSiteStatus()
  29. c.JSON(http.StatusOK, outStatus)
  30. }