Reachable hosts

This commit is contained in:
Ben Adrian Sarmiento
2024-06-24 01:21:09 +02:00
parent 449c0f71cf
commit 2e9a068780
5 changed files with 68 additions and 48 deletions

View File

@@ -64,7 +64,7 @@ func MainApp(configPath string) {
repoClient4 := http.NewHTTPClient("", 0, 1, false, []string{}, proxyURL, log.Named("network_test"))
repoClient6 := http.NewHTTPClient("", 0, 1, true, []string{}, proxyURL, log.Named("network_test"))
repo := http.NewIPRepository(repoClient4, repoClient6, "", log.Named("network_test"))
repo.NetworkTest(false)
repo.NetworkTest(false, config.ShouldCacheNetworkTestResults())
apiClient := http.NewHTTPClient(
config.GetToken(),
@@ -86,14 +86,11 @@ func MainApp(configPath string) {
log.Named("unrestrict_client"),
)
hosts := repo.GetOptimalHosts(config.GetNumberOfHosts(), config.ShouldForceIPv6())
hosts := repo.GetHosts(config.GetNumberOfHosts(), config.ShouldForceIPv6())
if len(hosts) == 0 {
zurglog.Fatal("No optimal hosts found. We cannot continue! (check if Real-Debrid is down or they have blocked your IP address)")
zurglog.Fatal("No reachable hosts found. We cannot continue! (check if Real-Debrid is down or they have blocked your IP address)")
}
zurglog.Debugf("Optimal hosts (%d): %v", len(hosts), hosts)
// help message
zurglog.Debug("To reset optimal hosts, run 'zurg network-test' (Using docker compose? 'docker compose exec zurg ./zurg network-test')")
zurglog.Debug("To run network-test with a proxy, set the PROXY environment variable 'PROXY=http://xyz:123 zurg network-test'")
zurglog.Debugf("Reachable hosts (%d): %v", len(hosts), hosts)
downloadClient := http.NewHTTPClient(
"",

View File

@@ -38,7 +38,7 @@ func NetworkTest(testURL string) {
repoClient4 := http.NewHTTPClient("", 0, 1, false, []string{}, proxyURL, log.Named("network_test"))
repoClient6 := http.NewHTTPClient("", 0, 1, true, []string{}, proxyURL, log.Named("network_test"))
repo := http.NewIPRepository(repoClient4, repoClient6, testURL, log.Named("network_test"))
repo.NetworkTest(true)
repo.NetworkTest(true, true)
}
func ClearDownloads() {

View File

@@ -34,6 +34,7 @@ type ConfigInterface interface {
GetVersion() string
MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64, mediaInfos []*ffprobe.ProbeData) bool
ShouldAutoAnalyzeNewTorrents() bool
ShouldCacheNetworkTestResults() bool
ShouldForceIPv6() bool
ShouldIgnoreRenames() bool
ShouldServeFromRclone() bool
@@ -45,6 +46,7 @@ type ZurgConfig struct {
ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"`
AutoAnalyzeNewTorrents bool `yaml:"auto_analyze_new_torrents" json:"auto_analyze_new_torrents"`
CacheNetworkTestResults bool `yaml:"cache_network_test_results" json:"cache_network_test_results"`
CanRepair bool `yaml:"enable_repair" json:"enable_repair"`
DownloadsEveryMins int `yaml:"downloads_every_mins" json:"downloads_every_mins"`
DownloadTimeoutSecs int `yaml:"download_timeout_secs" json:"download_timeout_secs"`
@@ -217,12 +219,13 @@ func (z *ZurgConfig) GetProxy() string {
}
func (z *ZurgConfig) GetNumberOfHosts() int {
if z.NumberOfHosts == 0 {
return 20
}
return z.NumberOfHosts
}
func (z *ZurgConfig) ShouldAutoAnalyzeNewTorrents() bool {
return z.AutoAnalyzeNewTorrents
}
func (z *ZurgConfig) ShouldCacheNetworkTestResults() bool {
return z.CacheNetworkTestResults
}