Config dump
This commit is contained in:
@@ -25,16 +25,16 @@ import (
|
||||
)
|
||||
|
||||
type HTTPClient struct {
|
||||
client *http.Client
|
||||
maxRetries int
|
||||
timeoutSecs int
|
||||
backoff func(attempt int) time.Duration
|
||||
bearerToken string
|
||||
ensureIPv6Host bool
|
||||
cfg config.ConfigInterface
|
||||
ipv6 cmap.ConcurrentMap[string, string]
|
||||
ipv6Hosts []string
|
||||
log *logutil.Logger
|
||||
client *http.Client
|
||||
maxRetries int
|
||||
timeoutSecs int
|
||||
backoff func(attempt int) time.Duration
|
||||
bearerToken string
|
||||
supportIPv6 bool
|
||||
cfg config.ConfigInterface
|
||||
ipv6 cmap.ConcurrentMap[string, string]
|
||||
ipv6Hosts []string
|
||||
log *logutil.Logger
|
||||
}
|
||||
|
||||
// {
|
||||
@@ -51,17 +51,24 @@ func (e *ApiErrorResponse) Error() string {
|
||||
return fmt.Sprintf("api response error: %s (code: %d)", e.Message, e.Code)
|
||||
}
|
||||
|
||||
func NewHTTPClient(token string, maxRetries int, timeoutSecs int, ensureIPv6Host bool, cfg config.ConfigInterface, log *logutil.Logger) *HTTPClient {
|
||||
func NewHTTPClient(
|
||||
token string,
|
||||
maxRetries int,
|
||||
timeoutSecs int,
|
||||
supportIPv6 bool,
|
||||
cfg config.ConfigInterface,
|
||||
log *logutil.Logger,
|
||||
) *HTTPClient {
|
||||
client := HTTPClient{
|
||||
bearerToken: token,
|
||||
client: http.DefaultClient,
|
||||
maxRetries: maxRetries,
|
||||
timeoutSecs: timeoutSecs,
|
||||
backoff: backoffFunc,
|
||||
ensureIPv6Host: ensureIPv6Host,
|
||||
cfg: cfg,
|
||||
ipv6: cmap.New[string](),
|
||||
log: log,
|
||||
bearerToken: token,
|
||||
client: http.DefaultClient,
|
||||
maxRetries: maxRetries,
|
||||
timeoutSecs: timeoutSecs,
|
||||
backoff: backoffFunc,
|
||||
supportIPv6: supportIPv6,
|
||||
cfg: cfg,
|
||||
ipv6: cmap.New[string](),
|
||||
log: log,
|
||||
}
|
||||
|
||||
var dialer proxy.Dialer = &net.Dialer{
|
||||
@@ -191,7 +198,7 @@ func (r *HTTPClient) Do(req *http.Request) (*http.Response, error) {
|
||||
}
|
||||
|
||||
func (r *HTTPClient) replaceHostIfNeeded(req *http.Request) {
|
||||
if strings.HasSuffix(req.Host, "download.real-debrid.cloud") || !r.ensureIPv6Host || !r.cfg.ShouldForceIPv6() {
|
||||
if strings.HasSuffix(req.Host, "download.real-debrid.cloud") || !r.supportIPv6 || !r.cfg.ShouldForceIPv6() {
|
||||
return
|
||||
}
|
||||
// get subdomain of req.Host
|
||||
|
||||
Reference in New Issue
Block a user