Additional configs

This commit is contained in:
Ben Sarmiento
2023-11-28 11:39:08 +01:00
parent 00c7e04795
commit a42a5eeb80
5 changed files with 30 additions and 7 deletions

View File

@@ -23,6 +23,8 @@ type ConfigInterface interface {
GetUnrestrictWorkers() int
GetReleaseUnrestrictAfterMs() int
GetRateLimitSleepSeconds() int
GetRealDebridTimeout() int
GetRetriesUntilFailed() int
}
type ZurgConfig struct {
@@ -44,6 +46,8 @@ type ZurgConfig struct {
PreferredHosts []string `yaml:"preferred_hosts"`
ServeFromRclone bool `yaml:"serve_from_rclone"`
ForceIPv6 bool `yaml:"force_ipv6"`
RealDebridTimeout int `yaml:"realdebrid_timeout_secs"`
RetriesUntilFailed int `yaml:"retries_until_failed"`
}
func (z *ZurgConfig) GetToken() string {
@@ -144,3 +148,17 @@ func (z *ZurgConfig) GetRateLimitSleepSeconds() int {
}
return z.RateLimitSleepSeconds
}
func (z *ZurgConfig) GetRealDebridTimeout() int {
if z.RealDebridTimeout == 0 {
return 60
}
return z.RealDebridTimeout
}
func (z *ZurgConfig) GetRetriesUntilFailed() int {
if z.RetriesUntilFailed == 0 {
return 5
}
return z.RetriesUntilFailed
}

View File

@@ -82,6 +82,7 @@ func (gf *GetFile) HandleGetRequest(w http.ResponseWriter, r *http.Request, t *i
if download, exists := t.DownloadCache.Get(link); exists {
if c.ShouldServeFromRclone() && t.Api.CanFetchFirstByte(download.Download) {
redirect(w, r, download.Download, c)
return
} else {
err := gf.streamCachedLinkToResponse(download.Download, w, r, t, c, log)
if err == nil {