Added 'no-proxy-check' parameter

This commit is contained in:
2024-11-22 23:58:17 +04:00
parent 9cfae3bdc1
commit 011c7a7774
6 changed files with 68 additions and 9 deletions

View File

@ -26,11 +26,42 @@ func getClients(
dodosCount uint,
maxConns uint,
yes bool,
noProxyCheck bool,
URL *url.URL,
) []*fasthttp.HostClient {
isTLS := URL.Scheme == "https"
if len(proxies) > 0 {
if proxiesLen := len(proxies); proxiesLen > 0 {
// If noProxyCheck is true, we will return the clients without checking the proxies.
if noProxyCheck {
clients := make([]*fasthttp.HostClient, 0, proxiesLen)
addr := URL.Host
if isTLS && URL.Port() == "" {
addr += ":443"
}
for _, proxy := range proxies {
dialFunc, err := getDialFunc(&proxy, timeout)
if err != nil {
continue
}
clients = append(clients, &fasthttp.HostClient{
MaxConns: int(maxConns),
IsTLS: isTLS,
Addr: addr,
Dial: dialFunc,
MaxIdleConnDuration: timeout,
MaxConnDuration: timeout,
WriteTimeout: timeout,
ReadTimeout: timeout,
},
)
}
return clients
}
// Else, we will check the proxies and return the active ones.
activeProxyClients := getActiveProxyClients(
ctx, proxies, timeout, dodosCount, maxConns, URL,
)

View File

@ -2,6 +2,7 @@ package requests
import (
"context"
"fmt"
"sync"
"time"
@ -24,6 +25,8 @@ import (
// - Responses: A collection of responses from the executed requests.
// - error: An error if the operation fails, such as no internet connection or an interrupt.
func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, error) {
fmt.Println("No Proxy Check:", requestConfig.NoProxyCheck)
checkConnectionCtx, checkConnectionCtxCancel := context.WithTimeout(ctx, 8*time.Second)
if !checkConnection(checkConnectionCtx) {
checkConnectionCtxCancel()
@ -38,6 +41,7 @@ func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, e
requestConfig.GetValidDodosCountForProxies(),
requestConfig.GetMaxConns(fasthttp.DefaultMaxConnsPerHost),
requestConfig.Yes,
requestConfig.NoProxyCheck,
requestConfig.URL,
)
if clients == nil {