Add network test command

This commit is contained in:
Ben Adrian Sarmiento
2024-06-16 09:47:29 +02:00
parent f4d3f273f6
commit 42a08583ce
7 changed files with 60 additions and 47 deletions

View File

@@ -52,8 +52,10 @@ func MainApp(configPath string) {
os.Exit(1)
}
repoClient4 := http.NewHTTPClient("", 0, 1, false, []string{}, config, log.Named("network_test"))
repoClient6 := http.NewHTTPClient("", 0, 1, true, []string{}, config, log.Named("network_test"))
proxyURL := os.Getenv("PROXY")
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)
@@ -63,7 +65,7 @@ func MainApp(configPath string) {
config.GetApiTimeoutSecs(), // default api timeout = 60
false, // no need for ipv6 support
[]string{}, // no optimal hosts needed
config,
proxyURL,
log.Named("api_client"),
)
@@ -73,7 +75,7 @@ func MainApp(configPath string) {
config.GetDownloadTimeoutSecs(), // default download timeout = 10
false, // no need for ipv6 support
[]string{}, // no optimal hosts needed
config,
proxyURL,
log.Named("unrestrict_client"),
)
@@ -86,7 +88,7 @@ func MainApp(configPath string) {
config.GetDownloadTimeoutSecs(),
config.ShouldForceIPv6(),
hosts,
config,
proxyURL,
log.Named("download_client"),
)

View File

@@ -5,10 +5,13 @@ import (
"fmt"
"os"
"strings"
"time"
"github.com/debridmediamanager/zurg/internal/clear"
"github.com/debridmediamanager/zurg/internal/version"
"github.com/debridmediamanager/zurg/pkg/realdebrid"
"github.com/debridmediamanager/zurg/pkg/http"
"github.com/debridmediamanager/zurg/pkg/logutil"
"github.com/debridmediamanager/zurg/pkg/utils"
)
func ShowVersion() {
@@ -16,8 +19,19 @@ func ShowVersion() {
version.GetBuiltAt(), version.GetGitCommit(), version.GetVersion())
}
func NetworkTest(testType string) {
realdebrid.RunTest(testType)
func NetworkTest() {
utils.EnsureDirExists("logs")
utils.EnsureDirExists("data")
dateStr := time.Now().Format(time.DateOnly)
timeStr := strings.ReplaceAll(time.Now().Format(time.TimeOnly), ":", "-")
logPath := fmt.Sprintf("logs/network-test-%s-%s.log", dateStr, timeStr)
log := logutil.NewLogger(logPath)
repoClient4 := http.NewHTTPClient("", 0, 1, false, []string{}, os.Getenv("PROXY"), log.Named("network_test"))
repoClient6 := http.NewHTTPClient("", 0, 1, true, []string{}, os.Getenv("PROXY"), log.Named("network_test"))
repo := http.NewIPRepository(repoClient4, repoClient6, log.Named("network_test"))
repo.NetworkTest(true)
}
func ClearDownloads() {

View File

@@ -18,7 +18,6 @@ type ConfigInterface interface {
GetPort() string
GetUsername() string
GetPassword() string
GetProxy() string
GetDirectories() []string
MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64, mediaInfos []*ffprobe.ProbeData) bool
GetOnLibraryUpdate() string
@@ -101,13 +100,6 @@ func (z *ZurgConfig) GetPassword() string {
return z.Password
}
func (z *ZurgConfig) GetProxy() string {
if os.Getenv("PROXY") != "" {
return os.Getenv("PROXY")
}
return z.Proxy
}
func (z *ZurgConfig) GetNumOfWorkers() int {
if z.NumOfWorkers == 0 {
return 20

View File

@@ -1 +0,0 @@
--allow-non-empty --allow-other --attr-timeout 10y --buffer-size 4M --dir-cache-time 120s --poll-interval 60s --vfs-cache-max-age 2M --vfs-cache-max-size 2G --vfs-cache-min-free-space 200M --vfs-cache-mode full --vfs-cache-poll-interval 30s --vfs-disk-space-total-size 6G --vfs-fast-fingerprint --vfs-read-ahead 4M --vfs-read-chunk-size 8M --vfs-read-chunk-size-limit 0 --vfs-read-wait 5ms --vfs-refresh