Rename variables for easy reference
This commit is contained in:
@@ -201,6 +201,7 @@ func (r *HTTPClient) ensureReachableHost(req *http.Request) {
|
||||
if !strings.Contains(req.Host, ".download.real-debrid.") {
|
||||
return
|
||||
}
|
||||
// skip CDN servers
|
||||
if req.Host[0] >= 'a' && req.Host[0] <= 'z' {
|
||||
return
|
||||
}
|
||||
@@ -216,16 +217,18 @@ func (r *HTTPClient) ensureReachableHost(req *http.Request) {
|
||||
} else if strings.HasSuffix(req.Host, ".cloud") {
|
||||
newHost = strings.Replace(req.Host, ".cloud", ".com", 1)
|
||||
}
|
||||
// check if newHost is reachable
|
||||
if r.CheckIfHostIsReachable(newHost) {
|
||||
req.Host = newHost
|
||||
req.URL.Host = req.Host
|
||||
return
|
||||
}
|
||||
|
||||
// just pick a random host
|
||||
req.Host = r.hosts[rand.Intn(len(r.hosts))]
|
||||
req.URL.Host = req.Host
|
||||
}
|
||||
|
||||
// CheckIfHostIsReachable checks if the given host is passed in the list of reachable hosts
|
||||
func (r *HTTPClient) CheckIfHostIsReachable(reqHost string) bool {
|
||||
for _, host := range r.hosts {
|
||||
if reqHost == host {
|
||||
|
||||
Reference in New Issue
Block a user