Bandwidth tracking
This commit is contained in:
@@ -66,6 +66,12 @@ func MainApp(configPath string) {
|
||||
repo := http.NewIPRepository(repoClient4, repoClient6, "", log.Named("network_test"))
|
||||
repo.NetworkTest(false, config.ShouldCacheNetworkTestResults())
|
||||
|
||||
hosts := repo.GetHosts(config.GetNumberOfHosts(), config.ShouldForceIPv6())
|
||||
if len(hosts) == 0 {
|
||||
zurglog.Fatal("No reachable hosts found. We cannot continue! (check if Real-Debrid is down or they have blocked your IP address)")
|
||||
}
|
||||
zurglog.Debugf("Reachable hosts (%d): %v", len(hosts), hosts)
|
||||
|
||||
apiClient := http.NewHTTPClient(
|
||||
config.GetToken(),
|
||||
config.GetRetriesUntilFailed(), // default retries = 2
|
||||
@@ -86,12 +92,6 @@ func MainApp(configPath string) {
|
||||
log.Named("unrestrict_client"),
|
||||
)
|
||||
|
||||
hosts := repo.GetHosts(config.GetNumberOfHosts(), config.ShouldForceIPv6())
|
||||
if len(hosts) == 0 {
|
||||
zurglog.Fatal("No reachable hosts found. We cannot continue! (check if Real-Debrid is down or they have blocked your IP address)")
|
||||
}
|
||||
zurglog.Debugf("Reachable hosts (%d): %v", len(hosts), hosts)
|
||||
|
||||
downloadClient := http.NewHTTPClient(
|
||||
"",
|
||||
config.GetRetriesUntilFailed(),
|
||||
|
||||
@@ -37,6 +37,7 @@ type ConfigInterface interface {
|
||||
ShouldCacheNetworkTestResults() bool
|
||||
ShouldForceIPv6() bool
|
||||
ShouldIgnoreRenames() bool
|
||||
ShouldLogRequests() bool
|
||||
ShouldServeFromRclone() bool
|
||||
}
|
||||
|
||||
@@ -54,6 +55,7 @@ type ZurgConfig struct {
|
||||
ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"`
|
||||
Host string `yaml:"host" json:"host"`
|
||||
IgnoreRenames bool `yaml:"ignore_renames" json:"ignore_renames"`
|
||||
LogRequests bool `yaml:"log_requests" json:"log_requests"`
|
||||
NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"`
|
||||
NumberOfHosts int `yaml:"number_of_hosts" json:"number_of_hosts"`
|
||||
NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"`
|
||||
@@ -229,3 +231,7 @@ func (z *ZurgConfig) ShouldAutoAnalyzeNewTorrents() bool {
|
||||
func (z *ZurgConfig) ShouldCacheNetworkTestResults() bool {
|
||||
return z.CacheNetworkTestResults
|
||||
}
|
||||
|
||||
func (z *ZurgConfig) ShouldLogRequests() bool {
|
||||
return z.LogRequests
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
|
||||
if denominator == 0 {
|
||||
denominator = 1
|
||||
}
|
||||
efficiency := response.ServedMB / denominator
|
||||
efficiency := response.ServedMB * 100 / denominator
|
||||
|
||||
out += fmt.Sprintf(`
|
||||
<tr>
|
||||
|
||||
@@ -220,7 +220,9 @@ func (dl *Downloader) streamFileToResponse(
|
||||
}
|
||||
dl.RequestedBytes.Add(reqBytes)
|
||||
dl.TotalBytes.Add(uint64(n))
|
||||
log.Debugf("Served %d MB of the requested %d MB of file %s (range=%s)", bToMb(uint64(n)), bToMb(reqBytes), unrestrict.Filename, req.Header.Get("Range"))
|
||||
if cfg.ShouldLogRequests() {
|
||||
log.Debugf("Served %d MB of the requested %d MB of file %s (range=%s)", bToMb(uint64(n)), bToMb(reqBytes), unrestrict.Filename, req.Header.Get("Range"))
|
||||
}
|
||||
}
|
||||
|
||||
func redirect(resp http.ResponseWriter, req *http.Request, url string) {
|
||||
|
||||
Reference in New Issue
Block a user