Do no replace with random host if not on reachable host list
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -200,7 +199,10 @@ func (r *HTTPClient) Do(req *http.Request) (*http.Response, error) {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// ensureReachableHost ensures that the request is sent to a reachable host
|
||||
// if not, it will replace the host with a reachable one
|
||||
func (r *HTTPClient) ensureReachableHost(req *http.Request) {
|
||||
// skip if not a download server
|
||||
if !strings.Contains(req.Host, ".download.real-debrid.") {
|
||||
return
|
||||
}
|
||||
@@ -208,7 +210,6 @@ func (r *HTTPClient) ensureReachableHost(req *http.Request) {
|
||||
if req.Host[0] >= 'a' && req.Host[0] <= 'z' {
|
||||
return
|
||||
}
|
||||
|
||||
// check if req.Host is in r.hosts
|
||||
if r.CheckIfHostIsReachable(req.Host) {
|
||||
return
|
||||
@@ -226,9 +227,13 @@ func (r *HTTPClient) ensureReachableHost(req *http.Request) {
|
||||
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
|
||||
|
||||
// // just pick a random host
|
||||
// req.Host = r.hosts[rand.Intn(len(r.hosts))]
|
||||
// req.URL.Host = req.Host
|
||||
|
||||
// just retain the original host if not in the list of reachable hosts
|
||||
r.log.Debugf("Host %s is not found on the list of reachable hosts", req.Host)
|
||||
}
|
||||
|
||||
// CheckIfHostIsReachable checks if the given host is passed in the list of reachable hosts
|
||||
|
||||
Reference in New Issue
Block a user